Repository navigation
docs(security): design remote web network confinement #5306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2c7c5b6
docs(security): design remote web network confinement
thymikee a268896
docs(security): phase remote web confinement
thymikee 0d0e692
docs(security): correct Chromium proxy bypass
thymikee 8a80342
docs(security): require isolated confined browser sessions
thymikee 4932675
docs(security): bind remote web confinement to session state
thymikee 239ebc7
docs(security): cover DNS64 in remote web confinement design
thymikee 464e999
docs(security): close remote web confinement design gaps
thymikee 2f69dcc
docs(security): state remote web confinement prerequisites
thymikee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
236 changes: 236 additions & 0 deletions
236
docs/experiments/remote-web-public-network-confinement.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,236 @@ | ||
| # Remote web public-network confinement | ||
|
|
||
| ## Status | ||
|
|
||
| Design proposal. [#5243](https://github.com/callstack/agent-device/pull/5243) introduces | ||
| `remote_web_public_network_unenforced` for remote tenant web commands. | ||
| The refusal is absent from the `main` revision that this proposal targets. | ||
| Land #5243 before landing the confinement implementation. Keep its refusal until the final phase. | ||
|
|
||
| ## Security invariant | ||
|
|
||
| A browser that belongs to a request with `internal.publicNetworkOnly` must not create an external | ||
| network connection to an address that is not globally reachable. The authenticated, daemon-owned | ||
| proxy hop is the sole local exception. This rule applies to every browser-created connection for | ||
| the session, not only 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. Authenticate the browser to a per-session proxy | ||
| endpoint or use an equivalent OS-protected socket. Apply global and per-session connection limits. | ||
| Proxy loss revokes the confinement lease and terminates the browser before any replacement proxy | ||
| can accept its connections. Another local user can discover and replace an unprotected 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 absolute-form `http` and `ws` requests. A `CONNECT` tunnel is opaque after admission: | ||
| enforce its destination address at the proxy and restrict browser transports at launch. Treat any | ||
| external transport that can bypass the proxy as denied until its enforcement path is proven. | ||
| 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. Deny `2001::/23` by default. Admit a more-specific assignment only when | ||
| the current [IANA IPv6 Special-Purpose Address Registry](https://www.iana.org/assignments/iana-ipv6-special-registry) | ||
| marks it globally reachable and no other exclusion applies. 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. 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. | ||
| 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 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 | ||
| WebTransport, direct sockets exposed by an extension, and a browser feature added after the pinned | ||
| backend version. | ||
|
|
||
| ## Backend launch and session isolation | ||
|
|
||
| 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`. | ||
| - 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`. | ||
|
|
||
| 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 | ||
|
|
||
| | 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 | | ||
| | 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 | | ||
| | `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 | ||
|
|
||
| | 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 | | ||
| | 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 | ||
|
|
||
| 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 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. Recent socket activity must not suppress confined-browser | ||
| recovery. 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. | ||
|
|
||
| Startup recovery alone leaves an interval between daemon exit and browser cleanup. The browser | ||
| can still connect to a loopback address in that interval. Before enabling remote web, prove that | ||
| the browser can only use its authenticated proxy endpoint, or that host enforcement blocks | ||
| connections from the browser as soon as the proxy is lost. | ||
|
|
||
| `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 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 | ||
| fail-closed when the evidence lane is absent or fails. | ||
|
|
||
| ## Phased implementation | ||
|
|
||
| After #5243 lands, each phase can merge while `assertRemoteWebDeviceAdmitted` refuses remote web. | ||
| Keep that refusal and the independent launch guard until the final phase. | ||
|
|
||
| 1. Use the `publicNetworkOnly` provider context from #5265, carried by #5243. Preserve the trusted | ||
| marker through default web provider construction. Prove that nested batch and replay requests | ||
| cannot clear the marker. | ||
| 2. Add a private `@agent-device/platform-web` public-destination classifier. Cover every IPv4 and | ||
| IPv6 range, IPv4-mapped IPv6, DNS64/NAT64 synthesis, mixed DNS answers, and current host-interface | ||
| addresses. Pin `2001::/23` exceptions to IANA registry entries in tests. 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 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 | ||
| 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 positive controls, a local listener replacement | ||
| attempt after proxy death, and fail-closed behavior on macOS, Linux, and Windows. | ||
| 6. Replace the routing refusal in `assertRemoteWebDeviceAdmitted` with confinement lease admission. | ||
| At launch, keep `remote_web_browser_unconfined` unless the backend can prove it has the matching | ||
| proxy. Keep `close` available when either check fails. Update help and security docs in the same | ||
| change. | ||
|
|
||
| The launch phases require the managed `agent-browser` 0.42.0 pin from #5273. An optional upstream | ||
| `--public-network-proxy <url>` mode could reject profiles, providers, restore/state, extensions, | ||
| startup URLs in raw arguments, proxy bypasses, QUIC, and unsafe WebRTC settings as one atomic | ||
| launch policy. Until that mode exists, 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. | ||
| - 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. | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.