← Back to PRs

#11054: fix(security): Add auth token to sandbox browser bridge (#11023)

by shadril238 open 2026-02-07 10:17 View on GitHub →
agents stale
## 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