6 Commits
Author SHA1 Message Date
sausheong 60e6077408 fix(browser,stagehand): contain Chrome egress with an SSRF-validating proxy
Chrome's --host-resolver-rules only glob-matches host strings, so the CIDR
entries (127.0.0.0/8, 10.0.0.0/8, 172.16.0.0/12, 169.254.0.0/16,
192.168.0.0/16) never matched: pages could fetch private IP literals and
names resolving to private IPs, and the live SSRF test hung dialing
169.254.169.254 until its deadline.

Replace the rules with web.EgressProxy, a loopback HTTP proxy (CONNECT and
absolute-URI HTTP) that resolves each destination, refuses it if any
address is private, and dials the validated IP directly. Chrome is pointed
at it with --proxy-server and <-loopback>, and WebRTC is limited to proxied
UDP. Stagehand's local mode allows only Chrome's own debugging port through,
which its extension needs.

SafeHTTPClient and the proxy now share one safe dialer, which races the
validated addresses happy-eyeballs style so dual-stack hosts with broken
IPv6 don't stall. isPrivateIP also covers multicast, reserved, benchmark,
Teredo and NAT64/6to4/IPv4-compatible addresses embedding a private IPv4.
2026-10-03 23:15:50 +08:00
sausheong eb4fa67976 fix: harden runtime against panics/races, close path-traversal and fail-open gaps
- Runtime.Run rejects concurrent invocations instead of racing on shared state; panics in tools, hooks, and permission checkers are recovered and surfaced as errors/denials instead of crashing the loop
- AgentSpec.Loop now actually overrides RuntimeDeps.AgentLoop per-agent, as documented
- session.Store validates agent ID / session key as single path components, preventing traversal outside the session directory
- ValidatePathInWorkDir resolves symlinks on the target itself, not just its parent, closing a workspace-escape gap
- bash tool now fails closed on an unrecognized ExecPolicy.Level instead of allowing everything
- browser tool rejects unknown actions instead of silently no-op'ing

Bump README to v0.3.4 and document the AgentSpec.Loop override semantics.
2026-08-02 10:14:20 +08:00
sausheong d6db565d7c fix(web): dial all validated IPs for dual-stack fallback (I1); fix live SSRF test to await fetch (M1) 2026-06-13 11:56:30 +08:00
sausheong 01b55a1446 fix(browser): block private-IP resolution via host-resolver-rules (S3) 2026-06-13 11:25:22 +08:00
sausheong 0ca0fed9f7 fix(browser): reap orphaned Chromes when parent dies hard
chromedp launches Chrome as detached subprocesses; on SIGKILL, OOM, or
any path that bypasses our cleanup chain they reparent to PID 1 and
survive indefinitely. Each launch now allocates a known harness-browser-*
user-data-dir and registers it with a single detached /bin/sh watchdog
spawned via Setsid. When the parent dies the watchdog detects stdin EOF
and pkills + rm -rfs every still-tracked path. Clean teardown untracks
the path so a later hard exit can't kill the next session sharing the
process.
2026-05-08 22:08:58 +08:00
sausheong 1f2c471ff9 Initial commit: Go agentic harness extracted from Felix 2026-05-07 11:31:42 +08:00