From 8e45155d4300d48a6c6301b806144ddd5594bc87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Mon, 30 Nov 2026 15:42:43 +0100 Subject: [PATCH 01/12] docs(security): design remote web network confinement --- .../remote-web-public-network-confinement.md | 136 ++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 docs/experiments/remote-web-public-network-confinement.md diff --git a/docs/experiments/remote-web-public-network-confinement.md b/docs/experiments/remote-web-public-network-confinement.md new file mode 100644 index 00000000000..d12ec3b851f --- /dev/null +++ b/docs/experiments/remote-web-public-network-confinement.md @@ -0,0 +1,136 @@ +# Remote web public-network confinement + +## Status + +Design proposal. Remote tenant web commands stay refused with +`remote_web_public_network_unenforced` until this contract has an implementation and end-to-end +evidence. + +## Security invariant + +A browser that belongs to a request with `internal.publicNetworkOnly` must not create a network +connection to an address that is not globally reachable. This rule applies to every browser-created +connection for the session. It is not limited to the URL supplied to `open`. + +The enforcement point must select and connect the destination IP address. A URL check, a DNS check +followed by a browser connection, or inspection after a request cannot enforce the invariant. + +## Required boundary + +Use one daemon-owned explicit forward proxy for confined web sessions. Start the proxy before the +first browser process for a confined session. Keep it alive until that browser is closed. Configure +the browser with a fixed proxy and no direct fallback. + +The proxy must apply these rules: + +1. Accept connections only on a loopback listener. Apply global and per-session connection limits, + because another local user can discover and use a TCP listener. +2. Accept only HTTP proxy requests and HTTP `CONNECT` requests. +3. Parse the authority once. Reject user information, malformed ports, IP zone identifiers, and + non-canonical or ambiguous IP address forms. +4. Permit only `http`, `https`, `ws`, and `wss` browser traffic. Treat every other external protocol + as denied unless a later design names its enforcement path. +5. Resolve a hostname for each new upstream connection. Never reuse a browser-supplied resolution. +6. Classify every resolved address. Reject the request when any answer is unspecified, loopback, + link-local, private, carrier-grade NAT, documentation, benchmarking, multicast, reserved, or + otherwise non-unicast. Also reject every address assigned to a current daemon-host network + interface, including a publicly routed address. Apply IPv4 classification and local-interface + comparison to IPv4-mapped IPv6 addresses. +7. Connect to one admitted numeric address from that resolution result. Do not resolve the hostname + again in the connection API. Preserve the original hostname only for the HTTP `Host` field and + TLS server name that pass through the tunnel. +8. Apply the same resolution and connection rule to an absolute-form HTTP request and to `CONNECT`. +9. Re-resolve on a new connection, including after redirects, connection failure, proxy retry, and + keep-alive expiry. A previously admitted address does not admit a different address. +10. Bound request headers, connection count, DNS time, connect time, idle time, and bytes buffered + before either side applies backpressure. +11. Require absolute-form targets for ordinary HTTP. Treat the parsed target as the only authority, + and overwrite `Host` from that authority after admission. +12. Reject conflicting or ambiguous `Content-Length`, `Transfer-Encoding`, and upgrade framing. + Remove proxy credentials and hop-by-hop headers before forwarding. Preserve only the one valid + WebSocket upgrade shape. +13. Emit typed refusal details without returning resolved private addresses to the remote caller. + +The browser launch must use the fixed proxy as its only network route. It must remove Chromium's +implicit loopback bypass, disable QUIC, and disable non-proxied WebRTC UDP. The launch owner must +replace conflicting caller-supplied proxy, bypass, QUIC, and WebRTC arguments. Appending another +argument without proving Chromium's duplicate-argument precedence is not sufficient. + +If Chromium or `agent-browser` can create another external transport that does not use the fixed +proxy, remote web remains refused until that transport is disabled or confined. Examples include +WebTransport, direct sockets exposed by an extension, and a browser feature added after the pinned +backend version. + +## Coverage table + +| Traffic source | Required enforcement | +| --- | --- | +| Initial `open` URL | Scheme admission plus the proxy's resolution and pinned numeric connection | +| HTTP redirect | The redirected request returns through the proxy and receives a fresh connection admission | +| HTML subresource, worker, service worker, `fetch`, and XHR | The browser has no direct route, so every external connection returns through the proxy | +| WebSocket | `ws` uses an absolute-form proxy request and `wss` uses `CONNECT`; both use the same admission | +| DNS rebinding | The proxy connects only to an address from its own current result and never asks the socket layer to resolve again | +| HTTP keep-alive and HTTP/2 inside `CONNECT` | The admitted numeric peer stays fixed for the life of that connection | +| QUIC and WebTransport over HTTP/3 | Disabled unless the confinement owner later provides a UDP enforcement path | +| WebRTC | Non-proxied UDP disabled. A test must prove that the pinned Chromium build does not reach a private peer through another candidate type | +| `file`, `ftp`, `gopher`, custom handlers, and extension protocols | Refused before navigation or disabled at browser launch; no claim relies only on the current CLI URL parser | +| `data`, `blob`, `about`, and `view-source` | Local rendering may run, but any external connection that it initiates still uses the proxy | +| Browser proxy settings | Conflicting environment and caller arguments are replaced. Page content cannot change the fixed browser proxy | + +## Trust-boundary case table + +| Case | Who chooses the name | What the kernel resolves | What can change | Where bytes first leave the host | Result | +| --- | --- | --- | --- | --- | --- | +| Public hostname | Remote page or remote caller | Nothing by hostname; the proxy supplies a numeric address | DNS can change before the next connection | Proxy socket to the admitted public address | Accept | +| Public hostname resolves only to a denied address | Remote page or remote caller | No upstream socket is created | DNS can change after refusal | Nowhere | Refuse | +| Mixed public and denied answers | Authoritative DNS | No upstream socket is created | Answer order and TTL can change | Nowhere | Refuse the complete answer set | +| Hostname changes from public to denied | Authoritative DNS | Each connection receives one numeric address | DNS changes between connections | Existing connection stays on its admitted peer; the next connection is refused | Accept existing, refuse new | +| Numeric private address | Remote page or remote caller | Nothing | Text representations can be ambiguous | Nowhere | Refuse | +| Daemon host's public interface address | Remote page or remote caller | Nothing | Interface addresses can change | Nowhere | Refuse | +| Public HTTP redirect to private | Remote server | Nothing by hostname | Redirect target is attacker-controlled | Nowhere for the redirected destination | Refuse redirected connection | +| Public TLS tunnel | Remote page or remote caller | Nothing by hostname; proxy connects to an admitted numeric peer | Bytes inside TLS are opaque | Proxy socket to the admitted public address | Accept | +| Proxy unavailable or loses its listener capability | Daemon lifecycle | Nothing | Browser may retry | Nowhere | Fail closed; no direct fallback | + +## Lifecycle and ownership + +The confinement proxy belongs beside the managed browser lifecycle in `@agent-device/platform-web`. +The request router supplies the trusted `publicNetworkOnly` fact through request-bound runtime +composition. Page input and command flags must not be able to enable confinement for one call and +then reuse the browser without it, or disable confinement on a browser that was created with it. + +Confinement does not add a suffix or another axis to the device ID or backend key. ADR 0037 already +separates local `p_` browser keys from tenant-derived `t_` browser keys. Every `t_` browser is +confined, and its durable process record also identifies its proxy listener. A local request must +not adopt a confined remote browser, and a remote request must not adopt an unconfined browser. +Startup recovery must close a browser when it cannot prove that the matching proxy listener is live +and owned by this daemon process. + +`close` remains available when proxy startup, proxy recovery, or confinement admission fails. + +## Proof required before enabling remote web + +Focused unit tests must cover the complete IPv4 and IPv6 classification table, authority parsing, +pinned-address connection, limits, and typed refusals. Integration tests with the real pinned +Chromium and managed `agent-browser` must demonstrate denial for initial URLs, redirects, +subresources, workers, service workers, WebSockets, DNS rebinding, loopback bypass, QUIC, WebRTC, +and conflicting browser arguments. + +The browser evidence must observe attempted connections at a host network boundary. A proxy log +alone cannot prove that Chromium had no bypass. Run the same public destinations as negative +controls and prove that normal remote web commands still work. + +Repeat this evidence when the pinned `agent-browser` or Chromium version changes. Keep remote web +fail-closed when the evidence lane is absent or fails. + +## Rejected partial fixes + +- Checking only the `open` URL misses redirects, subresources, script-created requests, and sockets. +- Resolving before navigation and then passing the hostname to Chromium permits a second DNS lookup + and DNS rebinding. +- Request interception through an `agent-browser` command is unavailable in the managed backend and + would still need proof for workers, WebSockets, service workers, and browser-owned traffic. +- Observing `network requests` after execution detects traffic after the protected service may have + received it. +- An HTTP proxy without browser launch hardening leaves implicit bypasses and UDP transports. +- A DNS server that filters private answers does not pin the address used by the connection and does + not cover numeric destinations. From 74f9ddea503eee547b7adaa22733ad35bc5384ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Mon, 30 Nov 2026 15:59:42 +0100 Subject: [PATCH 02/12] docs(security): phase remote web confinement --- .../remote-web-public-network-confinement.md | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/docs/experiments/remote-web-public-network-confinement.md b/docs/experiments/remote-web-public-network-confinement.md index d12ec3b851f..edaf28ea288 100644 --- a/docs/experiments/remote-web-public-network-confinement.md +++ b/docs/experiments/remote-web-public-network-confinement.md @@ -61,6 +61,22 @@ proxy, remote web remains refused until that transport is disabled or confined. WebTransport, direct sockets exposed by an extension, and a browser feature added after the pinned backend version. +## Current backend seam + +The pinned `agent-browser` 0.39.0 has enough launch configuration to attach the boundary, but it +does not implement the boundary itself. + +- `--proxy` and `AGENT_BROWSER_PROXY` become Chromium `--proxy-server`. +- `--proxy-bypass` and `AGENT_BROWSER_PROXY_BYPASS` become Chromium `--proxy-bypass-list`. +- Proxy server, proxy bypass, credentials, raw arguments, and WebRTC restriction participate in the + backend launch hash. A changed value closes and relaunches the browser instead of reusing it. +- Raw launch arguments can disable QUIC. The backend's domain-filter path already removes a caller + WebRTC policy argument before it appends `disable_non_proxied_udp`. + +This seam is insufficient on its own. `@agent-device/platform-web` currently receives no trusted +`publicNetworkOnly` fact when it creates the request-scoped provider. It also has no daemon-owned +proxy server, no proxy lifecycle record, and no host-boundary bypass test. + ## Coverage table | Traffic source | Required enforcement | @@ -122,6 +138,39 @@ controls and prove that normal remote web commands still work. Repeat this evidence when the pinned `agent-browser` or Chromium version changes. Keep remote web fail-closed when the evidence lane is absent or fails. +## Phased implementation + +Each phase can merge while `assertRemoteWebDeviceAdmitted` still refuses remote web. Remove that +refusal only in the final phase. + +1. Add `publicNetworkOnly?: true` to `PlatformProviderRequestContext`. Populate it only from + `DaemonRequest.internal.publicNetworkOnly`. Forward it to default web provider construction. + Add routing tests that prove nested batch and replay requests cannot clear the fact. +2. Add a private `@agent-device/platform-web` public-destination classifier. Cover every IPv4 and + IPv6 range, IPv4-mapped IPv6, mixed DNS answers, and current host-interface addresses. Do not + export it as a general URL validator. +3. Add the bounded loopback forward proxy. Use Node's HTTP parser for absolute-form HTTP and + `CONNECT`. Resolve all answers, reject the complete set when one answer is denied, and connect + with the admitted numeric address. Add framing, header, timeout, backpressure, cancellation, and + capacity tests at this module boundary. +4. Give the default web provider a confinement-proxy lease keyed by the existing tenant backend + key. Start it before `open`. Pass the fixed proxy, an empty bypass list that removes Chromium's + implicit loopback bypass, `--disable-quic`, and the enforced WebRTC policy on every backend call. + Reject conflicting host environment settings instead of merging them. Record proxy ownership + beside the managed browser process record. Close both resources together. +5. Add real Chromium integration evidence for every row in the coverage table. Observe attempted + egress outside the proxy process. Include public negative controls and proxy-death fail-closed + behavior on macOS, Linux, and Windows. +6. Replace `remote_web_public_network_unenforced` admission with a check for a live, matching + confinement lease. Keep `close` independent of that check. Update help and security docs in the + same change. + +The dependency change is optional. The current backend flags can launch a confined browser. A +smaller and safer integration would add an upstream `--public-network-proxy ` mode that rejects +profiles, providers, restore/state, extensions, startup URLs in raw arguments, proxy bypasses, QUIC, +and unsafe WebRTC settings as one atomic launch policy. Without that API, agent-device must pin and +re-audit those launch-option conflicts at each backend upgrade. + ## Rejected partial fixes - Checking only the `open` URL misses redirects, subresources, script-created requests, and sockets. From c40c160b5a5ba947fb52e2b2ba4263bde8c14117 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Mon, 30 Nov 2026 16:42:19 +0100 Subject: [PATCH 03/12] docs(security): correct Chromium proxy bypass --- .../remote-web-public-network-confinement.md | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/docs/experiments/remote-web-public-network-confinement.md b/docs/experiments/remote-web-public-network-confinement.md index edaf28ea288..1710ea638dd 100644 --- a/docs/experiments/remote-web-public-network-confinement.md +++ b/docs/experiments/remote-web-public-network-confinement.md @@ -51,10 +51,14 @@ The proxy must apply these rules: WebSocket upgrade shape. 13. Emit typed refusal details without returning resolved private addresses to the remote caller. -The browser launch must use the fixed proxy as its only network route. It must remove Chromium's -implicit loopback bypass, disable QUIC, and disable non-proxied WebRTC UDP. The launch owner must -replace conflicting caller-supplied proxy, bypass, QUIC, and WebRTC arguments. Appending another -argument without proving Chromium's duplicate-argument precedence is not sufficient. +The browser launch must use the fixed proxy as its only network route. It must set +`--proxy-bypass-list="<-loopback>"`; an empty bypass list retains Chromium's implicit direct rules +for localhost, link-local, and unspecified addresses. Chromium documents `<-loopback>` as the +subtractive rule for those implicit bypasses in +[Proxy support in Chrome](https://chromium.googlesource.com/chromium/src/+/master/net/docs/proxy.md#proxy-config-url-patterns_subtract-implicit-rules). +The launch must also disable QUIC and non-proxied WebRTC UDP. The launch owner must replace +conflicting caller-supplied proxy, bypass, QUIC, and WebRTC arguments. Appending another argument +without proving Chromium's duplicate-argument precedence is not sufficient. If Chromium or `agent-browser` can create another external transport that does not use the fixed proxy, remote web remains refused until that transport is disabled or confined. Examples include @@ -91,7 +95,7 @@ proxy server, no proxy lifecycle record, and no host-boundary bypass test. | WebRTC | Non-proxied UDP disabled. A test must prove that the pinned Chromium build does not reach a private peer through another candidate type | | `file`, `ftp`, `gopher`, custom handlers, and extension protocols | Refused before navigation or disabled at browser launch; no claim relies only on the current CLI URL parser | | `data`, `blob`, `about`, and `view-source` | Local rendering may run, but any external connection that it initiates still uses the proxy | -| Browser proxy settings | Conflicting environment and caller arguments are replaced. Page content cannot change the fixed browser proxy | +| Browser proxy settings | Conflicting environment and caller arguments are replaced. The bypass list is exactly `<-loopback>`, not empty. Page content cannot change the fixed browser proxy | ## Trust-boundary case table @@ -105,6 +109,8 @@ proxy server, no proxy lifecycle record, and no host-boundary bypass test. | Daemon host's public interface address | Remote page or remote caller | Nothing | Interface addresses can change | Nowhere | Refuse | | Public HTTP redirect to private | Remote server | Nothing by hostname | Redirect target is attacker-controlled | Nowhere for the redirected destination | Refuse redirected connection | | Public TLS tunnel | Remote page or remote caller | Nothing by hostname; proxy connects to an admitted numeric peer | Bytes inside TLS are opaque | Proxy socket to the admitted public address | Accept | +| Fixed proxy with an empty bypass list | Chromium's implicit rules | Chromium may connect directly to localhost, link-local, or unspecified literals | Browser defaults can change with Chromium | Browser socket bypasses the proxy | Refuse the launch configuration | +| Fixed proxy with bypass list `<-loopback>` | Remote page or remote caller | Proxy resolves and connects as above | Browser defaults can change with Chromium | Proxy socket only | Accept after the host-boundary bypass test passes | | Proxy unavailable or loses its listener capability | Daemon lifecycle | Nothing | Browser may retry | Nowhere | Fail closed; no direct fallback | ## Lifecycle and ownership @@ -154,8 +160,8 @@ refusal only in the final phase. with the admitted numeric address. Add framing, header, timeout, backpressure, cancellation, and capacity tests at this module boundary. 4. Give the default web provider a confinement-proxy lease keyed by the existing tenant backend - key. Start it before `open`. Pass the fixed proxy, an empty bypass list that removes Chromium's - implicit loopback bypass, `--disable-quic`, and the enforced WebRTC policy on every backend call. + key. Start it before `open`. Pass the fixed proxy, the exact `<-loopback>` subtractive bypass + rule, `--disable-quic`, and the enforced WebRTC policy on every backend call. Reject conflicting host environment settings instead of merging them. Record proxy ownership beside the managed browser process record. Close both resources together. 5. Add real Chromium integration evidence for every row in the coverage table. Observe attempted From 9eb0ac8737c67e34fcb035a58fd0f2f0eda44632 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Mon, 30 Nov 2026 16:54:55 +0100 Subject: [PATCH 04/12] docs(security): require isolated confined browser sessions --- .../remote-web-public-network-confinement.md | 46 +++++++++++++------ 1 file changed, 33 insertions(+), 13 deletions(-) diff --git a/docs/experiments/remote-web-public-network-confinement.md b/docs/experiments/remote-web-public-network-confinement.md index 1710ea638dd..d1616d4465f 100644 --- a/docs/experiments/remote-web-public-network-confinement.md +++ b/docs/experiments/remote-web-public-network-confinement.md @@ -65,21 +65,35 @@ proxy, remote web remains refused until that transport is disabled or confined. WebTransport, direct sockets exposed by an extension, and a browser feature added after the pinned backend version. -## Current backend seam +## Backend launch and session isolation -The pinned `agent-browser` 0.39.0 has enough launch configuration to attach the boundary, but it -does not implement the boundary itself. +The implementation stack updates the managed backend from `agent-browser` 0.39.0 to 0.42.0 in +#5273. The proxy flags expose a launch seam, but they do not enforce confinement by themselves. - `--proxy` and `AGENT_BROWSER_PROXY` become Chromium `--proxy-server`. - `--proxy-bypass` and `AGENT_BROWSER_PROXY_BYPASS` become Chromium `--proxy-bypass-list`. -- Proxy server, proxy bypass, credentials, raw arguments, and WebRTC restriction participate in the - backend launch hash. A changed value closes and relaunches the browser instead of reusing it. +- A changed proxy launch setting can relaunch a managed browser. The setting is ignored when the + session attaches through CDP, auto-connect, or a provider. - Raw launch arguments can disable QUIC. The backend's domain-filter path already removes a caller WebRTC policy argument before it appends `disable_non_proxied_udp`. -This seam is insufficient on its own. `@agent-device/platform-web` currently receives no trusted -`publicNetworkOnly` fact when it creates the request-scoped provider. It also has no daemon-owned -proxy server, no proxy lifecycle record, and no host-boundary bypass test. +The managed backend inherits `AGENT_BROWSER_*` connection settings from the daemon host. It also +uses the same socket directory for local and remote web sessions. This layout does not establish +that an existing browser was started under the remote confinement policy. An inherited connection +target can also select an external browser where the proxy setting has no effect. The +[0.42.0 session documentation](https://raw.githubusercontent.com/vercel-labs/agent-browser/v0.42.0/skill-data/core/references/session-management.md) +describes both the ignored proxy setting on external connections and retained settings across +commands and daemon restarts. A successful CLI command does not prove that its browser used the +proxy. + +Route remote sessions through a daemon-owned socket namespace separate from local sessions. Preserve +the ADR 0037 backend key and socket path limits. Remove inherited connection targets, profiles, +extensions, restore and state inputs, raw startup arguments, and conflicting proxy settings before +launch. Reject a remote command if the backend can still attach through CDP, auto-connect, or a +provider. Start a fresh managed Chromium browser under the confined policy, and verify that the +backend applied the proxy setting before accepting the session. Apply the same policy to every +later command that can launch or relaunch a browser. Keep the proxy alive through the browser's +life and close the browser if the matching proxy cannot be recovered. ## Coverage table @@ -96,6 +110,8 @@ proxy server, no proxy lifecycle record, and no host-boundary bypass test. | `file`, `ftp`, `gopher`, custom handlers, and extension protocols | Refused before navigation or disabled at browser launch; no claim relies only on the current CLI URL parser | | `data`, `blob`, `about`, and `view-source` | Local rendering may run, but any external connection that it initiates still uses the proxy | | Browser proxy settings | Conflicting environment and caller arguments are replaced. The bypass list is exactly `<-loopback>`, not empty. Page content cannot change the fixed browser proxy | +| Prior local session or inherited connection target | Remote socket namespace is separate. CDP, auto-connect, and provider attachments are rejected before navigation | +| Relaunch after a later command or daemon restart | The same confinement policy and live proxy are required before any browser process starts | ## Trust-boundary case table @@ -112,6 +128,7 @@ proxy server, no proxy lifecycle record, and no host-boundary bypass test. | Fixed proxy with an empty bypass list | Chromium's implicit rules | Chromium may connect directly to localhost, link-local, or unspecified literals | Browser defaults can change with Chromium | Browser socket bypasses the proxy | Refuse the launch configuration | | Fixed proxy with bypass list `<-loopback>` | Remote page or remote caller | Proxy resolves and connects as above | Browser defaults can change with Chromium | Proxy socket only | Accept after the host-boundary bypass test passes | | Proxy unavailable or loses its listener capability | Daemon lifecycle | Nothing | Browser may retry | Nowhere | Fail closed; no direct fallback | +| Existing or externally attached browser ignores proxy settings | Backend session state or inherited host environment | No confined destination is proven | A later command can reuse or relaunch the browser | The external browser can connect directly | Refuse; do not adopt that browser | ## Lifecycle and ownership @@ -125,7 +142,8 @@ separates local `p_` browser keys from tenant-derived `t_` browser keys. Every ` confined, and its durable process record also identifies its proxy listener. A local request must not adopt a confined remote browser, and a remote request must not adopt an unconfined browser. Startup recovery must close a browser when it cannot prove that the matching proxy listener is live -and owned by this daemon process. +and owned by this daemon process. The remote socket namespace must remain separate after a daemon +restart. A local session must not be able to reuse its backend key to enter that namespace. `close` remains available when proxy startup, proxy recovery, or confinement admission fails. @@ -160,10 +178,12 @@ refusal only in the final phase. with the admitted numeric address. Add framing, header, timeout, backpressure, cancellation, and capacity tests at this module boundary. 4. Give the default web provider a confinement-proxy lease keyed by the existing tenant backend - key. Start it before `open`. Pass the fixed proxy, the exact `<-loopback>` subtractive bypass - rule, `--disable-quic`, and the enforced WebRTC policy on every backend call. - Reject conflicting host environment settings instead of merging them. Record proxy ownership - beside the managed browser process record. Close both resources together. + key. Isolate its backend socket namespace from local sessions. Start the proxy before `open`. + Pass the fixed proxy, the exact `<-loopback>` subtractive bypass rule, `--disable-quic`, and the + enforced WebRTC policy on every backend call. Remove inherited connection targets and reject + external attachments and conflicting host settings. Verify a fresh managed browser received the + proxy policy before navigation. Record proxy ownership beside the managed browser process record. + Close both resources together. 5. Add real Chromium integration evidence for every row in the coverage table. Observe attempted egress outside the proxy process. Include public negative controls and proxy-death fail-closed behavior on macOS, Linux, and Windows. From 4a5c2eeac2e3476b0b22dc05bd5190402159ed28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Mon, 30 Nov 2026 17:09:18 +0100 Subject: [PATCH 05/12] docs(security): bind remote web confinement to session state --- .../remote-web-public-network-confinement.md | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/docs/experiments/remote-web-public-network-confinement.md b/docs/experiments/remote-web-public-network-confinement.md index d1616d4465f..80123cd61df 100644 --- a/docs/experiments/remote-web-public-network-confinement.md +++ b/docs/experiments/remote-web-public-network-confinement.md @@ -137,10 +137,13 @@ The request router supplies the trusted `publicNetworkOnly` fact through request composition. Page input and command flags must not be able to enable confinement for one call and then reuse the browser without it, or disable confinement on a browser that was created with it. -Confinement does not add a suffix or another axis to the device ID or backend key. ADR 0037 already -separates local `p_` browser keys from tenant-derived `t_` browser keys. Every `t_` browser is -confined, and its durable process record also identifies its proxy listener. A local request must -not adopt a confined remote browser, and a remote request must not adopt an unconfined browser. +Confinement does not add a suffix or another axis to the device ID or backend key. ADR 0037 derives +`p_`, `w_`, and `t_` keys from session and tenant isolation, independently of `publicNetworkOnly`. +A remote request can therefore use a `p_` or `w_` key, and a local tenant-isolated request can use +a `t_` key. Record the confinement fact on the web session lease and durable process record. Before +an existing session is adopted, compare that fact with the request and refuse a mismatch, regardless +of key prefix. Keep confined browser sockets in a separate namespace from local browser sockets. +The process record also identifies the confined browser's proxy listener. Startup recovery must close a browser when it cannot prove that the matching proxy listener is live and owned by this daemon process. The remote socket namespace must remain separate after a daemon restart. A local session must not be able to reuse its backend key to enter that namespace. @@ -177,8 +180,10 @@ refusal only in the final phase. `CONNECT`. Resolve all answers, reject the complete set when one answer is denied, and connect with the admitted numeric address. Add framing, header, timeout, backpressure, cancellation, and capacity tests at this module boundary. -4. Give the default web provider a confinement-proxy lease keyed by the existing tenant backend - key. Isolate its backend socket namespace from local sessions. Start the proxy before `open`. +4. Give the default web provider a confinement-proxy lease keyed by the existing backend key and + recorded confinement fact. Refuse adoption when a request's fact differs from that of the + existing session. Isolate its backend socket namespace from local sessions. Start the proxy + before `open`. Pass the fixed proxy, the exact `<-loopback>` subtractive bypass rule, `--disable-quic`, and the enforced WebRTC policy on every backend call. Remove inherited connection targets and reject external attachments and conflicting host settings. Verify a fresh managed browser received the From bdee98102d7ad38166f6422e1274c7f7d243a6f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Mon, 30 Nov 2026 20:37:56 +0100 Subject: [PATCH 06/12] docs(security): cover DNS64 in remote web confinement design --- .../remote-web-public-network-confinement.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/experiments/remote-web-public-network-confinement.md b/docs/experiments/remote-web-public-network-confinement.md index 80123cd61df..18c723f8415 100644 --- a/docs/experiments/remote-web-public-network-confinement.md +++ b/docs/experiments/remote-web-public-network-confinement.md @@ -35,7 +35,10 @@ The proxy must apply these rules: link-local, private, carrier-grade NAT, documentation, benchmarking, multicast, reserved, or otherwise non-unicast. Also reject every address assigned to a current daemon-host network interface, including a publicly routed address. Apply IPv4 classification and local-interface - comparison to IPv4-mapped IPv6 addresses. + comparison to IPv4-mapped IPv6 addresses. Reject IPv4-embedded IPv6 answers, including DNS64 + synthesis under a network-specific Pref64, unless the proxy can prove the embedded IPv4 + destination is public and the translated peer is not on a local interface. If the prefix cannot + be identified and checked, refuse the answer set. 7. Connect to one admitted numeric address from that resolution result. Do not resolve the hostname again in the connection API. Preserve the original hostname only for the HTTP `Host` field and TLS server name that pass through the tunnel. @@ -104,6 +107,7 @@ life and close the browser if the matching proxy cannot be recovered. | HTML subresource, worker, service worker, `fetch`, and XHR | The browser has no direct route, so every external connection returns through the proxy | | WebSocket | `ws` uses an absolute-form proxy request and `wss` uses `CONNECT`; both use the same admission | | DNS rebinding | The proxy connects only to an address from its own current result and never asks the socket layer to resolve again | +| DNS64/NAT64 answer | The proxy identifies the synthesis prefix and classifies the embedded IPv4 destination before connecting, or refuses the answer set | | HTTP keep-alive and HTTP/2 inside `CONNECT` | The admitted numeric peer stays fixed for the life of that connection | | QUIC and WebTransport over HTTP/3 | Disabled unless the confinement owner later provides a UDP enforcement path | | WebRTC | Non-proxied UDP disabled. A test must prove that the pinned Chromium build does not reach a private peer through another candidate type | @@ -159,7 +163,7 @@ subresources, workers, service workers, WebSockets, DNS rebinding, loopback bypa and conflicting browser arguments. The browser evidence must observe attempted connections at a host network boundary. A proxy log -alone cannot prove that Chromium had no bypass. Run the same public destinations as negative +alone cannot prove that Chromium had no bypass. Run the same public destinations as positive controls and prove that normal remote web commands still work. Repeat this evidence when the pinned `agent-browser` or Chromium version changes. Keep remote web @@ -174,8 +178,8 @@ refusal only in the final phase. `DaemonRequest.internal.publicNetworkOnly`. Forward it to default web provider construction. Add routing tests that prove nested batch and replay requests cannot clear the fact. 2. Add a private `@agent-device/platform-web` public-destination classifier. Cover every IPv4 and - IPv6 range, IPv4-mapped IPv6, mixed DNS answers, and current host-interface addresses. Do not - export it as a general URL validator. + IPv6 range, IPv4-mapped IPv6, DNS64/NAT64 synthesis, mixed DNS answers, and current host-interface + addresses. Do not export it as a general URL validator. 3. Add the bounded loopback forward proxy. Use Node's HTTP parser for absolute-form HTTP and `CONNECT`. Resolve all answers, reject the complete set when one answer is denied, and connect with the admitted numeric address. Add framing, header, timeout, backpressure, cancellation, and @@ -190,7 +194,7 @@ refusal only in the final phase. proxy policy before navigation. Record proxy ownership beside the managed browser process record. Close both resources together. 5. Add real Chromium integration evidence for every row in the coverage table. Observe attempted - egress outside the proxy process. Include public negative controls and proxy-death fail-closed + egress outside the proxy process. Include public positive controls and proxy-death fail-closed behavior on macOS, Linux, and Windows. 6. Replace `remote_web_public_network_unenforced` admission with a check for a live, matching confinement lease. Keep `close` independent of that check. Update help and security docs in the From 7a3bb06673c27ab4810269bec3010fd672a95eb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Mon, 30 Nov 2026 16:09:54 +0100 Subject: [PATCH 07/12] fix(web): carry remote network policy into browser provider --- packages/contracts/src/platform-providers.ts | 2 ++ .../request-platform-provider-context.test.ts | 16 +++++++++++++++ .../request-platform-provider-context.ts | 1 + .../platform-web/src/__tests__/test-utils.ts | 1 + .../src/agent-browser-provider.test.ts | 20 +++++++++++++++++++ .../src/agent-browser-provider.ts | 14 +++++++++++-- src/platform-runtime/request-providers.ts | 1 + 7 files changed, 53 insertions(+), 2 deletions(-) diff --git a/packages/contracts/src/platform-providers.ts b/packages/contracts/src/platform-providers.ts index 7519e10d4d1..a6438392b43 100644 --- a/packages/contracts/src/platform-providers.ts +++ b/packages/contracts/src/platform-providers.ts @@ -24,6 +24,8 @@ export type PlatformProviderRequestContext = Readonly<{ requestId?: string; /** Daemon policy says that the root may construct its managed Web provider for this request. */ useDefaultWebProvider?: boolean; + /** The daemon's trusted remote-tenant policy for this request. */ + publicNetworkOnly?: true; }>; /** The only request-scoped platform value currently consumed by daemon handlers. diff --git a/packages/daemon/src/server/request-platform-provider-context.test.ts b/packages/daemon/src/server/request-platform-provider-context.test.ts index 5c24b640df1..82bf79373d4 100644 --- a/packages/daemon/src/server/request-platform-provider-context.test.ts +++ b/packages/daemon/src/server/request-platform-provider-context.test.ts @@ -76,6 +76,22 @@ test('request provider context preserves an explicitly empty request id', async assert.equal(context?.device.id, IOS_SIMULATOR.id); }); +test('request provider context carries only the daemon-owned network policy', async () => { + const local = await resolvePlatformProviderRequestContext({ + req: request('snapshot'), + existingSession: makeIosSession('ios-session'), + env: process.env, + }); + const remote = await resolvePlatformProviderRequestContext({ + req: { ...request('snapshot'), internal: { publicNetworkOnly: true } }, + existingSession: makeIosSession('ios-session'), + env: process.env, + }); + + assert.equal(local?.publicNetworkOnly, undefined); + assert.equal(remote?.publicNetworkOnly, true); +}); + function request(command: string): DaemonRequest { return { token: 'test-token', diff --git a/packages/daemon/src/server/request-platform-provider-context.ts b/packages/daemon/src/server/request-platform-provider-context.ts index 3784652d663..22704cdc299 100644 --- a/packages/daemon/src/server/request-platform-provider-context.ts +++ b/packages/daemon/src/server/request-platform-provider-context.ts @@ -46,6 +46,7 @@ export async function resolvePlatformProviderRequestContext(params: { } : {}), ...(params.useDefaultWebProvider ? { useDefaultWebProvider: true } : {}), + ...(params.req.internal?.publicNetworkOnly === true ? { publicNetworkOnly: true } : {}), }; } diff --git a/packages/platform-web/src/__tests__/test-utils.ts b/packages/platform-web/src/__tests__/test-utils.ts index b1ce155074d..f93c4c8f7a6 100644 --- a/packages/platform-web/src/__tests__/test-utils.ts +++ b/packages/platform-web/src/__tests__/test-utils.ts @@ -59,6 +59,7 @@ export async function withManagedAgentBrowserProvider( session?: string; openWebSessionNames?: () => readonly string[]; ownedProcessRecords?: OwnedProcessRecordStore; + publicNetworkOnly?: true; }, testFn: (provider: WebProvider) => void | Promise, ): Promise { diff --git a/packages/platform-web/src/agent-browser-provider.test.ts b/packages/platform-web/src/agent-browser-provider.test.ts index e7068257140..dd6ece085a6 100644 --- a/packages/platform-web/src/agent-browser-provider.test.ts +++ b/packages/platform-web/src/agent-browser-provider.test.ts @@ -56,6 +56,26 @@ test('agent-browser provider keys its browser on its backend key as given', asyn }); }); +test('a confined remote provider refuses browser commands before spawning the backend', async () => { + await withManagedAgentBrowserProvider( + { session: 't_remote-session', publicNetworkOnly: true }, + async (provider) => { + const calls: AgentBrowserCall[] = []; + await withCommandExecutorOverride(recordingExecutor(calls), async () => { + await assert.rejects(provider.open('https://example.test'), (error: unknown) => + error instanceof AppError && + error.code === 'UNSUPPORTED_OPERATION' && + error.details?.reason === 'remote_web_public_network_unenforced', + ); + await provider.close(); + }); + assert.deepEqual(calls.map((call) => call.args), [ + ['close', '--json', '--session', 't_remote-session'], + ]); + }, + ); +}); + test('agent-browser provider maps supported operations to session-scoped JSON commands', async () => { await withManagedAgentBrowserProvider({ session: 'web-session' }, async (provider) => { const calls: AgentBrowserCall[] = []; diff --git a/packages/platform-web/src/agent-browser-provider.ts b/packages/platform-web/src/agent-browser-provider.ts index 1d6e2084cd7..fa69fdc4c38 100644 --- a/packages/platform-web/src/agent-browser-provider.ts +++ b/packages/platform-web/src/agent-browser-provider.ts @@ -58,6 +58,8 @@ type AgentBrowserProviderOptions = { /** The backend keys of the published web sessions. */ openWebSessionNames?: () => readonly string[]; ownedProcessRecords?: OwnedProcessRecordStore; + /** The daemon requires public-network confinement for this request. */ + publicNetworkOnly?: true; }; /** How one backend call is executed: cancellation, plus the work it reads from stdin (`batch`). */ @@ -73,8 +75,16 @@ type AgentBrowserRunOptions = { export function createAgentBrowserWebProvider(options: AgentBrowserProviderOptions): WebProvider { const { session } = options; - const runJson = async (args: string[], run?: AgentBrowserRunOptions): Promise => - await runAgentBrowserJson(args, { session, options, ...run }); + const runJson = async (args: string[], run?: AgentBrowserRunOptions): Promise => { + if (options.publicNetworkOnly && args[0] !== 'close') { + throw new AppError( + 'UNSUPPORTED_OPERATION', + 'Remote web sessions require public-network confinement.', + { reason: 'remote_web_public_network_unenforced', retriable: false }, + ); + } + return await runAgentBrowserJson(args, { session, options, ...run }); + }; return { async open(target) { diff --git a/src/platform-runtime/request-providers.ts b/src/platform-runtime/request-providers.ts index 7dd3adadd8b..ddbcf8a3fa6 100644 --- a/src/platform-runtime/request-providers.ts +++ b/src/platform-runtime/request-providers.ts @@ -159,6 +159,7 @@ async function providersForContext( stateDir: defaultWebProvider.stateDir, openWebSessionNames: defaultWebProvider.openWebSessionNames, ownedProcessRecords: defaultWebProvider.ownedProcessRecords, + ...(context.publicNetworkOnly === true ? { publicNetworkOnly: true } : {}), }); return { ...providers, From 87058a5b1dd29eba99bb9d369c0cdcc797476c91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Mon, 30 Nov 2026 16:17:01 +0100 Subject: [PATCH 08/12] fix(web): own confined browser refusal at launch --- .../src/agent-browser-provider.test.ts | 17 ++++++++++------- .../platform-web/src/agent-browser-provider.ts | 17 ++++------------- packages/platform-web/src/agent-browser-tool.ts | 16 ++++++++++++++-- website/docs/docs/error-reasons.md | 1 + 4 files changed, 29 insertions(+), 22 deletions(-) diff --git a/packages/platform-web/src/agent-browser-provider.test.ts b/packages/platform-web/src/agent-browser-provider.test.ts index dd6ece085a6..62b0fa36777 100644 --- a/packages/platform-web/src/agent-browser-provider.test.ts +++ b/packages/platform-web/src/agent-browser-provider.test.ts @@ -62,16 +62,19 @@ test('a confined remote provider refuses browser commands before spawning the ba async (provider) => { const calls: AgentBrowserCall[] = []; await withCommandExecutorOverride(recordingExecutor(calls), async () => { - await assert.rejects(provider.open('https://example.test'), (error: unknown) => - error instanceof AppError && - error.code === 'UNSUPPORTED_OPERATION' && - error.details?.reason === 'remote_web_public_network_unenforced', + await assert.rejects( + provider.open('https://example.test'), + (error: unknown) => + error instanceof AppError && + error.code === 'UNSUPPORTED_OPERATION' && + error.details?.reason === 'remote_web_browser_unconfined', ); await provider.close(); }); - assert.deepEqual(calls.map((call) => call.args), [ - ['close', '--json', '--session', 't_remote-session'], - ]); + assert.deepEqual( + calls.map((call) => call.args), + [['close', '--json', '--session', 't_remote-session']], + ); }, ); }); diff --git a/packages/platform-web/src/agent-browser-provider.ts b/packages/platform-web/src/agent-browser-provider.ts index fa69fdc4c38..2efce69e602 100644 --- a/packages/platform-web/src/agent-browser-provider.ts +++ b/packages/platform-web/src/agent-browser-provider.ts @@ -58,11 +58,10 @@ type AgentBrowserProviderOptions = { /** The backend keys of the published web sessions. */ openWebSessionNames?: () => readonly string[]; ownedProcessRecords?: OwnedProcessRecordStore; - /** The daemon requires public-network confinement for this request. */ publicNetworkOnly?: true; }; -/** How one backend call is executed: cancellation, plus the work it reads from stdin (`batch`). */ +/** Cancellation and stdin work for one backend call. */ type AgentBrowserRunOptions = { signal?: AbortSignal; stdin?: string; @@ -74,17 +73,8 @@ type AgentBrowserRunOptions = { }; export function createAgentBrowserWebProvider(options: AgentBrowserProviderOptions): WebProvider { - const { session } = options; - const runJson = async (args: string[], run?: AgentBrowserRunOptions): Promise => { - if (options.publicNetworkOnly && args[0] !== 'close') { - throw new AppError( - 'UNSUPPORTED_OPERATION', - 'Remote web sessions require public-network confinement.', - { reason: 'remote_web_public_network_unenforced', retriable: false }, - ); - } - return await runAgentBrowserJson(args, { session, options, ...run }); - }; + const runJson = async (args: string[], run?: AgentBrowserRunOptions): Promise => + await runAgentBrowserJson(args, { session: options.session, options, ...run }); return { async open(target) { @@ -637,6 +627,7 @@ async function runAgentBrowserCommand( stateDir: options.stateDir, allowFailure: true, timeoutMs: AGENT_BROWSER_TIMEOUT_MS, + ...(options.publicNetworkOnly ? { publicNetworkOnly: true } : {}), signal: run.signal, stdin: run.stdin, }); diff --git a/packages/platform-web/src/agent-browser-tool.ts b/packages/platform-web/src/agent-browser-tool.ts index defd57d917e..9c7f520190e 100644 --- a/packages/platform-web/src/agent-browser-tool.ts +++ b/packages/platform-web/src/agent-browser-tool.ts @@ -47,6 +47,7 @@ export type ManagedAgentBrowserRunOptions = { timeoutMs: number; allowFailure?: boolean; signal?: AbortSignal; + publicNetworkOnly?: true; /** Written to the backend's stdin, for the command that reads its work from it (`batch`). */ stdin?: string; }; @@ -60,6 +61,16 @@ export async function runManagedAgentBrowser( args: readonly string[], options: ManagedAgentBrowserRunOptions, ): Promise { + if (options.publicNetworkOnly && args[0] !== 'close') { + throw new AppError( + 'UNSUPPORTED_OPERATION', + 'Remote web browser network access is unavailable.', + { + reason: AGENT_BROWSER_REFUSAL_REASONS.remoteNetworkUnenforced.reason, + retriable: false, + }, + ); + } const status = getManagedAgentBrowserStatus({ host: options.host, stateDir: options.stateDir }); if (!status.installed) throw missingManagedToolError(status); return await spawnManagedAgentBrowser(status, args, options); @@ -317,10 +328,11 @@ export function mapManagedAgentBrowserError(error: unknown): AppError { /** * Why the managed `agent-browser` backend's answer cannot be trusted. The backend runs and prints - * JSON; these rows are the shapes that JSON can have which prove the round trip went wrong, and - * the text-entry refusals the entry's own verdict gives. + * JSON; these rows include invalid answers, text-entry refusals, and launch policy refusals. */ export const AGENT_BROWSER_REFUSAL_REASONS = { + // A remote tenant's browser cannot run before its public-network proxy is enforced. + remoteNetworkUnenforced: { reason: 'remote_web_browser_unconfined' }, // The batch call for a text entry answered with something other than its one echoed entry. textEntryResultUnusable: { reason: 'text-entry-result-unusable' }, // The backend ran the fill or type entry and the page refused it. diff --git a/website/docs/docs/error-reasons.md b/website/docs/docs/error-reasons.md index 1909351a8b1..4bd8765a666 100644 --- a/website/docs/docs/error-reasons.md +++ b/website/docs/docs/error-reasons.md @@ -1062,6 +1062,7 @@ These reasons can come from more than one command. | Reason | Meaning | | --- | --- | +| `remote_web_browser_unconfined` | A remote tenant's browser cannot run before its public-network proxy is enforced. | | `text-entry-result-unusable` | The batch call for a text entry answered with something other than its one echoed entry. | | `text-entry-failed` | The backend ran the fill or type entry and the page refused it. | | `snapshot-refs-unmeasurable` | Every snapshot ref failed to measure, so the capture's refs belong to no live nodes. | From 0d4c8bc2c47922a97d895b1e0b9911750adc3870 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Mon, 30 Nov 2026 17:05:51 +0100 Subject: [PATCH 09/12] fix(web): refuse confined commands before provider cleanup --- .../src/agent-browser-provider.test.ts | 5 +++-- .../src/agent-browser-provider.ts | 7 ++++-- .../platform-web/src/agent-browser-tool.ts | 22 ++++++++++--------- src/commands/schema/cli-help.ts | 2 +- website/docs/docs/commands.md | 2 +- 5 files changed, 22 insertions(+), 16 deletions(-) diff --git a/packages/platform-web/src/agent-browser-provider.test.ts b/packages/platform-web/src/agent-browser-provider.test.ts index 62b0fa36777..dd394df9a56 100644 --- a/packages/platform-web/src/agent-browser-provider.test.ts +++ b/packages/platform-web/src/agent-browser-provider.test.ts @@ -56,9 +56,9 @@ test('agent-browser provider keys its browser on its backend key as given', asyn }); }); -test('a confined remote provider refuses browser commands before spawning the backend', async () => { +test('a confined remote provider refuses before browser cleanup or backend spawn', async () => { await withManagedAgentBrowserProvider( - { session: 't_remote-session', publicNetworkOnly: true }, + { session: 't_remote-session', publicNetworkOnly: true, openWebSessionNames: () => [] }, async (provider) => { const calls: AgentBrowserCall[] = []; await withCommandExecutorOverride(recordingExecutor(calls), async () => { @@ -69,6 +69,7 @@ test('a confined remote provider refuses browser commands before spawning the ba error.code === 'UNSUPPORTED_OPERATION' && error.details?.reason === 'remote_web_browser_unconfined', ); + assert.equal(mockProviderStartupCleanup.mock.calls.length, 0); await provider.close(); }); assert.deepEqual( diff --git a/packages/platform-web/src/agent-browser-provider.ts b/packages/platform-web/src/agent-browser-provider.ts index 2efce69e602..8b284f6a3ab 100644 --- a/packages/platform-web/src/agent-browser-provider.ts +++ b/packages/platform-web/src/agent-browser-provider.ts @@ -30,6 +30,7 @@ import { import type { WebProvider, WebSnapshotOptions, WebSnapshotResult } from './provider.ts'; import { AGENT_BROWSER_REFUSAL_REASONS, + assertManagedAgentBrowserNetworkPolicy, getManagedAgentBrowserStatus, mapManagedAgentBrowserError, runManagedAgentBrowser, @@ -73,8 +74,10 @@ type AgentBrowserRunOptions = { }; export function createAgentBrowserWebProvider(options: AgentBrowserProviderOptions): WebProvider { - const runJson = async (args: string[], run?: AgentBrowserRunOptions): Promise => - await runAgentBrowserJson(args, { session: options.session, options, ...run }); + const runJson = async (args: string[], run?: AgentBrowserRunOptions): Promise => { + assertManagedAgentBrowserNetworkPolicy(args, options.publicNetworkOnly); + return await runAgentBrowserJson(args, { session: options.session, options, ...run }); + }; return { async open(target) { diff --git a/packages/platform-web/src/agent-browser-tool.ts b/packages/platform-web/src/agent-browser-tool.ts index 9c7f520190e..59113431d30 100644 --- a/packages/platform-web/src/agent-browser-tool.ts +++ b/packages/platform-web/src/agent-browser-tool.ts @@ -61,21 +61,23 @@ export async function runManagedAgentBrowser( args: readonly string[], options: ManagedAgentBrowserRunOptions, ): Promise { - if (options.publicNetworkOnly && args[0] !== 'close') { - throw new AppError( - 'UNSUPPORTED_OPERATION', - 'Remote web browser network access is unavailable.', - { - reason: AGENT_BROWSER_REFUSAL_REASONS.remoteNetworkUnenforced.reason, - retriable: false, - }, - ); - } + assertManagedAgentBrowserNetworkPolicy(args, options.publicNetworkOnly); const status = getManagedAgentBrowserStatus({ host: options.host, stateDir: options.stateDir }); if (!status.installed) throw missingManagedToolError(status); return await spawnManagedAgentBrowser(status, args, options); } +export function assertManagedAgentBrowserNetworkPolicy( + args: readonly string[], + publicNetworkOnly: true | undefined, +): void { + if (!publicNetworkOnly || args[0] === 'close') return; + throw new AppError('UNSUPPORTED_OPERATION', 'Remote web browser network access is unavailable.', { + reason: AGENT_BROWSER_REFUSAL_REASONS.remoteNetworkUnenforced.reason, + retriable: false, + }); +} + export async function setupManagedAgentBrowser(options: { host: HostEnvironment; stateDir?: string; diff --git a/src/commands/schema/cli-help.ts b/src/commands/schema/cli-help.ts index 1bb3c10473a..ca481d9f8da 100644 --- a/src/commands/schema/cli-help.ts +++ b/src/commands/schema/cli-help.ts @@ -683,7 +683,7 @@ Rules: body: `agent-device help web Use --platform web only for the minimal browser command loop exposed through agent-device. -Managed web sessions run locally. A remote tenant request to a web device is refused with reason remote_web_public_network_unenforced because browser subrequests cannot be confined to public destinations; close remains available for cleanup. +Managed web sessions run locally. A remote tenant request to a web device is refused with reason remote_web_public_network_unenforced because browser subrequests cannot be confined to public destinations. The managed browser also refuses a confined request that bypasses daemon admission with reason remote_web_browser_unconfined; close remains available for cleanup. Dependency: Browser mechanics come from a managed, pinned agent-browser backend. agent-device owns command/session/replay integration, selectors/refs at the command surface, and artifact routing; agent-browser owns browser launch, page control, screenshots, and browser-specific behavior. diff --git a/website/docs/docs/commands.md b/website/docs/docs/commands.md index 32eb6e85af9..902a3968d30 100644 --- a/website/docs/docs/commands.md +++ b/website/docs/docs/commands.md @@ -551,7 +551,7 @@ agent-device close --platform web ``` - Run `web setup` before first use and in CI bootstrap. Web commands never install the backend themselves. `web doctor` verifies the install. -- Managed web sessions require a local daemon. A remote daemon refuses requests that bind a web device with `remote_web_public_network_unenforced`, including requests for an existing web session that omit `--platform web`. `close` remains available to release an existing session. +- Managed web sessions require a local daemon. A remote daemon refuses requests that bind a web device with `remote_web_public_network_unenforced`, including requests for an existing web session that omit `--platform web`. The managed browser also refuses a confined request that bypasses daemon admission with `remote_web_browser_unconfined`. `close` remains available to release an existing session. - Each web session has its own browser, cookies, and storage. Sessions with different `--session` names run at once. A session name is 1 to 30 letters, digits, `_`, or `-` (1 to 17 under tenant isolation); another name fails with `web_session_name_invalid`. Without `--session`, each workspace gets its own browser. - Supported: URL open, snapshot refs, `get text/attrs`, `is visible/hidden/exists/absent/focused/text`, `find text/selector`, click/press, hover, fill/type, wait, `network dump`, `audio probe`, screenshot, close, and replay scripts made from those commands. - A coordinate or selector `fill` clicks the point and replaces the field's text. When the click does not reach an editable text field, such as a date input or a field in a cross-origin frame, it fails with `text_entry_focus_not_observed` and types nothing. Run `snapshot -i` and fill the field by ref instead. From 5e27f8e6bfbfe1a84c1bb8dc70a3a52c17ea2f8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Mon, 30 Nov 2026 17:26:43 +0100 Subject: [PATCH 10/12] refactor(web): keep confinement admission before browser effects --- .../src/agent-browser-provider.ts | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/packages/platform-web/src/agent-browser-provider.ts b/packages/platform-web/src/agent-browser-provider.ts index 8b284f6a3ab..6edcae32a0d 100644 --- a/packages/platform-web/src/agent-browser-provider.ts +++ b/packages/platform-web/src/agent-browser-provider.ts @@ -74,10 +74,8 @@ type AgentBrowserRunOptions = { }; export function createAgentBrowserWebProvider(options: AgentBrowserProviderOptions): WebProvider { - const runJson = async (args: string[], run?: AgentBrowserRunOptions): Promise => { - assertManagedAgentBrowserNetworkPolicy(args, options.publicNetworkOnly); - return await runAgentBrowserJson(args, { session: options.session, options, ...run }); - }; + const runJson = async (args: string[], run?: AgentBrowserRunOptions): Promise => + await runAgentBrowserJson(args, { session: options.session, options, ...run }); return { async open(target) { @@ -571,15 +569,7 @@ async function runAgentBrowserJson( } /** Detail keys that hold what an executed backend command printed. */ -const BACKEND_OUTPUT_DETAIL_KEYS: ReadonlySet = new Set([ - 'stdout', - 'stderr', - 'agentBrowserError', -]); - -function hasBackendOutput(error: AppError): boolean { - return Object.keys(error.details ?? {}).some((key) => BACKEND_OUTPUT_DETAIL_KEYS.has(key)); -} +const BACKEND_OUTPUT_DETAIL_KEYS = new Set(['stdout', 'stderr', 'agentBrowserError']); function detailsWithoutBackendOutput(error: AppError): Record { return Object.fromEntries( @@ -603,7 +593,11 @@ function withoutBackendAnswer(error: unknown, label: string): unknown { * ran (the backend missing, a cancellation) carries no output and passes through unchanged. */ function withoutBackendOutput(error: unknown): unknown { - if (!(error instanceof AppError) || !hasBackendOutput(error)) return error; + if ( + !(error instanceof AppError) || + !Object.keys(error.details ?? {}).some((key) => BACKEND_OUTPUT_DETAIL_KEYS.has(key)) + ) + return error; return new AppError(error.code, error.message, detailsWithoutBackendOutput(error)); } @@ -613,6 +607,7 @@ async function runAgentBrowserCommand( interpret: (result: { stdout: string; stderr: string; exitCode: number }) => unknown, run: AgentBrowserRunOptions, ): Promise { + assertManagedAgentBrowserNetworkPolicy(cliArgs, options.publicNetworkOnly); let stdout = ''; let stderr = ''; let exitCode = 0; From 4bab07990df7026fd7042b2e0b258fc2c2b905d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Mon, 30 Nov 2026 17:31:40 +0100 Subject: [PATCH 11/12] docs(web): scope remote refusal to tenant ingress --- src/commands/schema/cli-help.ts | 2 +- website/docs/docs/commands.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/commands/schema/cli-help.ts b/src/commands/schema/cli-help.ts index ca481d9f8da..3fa4f463fa0 100644 --- a/src/commands/schema/cli-help.ts +++ b/src/commands/schema/cli-help.ts @@ -683,7 +683,7 @@ Rules: body: `agent-device help web Use --platform web only for the minimal browser command loop exposed through agent-device. -Managed web sessions run locally. A remote tenant request to a web device is refused with reason remote_web_public_network_unenforced because browser subrequests cannot be confined to public destinations. The managed browser also refuses a confined request that bypasses daemon admission with reason remote_web_browser_unconfined; close remains available for cleanup. +Managed web sessions run locally. A tenant request through the remote proxy or a daemon auth hook is refused with reason remote_web_public_network_unenforced because browser subrequests cannot be confined to public destinations. The managed browser also refuses a confined request that bypasses daemon admission with reason remote_web_browser_unconfined; close remains available for cleanup. Dependency: Browser mechanics come from a managed, pinned agent-browser backend. agent-device owns command/session/replay integration, selectors/refs at the command surface, and artifact routing; agent-browser owns browser launch, page control, screenshots, and browser-specific behavior. diff --git a/website/docs/docs/commands.md b/website/docs/docs/commands.md index 902a3968d30..aabb0b59e4b 100644 --- a/website/docs/docs/commands.md +++ b/website/docs/docs/commands.md @@ -551,7 +551,7 @@ agent-device close --platform web ``` - Run `web setup` before first use and in CI bootstrap. Web commands never install the backend themselves. `web doctor` verifies the install. -- Managed web sessions require a local daemon. A remote daemon refuses requests that bind a web device with `remote_web_public_network_unenforced`, including requests for an existing web session that omit `--platform web`. The managed browser also refuses a confined request that bypasses daemon admission with `remote_web_browser_unconfined`. `close` remains available to release an existing session. +- Managed web sessions are available to local requests. A tenant request through the remote proxy or a daemon auth hook is refused when it binds a web device with `remote_web_public_network_unenforced`, including requests for an existing web session that omit `--platform web`. The managed browser also refuses a confined request that bypasses daemon admission with `remote_web_browser_unconfined`. `close` remains available to release an existing session. - Each web session has its own browser, cookies, and storage. Sessions with different `--session` names run at once. A session name is 1 to 30 letters, digits, `_`, or `-` (1 to 17 under tenant isolation); another name fails with `web_session_name_invalid`. Without `--session`, each workspace gets its own browser. - Supported: URL open, snapshot refs, `get text/attrs`, `is visible/hidden/exists/absent/focused/text`, `find text/selector`, click/press, hover, fill/type, wait, `network dump`, `audio probe`, screenshot, close, and replay scripts made from those commands. - A coordinate or selector `fill` clicks the point and replaces the field's text. When the click does not reach an editable text field, such as a date input or a field in a cross-origin frame, it fails with `text_entry_focus_not_observed` and types nothing. Run `snapshot -i` and fill the field by ref instead. From 4a8a43b74df701bd4ce40da09cca1a3864d4762f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pierzcha=C5=82a?= Date: Mon, 30 Nov 2026 20:38:38 +0100 Subject: [PATCH 12/12] fix(web): prove confined default provider composition --- src/commands/schema/cli-help.ts | 2 +- src/platform-runtime-provider-scope.test.ts | 41 +++++++++++++++++++++ website/docs/docs/commands.md | 2 +- 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/src/commands/schema/cli-help.ts b/src/commands/schema/cli-help.ts index 3fa4f463fa0..b54118d046e 100644 --- a/src/commands/schema/cli-help.ts +++ b/src/commands/schema/cli-help.ts @@ -683,7 +683,7 @@ Rules: body: `agent-device help web Use --platform web only for the minimal browser command loop exposed through agent-device. -Managed web sessions run locally. A tenant request through the remote proxy or a daemon auth hook is refused with reason remote_web_public_network_unenforced because browser subrequests cannot be confined to public destinations. The managed browser also refuses a confined request that bypasses daemon admission with reason remote_web_browser_unconfined; close remains available for cleanup. +Managed web sessions run locally. A tenant request through the remote proxy or a daemon auth hook is refused with reason remote_web_public_network_unenforced because browser subrequests cannot be restricted to public destinations. A remote request that reaches the managed browser without passing daemon admission is refused with reason remote_web_browser_unconfined; close remains available for cleanup. Dependency: Browser mechanics come from a managed, pinned agent-browser backend. agent-device owns command/session/replay integration, selectors/refs at the command surface, and artifact routing; agent-browser owns browser launch, page control, screenshots, and browser-specific behavior. diff --git a/src/platform-runtime-provider-scope.test.ts b/src/platform-runtime-provider-scope.test.ts index fcb273c7356..70d7e5369e7 100644 --- a/src/platform-runtime-provider-scope.test.ts +++ b/src/platform-runtime-provider-scope.test.ts @@ -1,5 +1,8 @@ import assert from 'node:assert/strict'; import { test } from 'vitest'; +import { AppError } from '@agent-device/kernel/errors'; +import { webSessionDevice } from '@agent-device/kernel/device'; +import { withCommandExecutorOverride } from '@agent-device/host-kit/command'; import type { PlatformProviderRequestContext, RequestPlatformProviderScope, @@ -9,6 +12,8 @@ import { IOS_SIMULATOR, MACOS_DEVICE, WEB_DESKTOP_DEVICE, + bindTestCommandHost, + createTestHostEnvironment, } from '@agent-device/test-kit'; import { createLocalAppleToolProvider, runXcrun } from '@agent-device/platform-apple/tool-provider'; import { buildSimctlArgsForDevice } from '@agent-device/platform-apple/simctl'; @@ -23,6 +28,8 @@ import { type PlatformProviderResolvers, } from './platform-runtime.ts'; +bindTestCommandHost(); + const OTHER_IOS_SIMULATOR = { platform: 'apple', id: 'sim-2', @@ -176,6 +183,40 @@ test('web provider scope uses the context device', async () => { assert.deepEqual(calls, ['web-session:agent-browser-chrome', 'open:https://example.test']); }); +test('default web provider carries remote confinement through composition before browser work', async () => { + const browserCalls: string[] = []; + const providers = createRequestPlatformProviders({ + defaultWebProvider: { + host: createTestHostEnvironment(), + openWebSessionNames: () => [], + }, + }); + const device = webSessionDevice(WEB_DESKTOP_DEVICE, { name: 'remote-web' }); + await withCommandExecutorOverride( + async (cmd) => { + browserCalls.push(cmd); + throw new Error('confined browser must refuse before command execution'); + }, + async () => { + await assert.rejects( + providers.run( + { + ...context(device, 'remote-web'), + useDefaultWebProvider: true, + publicNetworkOnly: true, + }, + async () => await (await scopedWebProvider()).open('https://example.test'), + ), + (error: unknown) => + error instanceof AppError && + error.code === 'UNSUPPORTED_OPERATION' && + error.details?.reason === 'remote_web_browser_unconfined', + ); + }, + ); + assert.deepEqual(browserCalls, []); +}); + test('generic Apple runner provider cannot borrow local recording authority', async () => { await withRequestPlatformProviderScope( context(MACOS_DEVICE, 'macos-session'), diff --git a/website/docs/docs/commands.md b/website/docs/docs/commands.md index aabb0b59e4b..b23e33dff4c 100644 --- a/website/docs/docs/commands.md +++ b/website/docs/docs/commands.md @@ -551,7 +551,7 @@ agent-device close --platform web ``` - Run `web setup` before first use and in CI bootstrap. Web commands never install the backend themselves. `web doctor` verifies the install. -- Managed web sessions are available to local requests. A tenant request through the remote proxy or a daemon auth hook is refused when it binds a web device with `remote_web_public_network_unenforced`, including requests for an existing web session that omit `--platform web`. The managed browser also refuses a confined request that bypasses daemon admission with `remote_web_browser_unconfined`. `close` remains available to release an existing session. +- Managed web sessions are available to local requests. A tenant request through the remote proxy or a daemon auth hook is refused when it binds a web device with `remote_web_public_network_unenforced`, including requests for an existing web session that omit `--platform web`. A remote request that reaches the managed browser without passing daemon admission is refused with `remote_web_browser_unconfined` because browser subrequests cannot be restricted to public destinations. `close` remains available to release an existing session. - Each web session has its own browser, cookies, and storage. Sessions with different `--session` names run at once. A session name is 1 to 30 letters, digits, `_`, or `-` (1 to 17 under tenant isolation); another name fails with `web_session_name_invalid`. Without `--session`, each workspace gets its own browser. - Supported: URL open, snapshot refs, `get text/attrs`, `is visible/hidden/exists/absent/focused/text`, `find text/selector`, click/press, hover, fill/type, wait, `network dump`, `audio probe`, screenshot, close, and replay scripts made from those commands. - A coordinate or selector `fill` clicks the point and replaces the field's text. When the click does not reach an editable text field, such as a date input or a field in a cross-origin frame, it fails with `text_entry_focus_not_observed` and types nothing. Run `snapshot -i` and fill the field by ref instead.