Repository navigation
feat(browser): let the operator list loopback origins the built-in panel may open - #17657
Conversation
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Check before merge: no one has run this against a real Electron panel. Open a listed What this change shipsInventory (5 items) — 5 justifiedIntent: let a frontend developer have the agent open and drive their own local dev server in the built-in Browser panel they are already watching. This is an ADDITION (opt-in; Refs #10126).
[FIRST-PRINCIPLES-REVIEWED] 9d71d4a Description read[DESCRIPTION-READ] f71a09599ce2f8a20c6769abbffda99ffcef7ddba182faebdf4d5cb18f207d45 That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS The diff raises the prompt byte ceiling in [DESIGN-REVIEWED] 9d71d4a Description read[DESCRIPTION-READ] cfb9bd7a784ede9bf8e4d56e45a4440fe5488f3b93962ef8306d7d0e77c760cc That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
cfd6155 to
705fc22
Compare
|
Dispositions for the review lanes (head
|
705fc22 to
1ca0dbb
Compare
1ca0dbb to
f607a65
Compare
|
Conflict-only rebase onto current main (f607a65). The one conflict was the SSRF-gate comment in src/kiro_crew/mcp_tools/browser.py: kept main's 'ordinary shell approval ladder' wording and this PR's operator-allowlist sentence. range-diff shows no change to this PR's own lines. |
UX Review (Opus 5.5) — ⏭️ skippedRevision |
|
Pushed d9fe079 for the red |
…nel may open The native browser tool refuses every non-public navigate target, so the built-in panel cannot open the user's own dev server. Add dashboard.browser_local_origins: exact loopback host:port entries (localhost, 127.0.0.1 or [::1] with a required port). The coercer drops every other shape; the tool admits a navigate whose own host:port equals an entry byte for byte, after the same parser-differential refusals, with userinfo refused and the gateway's own port refused even when listed. Empty by default, read fresh per call, fails closed. Refs #10126
…budget Shorten the added Browser-section sentence and raise the prompt.md ceiling by the rule's remaining bytes, keeping 20 bytes of headroom as before.
d9fe079 to
9d71d4a
Compare
iamwhatever
left a comment
There was a problem hiding this comment.
This PR adds an opt-in dashboard.browser_local_origins list (default empty) so the native browser tool's navigate can open exact loopback host:port origins the operator wrote, like a Vite dev server, while everything else non-public stays refused. That solves the reported gap without loosening the public-only gate for anyone who does not opt in. I read the full diff and tried to get past the gate. The coercer only keeps localhost, 127.0.0.1 or [::1] with a 1-65535 port. The matcher refuses localhost.:5173, [::ffff:127.0.0.1], [0:0:0:0:0:0:0:1], 0x7f000001/2130706433, *.localhost, userinfo (localhost:5173@evil), %40 in the host, backslash/tab/control bytes, a bare default port that is not listed, and the gateway's own API port even when listed. It fails closed if config or the gateway port can't be read. #@evil lands in the fragment for both urlsplit and the browser, so the two parsers agree. I also checked that the agent cannot add entries itself: config.json is in sandbox._CREW_READONLY_LEAVES, the dashboard_config PUT only takes use_builtin_browser, and the generic PATCH /api/config/kirocrew is owner-gated (require_owner_dashboard_request). Redirects or links from a listed page are the same residual a public page already has, and the spec says so. Checks are green on 9d71d4a (two commits, within the limit), it is mergeable on main, all lanes PASS, and there are no open change requests. — crew-pr-reviewer (deep re-check)
Problem / Motivation
Goal: Let the user name the exact local dev-server origins (e.g.
localhost:5173) that the built-in Browser panel may open, while every other loopback, private and link-local address stays refused.The native
browserMCP tool refuses every non-publicnavigatetarget and redirects the agent toplaywright-cli. A frontend developer who watches the built-in panel therefore cannot have the agent open their own Vite dev server in it at all, and the issue reporter says theplaywright-clifallback does not work for them.Why it matters
Previewing one's own local app is the most common reason a frontend user wants the agent to drive a browser. Today the panel they are already watching cannot do it, so that workflow stalls on a fallback that may not work on their machine.
Not a goal
kirocrew config set dashboard.browser_local_origins '["localhost:5173"]'). A list editor is a follow-up once the shape is agreed, henceRefs, notCloses.playwright-clipath, its approval prompt, or the URL gate on ops other thannavigate.What changed (motivation → approach → change)
Goal → an explicit operator exception to the public-only
navigategate, narrow enough that it cannot reach the gateway's control plane → a newdashboard.browser_local_originslist plus a second, exact-match predicate in the tool.config/sections.py: new fieldbrowser_local_origins: list[str](default[]) andcoerce_browser_local_origins(). It keeps an entry only when it is exactlylocalhost,127.0.0.1or[::1], then:and an ASCII port in 1-65535, rebuilt canonically. It drops everything else: no port, scheme, path, userinfo,*.localhost, alternate IPv4 encodings, other 127/8 addresses, LAN addresses, non-strings, and a non-list value.mcp_tools/browser.py:_navigate_target_is_allowed_local(url, allowed)runs the same backslash/whitespace/control-character refusals as the public gate. It refuses any userinfo (@in the netloc) and fills the default port in from the scheme. It then requires the URL's ownhost:portto equal an entry byte for byte. The gateway's API port (mcp_core._api_port()) is refused even when listed, and an unknowable port refuses too._allowed_local_origins()reads the config on every call and fails closed to empty. That is the opposite polarity from_use_builtin_browser, because a read error must never widen the gate.navigatenow passes when the URL is public OR an allowed local origin. The refusal text names the setting and tells the agent to ask the user instead of editing it.config.jsonis a read-only leaf inside the sandbox (sandbox._CREW_READONLY_LEAVES), andPUT /api/dashboard/configdoes not accept the key. Withsandbox: offthat fence is gone, as it is for every other setting.config/prompt.md,docs/system-specs/modules/browser.mdandconfig-baseline.jsonare updated to describe the exception and its accepted residual.Backwards compatibility
Compatible: the new key defaults to an empty list, which leaves the existing
navigategate exactly as it is. No existing key, validator or caller changes.Removes nothing: the change only adds an opt-in exception. Every target refused today is still refused unless the operator lists it.
Tests
test/test_browser_local_origins.py(35 cases):0x7f000001/2130706433,*.localhost, the trailing-dot form, both userinfo tricks, backslash/tab differentials, non-http schemes, an invalid port, LAN addresses, and the gateway port even when listed. It also refuses when the gateway port is unknowable or the list is empty.Mutation-checked, each turning the new file red: dropping the gateway-port check (3 failures), removing the exception from the tool (1), dropping the userinfo refusal (1), and accepting any host in the coercer (2), and dropping the port length cap (1, a
ValueErrorpast the int digit limit). The existingtest/test_mcp_browser_tool.pyrefusal matrix still passes unchanged: an empty list keepshttp://localhost:8080/andhttp://[::1]/refused.Run with
pytest -n0by path: the two files above plustest_config_baseline.py,test_config_module_boundaries.pyandtest_config_refactor_contract.py. 124 passed.Manual verification
Not driven against a live Electron panel: this Linux host has no desktop build. Only the tool's admission decision changes, and the unit tests cover it end to end up to the bus POST. The panel's own handling of a loopback URL is unchanged and was already reachable through the
web-previewmarker. Windows/macOS behaviour is unverified on this host, but nothing in the change is platform-specific.Related Issues
Refs #10126
Decision for the owner
Should the built-in panel ever open a local origin, and if so, under what threat model? This draft says yes, but only for exact loopback
host:portentries the operator writes into config (never the gateway's own port, never a bare host or LAN address), because that unblocks the dev-server case while the agent cannot add entries to the list itself; I rejected a host-only or per-session approval-prompt design as wider and more complex.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license.