Skip to content

fix(browser): wire hardened TunnelProxy to engine remote proxy isolation - #302

Merged
Hona merged 56 commits into
devfrom
browser-tools/fix-tunnel-proxy-wiring
Nov 21, 2026
Merged

Hona merged 56 commits into
devfrom
browser-tools/fix-tunnel-proxy-wiring

Conversation

@Hona

@Hona Hona commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes notes/review-rd-tools.md Finding 5, all 4 engine-reader #292 tunnel conditions, all 4 Round-1 tunnel findings, the Round-2 post-EOF/pool finding, and both Round-3 findings (no idle kill on established authenticated tunnels/streams + 64-slot separate unauthenticated pool with 3 s head deadline and 1 s watchdog margin), stacked on #298 (over dev 00d73a6d, incl. #305, #316, #303).

Tunnel only: Zero prompt-gate changes (the minimal fail-open new-session-start-only gate PR follows separately after #298 and #302 merge).

1. Round-4 Fixes (notes/review-rd-tools.md:768-793)

  1. No idle kill on established authenticated tunnels or response streams (tunnel_proxy.rs, tunnel_pump.rs):
    • Matches Official proxy.ts: promote_authenticated() clears TrackedClient.deadline = None so slow remote http:// dev-server responses, http:// SSE streams (EventSource), quiet CONNECT (https:///wss://) tunnels, and quiet WebSockets are never killed for being idle.
    • Kept: 3 s total-head deadline on pre-auth connections; ~2 s active watchdog reclaim (POST_EOF_DRAIN_TIMEOUT via Shutdown::Both + per-connection abort + 500 ms poll slice) after remote chunk.eof for both stalled POST bodies and half-open CONNECT/WS clients; and immediate 0 ms drop of all connections on suspension (on_sse_disconnected), rotation, or proxy close.
    • Accepted residual (matches Official proxy.ts): A stalled authenticated socket holds one of the 64 authenticated tunnel slots until either the remote server or the browser closes it (or suspension/rotation tears down the proxy).
  2. Separate 64-slot unauthenticated pool with 3 s head deadline + 1 s watchdog margin (tunnel_proxy.rs):
    • MAX_UNAUTH_CONNS = MAX_TUNNELS (64), completely separate from MAX_CONCURRENT_CONNS = MAX_TUNNELS (64), so filling unauthenticated slots is no easier than before and never consumes authenticated tunnel slots.
    • HEADER_TIMEOUT = 3 s ensures rapid recovery (CEF sends CONNECT/HTTP head + credentials on loopback in < 5 ms), and WATCHDOG_HEAD_MARGIN = 1 s (4 s watchdog deadline) guarantees read_http_head finishes writing HTTP/1.1 408 Request Timeout cleanly before the watchdog calls Shutdown::Both.
    • Residual stated plainly: A process running as the same user on the same machine can deny service to the local tunnel proxy (it could also kill the app); in particular, 64 unauthenticated sockets re-opened continuously can still delay NEW handshakes past the 3 s head deadline (existing authenticated tunnels remain unaffected); nothing further is built against same-user local DoS.

2. Confirmed Tunnel Security Guarantees Preserved

  • Remote-only egress through experimental.browser/tunnel.{open,read,write,close} wired to #292's set_partition_proxy; zero local loopback/IMDS/LAN hits; require_remote_proxy_if_remote fail-closed navigation guard; browser.proxy.required CDP bootstrap retry.
  • Exclusive loopback IP literal bind (127.0.0.1:0 with Windows SO_EXCLUSIVEADDRUSE), fresh 384-bit OS-CSPRNG credentials per proxy, full-width usize constant_time_eq, 407 auth + hop-by-hop/auth header stripping, GET + HTTP/1.1 + 0-CL + no-pipelining + wait-for-101 WebSocket anti-smuggling, no-pipelining CONNECT, unbracketed IPv6 rejection, and immediate on_sse_disconnected -> suspend_server_tunnels (503 + 0 ms socket drop + set_partition_proxy(None)).

3. Security Scope

  • Actions added: None (wires TunnelProxy to #292's set_partition_proxy; zero contract.json growth, zero ENGINE_REVISION bump, zero struct App field growth).
  • Who can call / which tab/session touched: Native Rust BrowserRpcFeature only; never exposed to web pages or Luau plugins.
  • User confirmation required: None.

4. Driven Verification (50/50 Live PASS)

  • 10-minute live idle soak (proof/browser-tools/fix-c/idle-10min-probe.json, 2/2 PASS, idleElapsedSeconds: 605):
    • http_sse_survives_10min_idle: true (data: sse-after-10min\n\n delivered after 605 s completely silent).
    • quiet_websocket_survives_10min_idle: true (PING-AFTER-10MIN -> PONG-AFTER-10MIN after 605 s completely silent, zero early closes).
  • Direct TunnelProxy security probe (proof/browser-tools/fix-c/proxy-probe.json, 26/26 PASS):
    • slowloris_total_head_deadline_enforced_408: true (HTTP/1.1 408 Request Timeout cleanly written at ~3.0 s before the +1 s watchdog margin).
    • unauth_64_flood_recovers_within_head_deadline: true (64 idle unauth sockets held -> 65th unauth 503, existing auth WS live, new real authenticated HTTP request succeeds at ~3.1 s).
    • stalled_post_body_post_eof_reclaims_slot: true (~2.5 s), half_open_connect_post_eof_reclaims_slot: true (~2.5 s), concurrency_cap_65th_gets_503: true (64 real authenticated CONNECT/WS tunnels -> 65th gets 503), windows_so_exclusiveaddruse_blocks_cobind: true, constant_time_eq_256byte_diff_rejected_407: true, ws_http10_refused_400: true, unbracketed_ipv6_url_refused_400: true, ws_rejected_non101_forbids_client_smuggling: true, upgraded_ws_severed_on_suspend/close: true (0 ms).
  • Full compiled opencode-desktop.exe + CEF 156 proof (proof/browser-tools/fix-c/summary.json, 22/22 PASS on merged head): Remote confinement (0 local victim hits across loopback/IMDS/LAN/CONNECT/WebSocket), Proxy-Authorization/Transfer-Encoding stripped, rotation binds new port & closes old + drops upgraded WebSocket, sse_drop_suspends_remote_tunnel_immediately: true (HTTP/1.1 503 + live ws2 dropped while attach held), and engine fail-closed checks.
  • Checks: Guardrails 5/5 (tunnel_proxy.rs 697 / 800, tunnel_pump.rs 224 / 800), web.ps1 -Check, Apple & Linux browser-policy via tools/cargo.ps1, --workspace --all-targets, desktop build: ALL PASS (0 warnings).

Held unmerged for READER-10 fourth read.

Hona added 30 commits November 21, 2026 00:00
…hed servers and block check_cdp contextId/userGesture
…& pinned contextId, fix wait deadline spin, and bound payloads/cancel
…te-dual-route-cdp

# Conflicts:
#	apps/desktop/src/surfaces/browser/mod.rs
#	crates/browser-pane/src/protocol.rs
… proxy to SetPartitionProxy, and add BuiltinPromptGate
…ow sticky suppression, and harden CdpCall/check_cdp
…ools/fix-rpc-auth-bounds

# Conflicts:
#	crates/opencode-kit/src/client/browser_rpc/machine.rs
…pinned context/256-frame overflow, recheck post-capture auth, and fix OOPIF/cancel/bounds
…mic tunnel rotation/suspend, host proxy validation, and Luau loopback_host
…te-dual-route-cdp

# Conflicts:
#	apps/browser-engine/src/engine.rs
…ools/fix-rpc-auth-bounds

# Conflicts:
#	apps/browser-engine/src/engine.rs
#	apps/browser-engine/src/handlers.rs
#	apps/browser-engine/src/wire.rs
#	crates/browser-pane/src/client.rs
#	crates/browser-pane/src/machine.rs
#	crates/browser-pane/src/protocol.rs
…ix-tunnel-proxy-wiring

# Conflicts:
#	apps/browser-engine/src/context.rs
#	crates/browser-policy/src/lib.rs
…te-dual-route-cdp

# Conflicts:
#	apps/desktop/src/surfaces/browser/mod.rs
#	crates/browser-pane/src/client.rs
#	crates/browser-pane/src/protocol.rs
…egacy MCP until Unsupported/Unavailable, and fix #292 merge regressions
…ools/fix-rpc-auth-bounds

# Conflicts:
#	apps/browser-engine/src/downloads.rs
#	apps/browser-engine/src/engine.rs
#	apps/browser-engine/src/main.rs
#	crates/browser-pane/src/find.rs
Hona added 15 commits November 21, 2026 05:42
…ools/fix-rpc-auth-bounds

# Conflicts:
#	apps/browser-engine/src/engine.rs
#	apps/browser-engine/src/handlers.rs
#	apps/browser-engine/src/wire.rs
#	apps/desktop/src/surfaces/browser/rpc/mod.rs
…te-dual-route-cdp

# Conflicts:
#	apps/desktop/src/plugin_host/native/browser/scope.rs
#	crates/browser-pane/src/client.rs
… subframe enumeration, WHATWG target URL, required contextId, bounded CdpResponse IPC)
…ools/fix-rpc-auth-bounds

# Conflicts:
#	apps/desktop/src/surfaces/browser/rpc/exec/nav.rs
#	apps/desktop/src/surfaces/browser/rpc/mod.rs
…e.getFrameTree stubs and fix BrowserRpcState field visibility
…ix-tunnel-proxy-wiring

# Conflicts:
#	apps/browser-engine/src/context.rs
#	apps/desktop/src/surfaces/browser/mod.rs
#	apps/desktop/src/surfaces/browser/rpc/mod.rs
#	crates/browser-pane/src/client.rs
#	crates/browser-pane/src/find.rs
#	crates/browser-policy/src/lib.rs
#	plugins/browser/init.luau
…auth-bounds

# Conflicts:
#	apps/desktop/src/surfaces/browser/rpc/mod.rs
#	crates/opencode-kit/src/client/browser_rpc/machine.rs
…auth-bounds

# Conflicts:
#	apps/desktop/src/surfaces/browser/rpc/exec/nav.rs
…ix-tunnel-proxy-wiring

# Conflicts:
#	apps/desktop/src/surfaces/browser/rpc/exec/nav.rs
@Hona Hona changed the title fix(browser): harden and wire remote TunnelProxy (407/framing/WS drop/rotation) and BuiltinPromptGate fix(browser): wire hardened TunnelProxy to engine remote proxy isolation Nov 20, 2026
Hona added a commit that referenced this pull request Nov 20, 2026
…P-143 (#318)

- Fold confirmed merged PRs #307 (a1e7d0d, click-to-load reply videos),
  #306 (b5167f7, atomic agent_driven), #301 (6522f11, routed-session
  attach + recency closing #287 regression), #296 (95cb36a, legacy
  rune_mcp suppression + Half::is_builtin + check_cdp), #303 (6fb05ce,
  oc-preview:// app routing + raw file:// ban completing UP-095-PREVIEWS),
  and #316 (6e98fc2, Rune 7a707454 / #1307 strict local video opening)
- Add missing browser follow-up rows UP-095-3P-CONTRACT (#296 narrow
  third-party plugin browser contract gap) and UP-095-PROMPT-GATE
  (new-session-start-only prompt gate split from #302)
- Record #302 split (tunnel vs gate), #314 masking stream paused pending
  owner decision on agent-tab contexts, and updated browser Reviewed entries
- Audit upstream anomalyco/opencode 4122af0206..b9a60d9d07 (+11 commits:
  3 skipped, 8 added UP-136..UP-143)
Base automatically changed from browser-tools/fix-rpc-auth-bounds to dev November 20, 2026 23:58
…el-proxy-wiring

# Conflicts:
#	apps/desktop/src/surfaces/browser/rpc/exec/nav.rs
#	apps/desktop/src/surfaces/browser/rpc/mod.rs
#	apps/desktop/src/surfaces/browser/rpc/session.rs
@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

PR test build retired — merged into dev. Install or auto-update OpenCode (Rune) from https://anoma.ly/release/opencode/desktop-rune/dev/macos-arm64-dmg.

@Hona
Hona merged commit 8b42a09 into dev Nov 21, 2026
7 checks passed
@Hona
Hona deleted the browser-tools/fix-tunnel-proxy-wiring branch November 21, 2026 00:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant