#11054: fix(security): Add auth token to sandbox browser bridge (#11023)
agents
stale
Cluster:
Sandbox Path Management Fixes
## Summary
Fixes a critical security vulnerability (CVSS 9.2) where the sandbox browser bridge starts without authentication, allowing any local process to take over another session's browser state.
## Problem
The sandbox browser bridge supports bearer-token protection via `authToken`, but [ensureSandboxBrowser()](cci:1://file:///c:/Users/BS01431/Desktop/openclaw/src/agents/sandbox/browser.ts:87:0-237:1) was calling [startBrowserBridgeServer()](cci:1://file:///c:/Users/BS01431/Desktop/openclaw/src/browser/bridge-server.ts:19:0-69:1) without passing a token. This created an unauthenticated browser control API accessible to any local process.
## Solution
- Generate a 256-bit cryptographically secure token using `randomBytes(32).toString("hex")`
- Pass the token to [startBrowserBridgeServer()](cci:1://file:///c:/Users/BS01431/Desktop/openclaw/src/browser/bridge-server.ts:19:0-69:1) which enables the auth middleware
- Return the token in [SandboxBrowserContext](cci:2://file:///c:/Users/BS01431/Desktop/openclaw/src/agents/sandbox/types.ts:61:0-66:2) so authorized clients can authenticate
## Changes
| File | Change |
|------|--------|
| [src/agents/sandbox/browser.ts](cci:7://file:///c:/Users/BS01431/Desktop/openclaw/src/agents/sandbox/browser.ts:0:0-0:0) | Generate and pass `authToken` to bridge server |
| [src/agents/sandbox/types.ts](cci:7://file:///c:/Users/BS01431/Desktop/openclaw/src/agents/sandbox/types.ts:0:0-0:0) | Add `authToken` field to [SandboxBrowserContext](cci:2://file:///c:/Users/BS01431/Desktop/openclaw/src/agents/sandbox/types.ts:61:0-66:2) |
## Testing
- All 5,932 unit tests pass
- No regressions introduced
## References
- Fixes #11023
- CWE-862: Missing Authorization
- CWE-269: Improper Privilege Management
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
- Adds a per-session cryptographic `authToken` for the sandbox browser bridge and passes it into `startBrowserBridgeServer()` to enable bearer-token protection.
- Extends `SandboxBrowserContext` to include `authToken` and returns it from `ensureSandboxBrowser()`.
- This tightens local-session isolation by requiring Authorization headers for bridge routes when a token is configured.
- No other code paths were updated to propagate/use this new required field (see comments).
<h3>Confidence Score: 3/5</h3>
- This PR improves bridge security, but likely breaks consumers because the new required auth token is not propagated to all bridge clients.
- Core change (token generation + server auth) looks correct, but there are concrete, reachable call sites and tests that still assume unauthenticated access or omit the new required field; those will fail typechecking or cause 401s at runtime until the token is threaded through.
- src/agents/pi-tools.ts, src/agents/pi-embedded-runner/sandbox-info.ts, src/agents/pi-embedded-runner.buildembeddedsandboxinfo.test.ts, plus any browser bridge client code that issues HTTP requests.
<!-- greptile_other_comments_section -->
<sub>(4/5) You can add custom instructions or style guidelines for the agent [here](https://app.greptile.com/review/github)!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#8296: fix(browser): bind sandbox browser bridge to 0.0.0.0 for container ...
by gavinbmoore · 2026-02-03
79.4%
#14197: fix(security): harden browser API auth, token comparisons, and hook...
by leecarollyn-gif · 2026-02-11
78.9%
#23805: Sandbox: default browser network to none and fail bridge without so...
by bmendonca3 · 2026-02-22
77.8%
#19885: test(gateway,browser): isolate tests from ambient OPENCLAW_GATEWAY_...
by NewdlDewdl · 2026-02-18
77.2%
#19937: fix(gateway): validate token/password auth modes and isolate gatewa...
by NewdlDewdl · 2026-02-18
76.4%
#18273: fix: extract token from URL query string for Control UI websocket auth
by MisterGuy420 · 2026-02-16
76.0%
#21119: Security/Browser: fail closed when control server has no auth
by bmendonca3 · 2026-02-19
75.8%
#7851: feat: secure sandbox defaults for new installs
by ichbinlucaskim · 2026-02-03
75.5%
#8517: Browser: sandbox download/trace paths
by coygeek · 2026-02-04
75.4%
#16929: fix(security): block access to sensitive directories from within sa...
by CornBrother0x · 2026-02-15
74.9%