browse can keep untrusted pages off local and private network addresses (#4812) (#4888)

Adds an opt-in `browse --public-only` mode (or `BROWSE_PUBLIC_ONLY=1`):
every connection the browser makes goes through a guard that refuses
loopback, private, link-local, cloud-metadata and this machine's own
network addresses.

Why: an agent reading an untrusted page should not let that page reach
services on your machine or network (#4812). Default mode is unchanged.

Nothing to do unless you want the mode; see BROWSER.md "Public-only
mode".

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Review-Finding: p1b/red-team#1 reader=red-team
Review-Finding: p1b/red-team#2 reader=red-team
Review-Finding: p1v/outside-voice#1 reader=outside-voice
Review-Finding: p1v/outside-voice#2 reader=outside-voice
Review-Finding: p1v/outside-voice#3 reader=outside-voice
Review-Finding: p1v/outside-voice#4 reader=outside-voice
Review-Finding: p1v/adversarial-native#1 reader=adversarial-native
Review-Finding: p1v/adversarial-native#2 reader=adversarial-native
Review-Finding: p1v/adversarial-native#3 reader=adversarial-native
Review-Finding: p1v/adversarial-native#5 reader=adversarial-native
Review-Finding: p2/specialist-batched#1 reader=specialist-batched
Review-Finding: p2/red-team#1 reader=red-team
This commit is contained in:
Garry Tanandcapy-ai[bot] authored and GitHub committed 2026-11-28 23:48:49 +00:00
1 parent 4a40464ea7
commit fb4474ec6c
46 files changed
+1396 -78

No files matched your search

+1 -1
View File
@@ -184,7 +184,7 @@ Each agent owns the tabs it creates. Rules:
- Tokens can be revoked instantly: `$B tunnel revoke agent-name` deletes the session plus any pending setup keys and verifies against the live agent list. `$B tunnel agents` shows who's paired (pending setup keys included). `$B stop` clears everything — tokens never survive the daemon.
- **SSE auth** uses a 30-minute HttpOnly SameSite=Strict cookie, stream-scope only (never valid against `/command`).
- **Path traversal guarded** on `/welcome` — `GSTACK_SLUG` must match `^[a-z0-9_-]+$` or falls back to the built-in template.
- **SSRF guards** on `goto`, `download`, and scrape paths — validates URL target against a localhost/private-range blocklist.
- **SSRF guards** on `goto`, `download`, and scrape paths — refuse cloud metadata and link-local addresses (`169.254.0.0/16`, `fe80::/10`, `fc00::/7` and the metadata host names). Localhost and private ranges stay reachable for local dev servers unless the daemon runs in [public-only mode](../BROWSER.md#public-only-mode), which refuses them for every connection the browser makes.
- **Tunnel surface denial logging.** Every rejection on the tunnel listener (`path_not_on_tunnel`, `root_token_on_tunnel`, `missing_scoped_token`, `disallowed_command:*`) is appended to `~/.gstack/security/attempts.jsonl` with timestamp, source IP, path, method. Rate-capped at 60 writes/min.
- **Egress receipt on tunnel start (v1.63+).** Every tunnel session open writes a hash-chained receipt (sink `browse-tunnel`) to `~/.gstack/security/egress.jsonl` BEFORE ngrok forwards anything. Fail-closed: if the receipt can't be written, the tunnel refuses to start. Audit with `bin/gstack-egress list` / `bin/gstack-egress verify`.
- All agent activity is logged with attribution (clientId).