Skip to content

Require auth for sandbox browser CDP relay [AI] - #81002

Merged
pgondhi987 merged 8 commits into
openclaw:mainfrom
pgondhi987:fix/fix-609
May 12, 2026
Merged

pgondhi987 merged 8 commits into
openclaw:mainfrom
pgondhi987:fix/fix-609

Conversation

@pgondhi987

Copy link
Copy Markdown
Contributor

Summary

  • Problem: The sandbox browser CDP relay depended on container-observed source filtering for access control.
  • Why it matters: The relay controls a high-privilege browser debugging surface and should require an application-layer credential.
  • What changed: Added a per-container relay token, routed bridge CDP access through authenticated URLs, removed default gateway-derived source-range injection, and replaced the unauthenticated TCP relay with an authenticated Python relay.
  • What did NOT change (scope boundary): noVNC behavior, browser bridge auth requirements, and explicit cdpSourceRange support as an additional filter remain in place.
  • AI-assisted: Yes.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Public issue: N/A
  • Related: maintainer-tracked private report
  • This PR addresses a bug or regression

Real behavior proof (required for external PRs)

  • Behavior or issue addressed: sandbox browser CDP relay now requires a generated relay credential before forwarding to Chromium.
  • Real environment tested: Not tested in a full Docker OpenClaw setup in this pass.
  • Exact steps or command run after this patch: bash -n scripts/sandbox-browser-entrypoint.sh; embedded relay Python block compiled with compile(..., "exec").
  • Evidence after patch: shell syntax check passed; embedded relay Python syntax check passed.
  • Observed result after patch: static syntax checks completed successfully.
  • What was not tested: full sandbox browser container rebuild/start and live CDP relay probing.
  • Before evidence: N/A.

Root Cause (if applicable)

  • Root cause: CDP relay access control relied on network source identity observed inside the container instead of a relay credential.
  • Missing detection / guardrail: there was no regression coverage asserting the sandbox CDP relay receives an auth token and that bridge CDP URLs carry that credential.
  • Contributing context (if known): Docker-published loopback ports can alter the source identity observed by services inside the container.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: src/agents/sandbox/browser.create.test.ts, extensions/browser/src/browser/cdp.helpers.test.ts.
  • Scenario the test should lock in: browser containers receive OPENCLAW_BROWSER_CDP_AUTH_TOKEN, the bridge uses an authenticated CDP URL, gateway-derived source ranges are not auto-injected, existing containers without relay auth are recreated, and URL credentials become request auth headers without being passed to fetch URLs.
  • Why this is the smallest reliable guardrail: it covers the create-time contract and CDP helper behavior without requiring Docker in unit tests.
  • Existing test that already covers this (if any): existing sandbox browser create-args tests covered port publication and explicit source ranges, but not relay authentication.
  • If no new test is added, why not: N/A.

User-visible / Behavior Changes

Sandbox browser containers without the relay auth environment are recreated. The default sandbox browser CDP relay now requires an internal credential. Explicit cdpSourceRange remains supported as an additional relay filter, but OpenClaw no longer injects a Docker-gateway-derived source range by default.

Diagram (if applicable)

Before:
OpenClaw bridge -> loopback published CDP relay -> Chromium
local process  -> loopback published CDP relay -> Chromium

After:
OpenClaw bridge -> authenticated CDP relay -> Chromium
local process  -> authenticated CDP relay -> rejected without credential

Security Impact (required)

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? Yes
  • New/changed network calls? Yes
  • Command/tool execution surface changed? No
  • Data access scope changed? No
  • If any Yes, explain risk + mitigation: the sandbox browser container now receives a generated relay token via environment and the bridge embeds that credential in its internal CDP URL. CDP fetch helpers convert URL credentials into an auth header while stripping credentials from the fetch URL. The relay rejects unauthenticated requests before forwarding to Chromium.

Repro + Verification

Environment

  • OS: Linux workspace
  • Runtime/container: local shell syntax checks only; Docker runtime not exercised
  • Model/provider: N/A
  • Integration/channel (if any): sandbox browser
  • Relevant config (redacted): default sandbox browser config shape from unit fixtures

Steps

  1. Inspect sandbox browser create path and relay entrypoint behavior.
  2. Add per-container relay auth and authenticated bridge CDP URL wiring.
  3. Add/update focused regression tests for relay auth env, CDP URL auth, source-range behavior, stale container recreation, and CDP helper credential handling.
  4. Run shell and embedded Python syntax checks.

Expected

  • Sandbox browser CDP relay requires a credential before forwarding to Chromium.
  • Bridge CDP requests include the generated credential.
  • Fetch-based CDP probes do not pass URL credentials to the fetch implementation.

Actual

  • Static checks passed for the shell entrypoint and embedded Python relay block.
  • Full Docker runtime verification was not run in this pass.

Evidence

  • Trace/log snippets
  • Failing test/log before + passing after
  • Screenshot/recording
  • Perf numbers (if relevant)
embedded python syntax ok
bash -n scripts/sandbox-browser-entrypoint.sh completed successfully

Human Verification (required)

  • Verified scenarios: shell entrypoint parses; embedded relay Python compiles; code inspection confirms bridge CDP URL includes relay credentials and stale containers without relay auth are recreated.
  • Edge cases checked: explicit cdpSourceRange remains passed through; network=none no longer gets an implicit source range; URL credentials are stripped before guarded fetch.
  • What you did not verify: rebuilt sandbox browser image, live Docker container startup, and real CDP HTTP/WebSocket relay behavior.

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.
  • I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

  • Backward compatible? Yes
  • Config/env changes? Yes
  • Migration needed? No
  • If yes, exact upgrade steps: standard sandbox browser containers are recreated automatically when relay auth is missing. Custom sandbox browser images need the updated entrypoint behavior to honor OPENCLAW_BROWSER_CDP_AUTH_TOKEN.

Risks and Mitigations

  • Risk: custom sandbox browser images that do not include the updated relay entrypoint may not support authenticated CDP relay startup.
    • Mitigation: the standard image path is updated, and containers missing relay auth are recreated so the standard entrypoint receives the new environment.
  • Risk: CDP URL credentials could be mishandled by fetch.
    • Mitigation: CDP helper coverage now verifies credentials are converted to an Authorization header and stripped from the guarded fetch URL.

@pgondhi987
pgondhi987 requested a review from a team as a code owner May 12, 2026 11:17
@openclaw-barnacle openclaw-barnacle Bot added scripts Repository scripts docker Docker and sandbox tooling agents Agent runtime and tooling size: M maintainer Maintainer-authored PR labels May 12, 2026
@clawsweeper

clawsweeper Bot commented May 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

Summary
The PR adds a generated sandbox browser CDP relay token, authenticated bridge CDP URLs, an authenticated Python relay, stale-image/container contract checks, credential redaction, and focused regression tests.

Reproducibility: no. high-confidence live reproduction yet. Source inspection on current main shows the relay relies on source-range filtering, but there is no before/after Docker proof showing unauthorized CDP access before the patch and rejection after it.

Real behavior proof
Needs real behavior proof before merge: Needs contributor action: the PR body provides only syntax/compile checks and says full Docker startup plus live CDP relay probing were not tested; add redacted terminal/log/screenshot/video proof and update the PR body for re-review.

Next step before merge
Protected maintainer label plus missing live proof for a security-sensitive Docker/CDP relay path makes this a maintainer review item, not a cleanup closure or automated repair lane.

Security
Cleared: Static security review found no concrete new supply-chain or code-execution regression in the diff, but the security behavior still needs live proof.

Review details

Best possible solution:

Land a relay-auth fix only after live Docker sandbox verification proves unauthenticated CDP HTTP/WS access is rejected and authenticated bridge CDP operations still work, while keeping explicit cdpSourceRange as a secondary filter and credentials out of status surfaces.

Do we have a high-confidence way to reproduce the issue?

No high-confidence live reproduction yet. Source inspection on current main shows the relay relies on source-range filtering, but there is no before/after Docker proof showing unauthorized CDP access before the patch and rejection after it.

Is this the best way to solve the issue?

Unclear as merge-ready. A per-container relay token is a plausible narrow fix, but the best path is to prove the HTTP and WebSocket CDP relay behavior in a real sandbox container before maintainer approval.

What I checked:

  • Checkout state: The review was performed on current main at c9ec1dea716f3248277c04aa739fe0a8be89c106, and the checkout remained clean after read-only inspection. (c9ec1dea716f)
  • Current main relay behavior: Current main starts a socat CDP relay and gates it with OPENCLAW_BROWSER_CDP_SOURCE_RANGE, so the PR is not obsolete and is changing the active sandbox browser relay path. (scripts/sandbox-browser-entrypoint.sh:175, c9ec1dea716f)
  • Current main source-range derivation: Current main auto-derives an effective CDP source range from the Docker network driver/gateway and fails when it cannot derive one, matching the source-filtering behavior the PR replaces with relay authentication. (src/agents/sandbox/browser.ts:261, c9ec1dea716f)
  • PR relay-auth implementation: The PR replaces the socat relay with a Python relay that checks Basic or Bearer auth before connecting to Chromium, while preserving explicit OPENCLAW_BROWSER_CDP_SOURCE_RANGE as an optional secondary filter. (scripts/sandbox-browser-entrypoint.sh:173, cc2eaf6d49ea)
  • PR bridge/token wiring: The PR generates OPENCLAW_BROWSER_CDP_AUTH_TOKEN, injects it into the container, builds authenticated CDP URLs for the bridge, recreates containers missing the token, and requires the updated browser image contract label. (src/agents/sandbox/browser.ts:53, cc2eaf6d49ea)
  • Real behavior proof gap: The supplied PR body says the author ran only bash -n plus embedded Python compilation and explicitly did not test full sandbox browser container rebuild/start or live CDP relay probing. (cc2eaf6d49ea)

Likely related people:

  • steipete: Current-main blame in the central files and recent commits show Peter Steinberger touching sandbox runtime cleanup, SSRF policy propagation, and the sandbox browser/CDP helper surfaces this PR changes. (role: recent area contributor; confidence: high; commits: 7625a8b6d650, 55a8f56a1546, 893c1d61ee0f; files: src/agents/sandbox/browser.ts, scripts/sandbox-browser-entrypoint.sh, extensions/browser/src/browser/cdp.helpers.ts)
  • dims: Commit fbf11ebdb7110632f93926d0ac7b48f04cb44d77 introduced the sandbox CDP source-range restriction and related tests that this PR replaces with application-layer relay auth. (role: introduced current source-range behavior; confidence: high; commits: fbf11ebdb711; files: src/agents/sandbox/browser.ts, scripts/sandbox-browser-entrypoint.sh, src/agents/sandbox/docker.ts)
  • Syysean: Commit c61be87b0e40de0ed178a6aff0ddb0700ef184e3 restored and hardened the sandbox browser CDP/noVNC lifecycle shape adjacent to the relay now being changed. (role: sandbox browser lifecycle contributor; confidence: medium; commits: c61be87b0e40; files: src/agents/sandbox/browser.ts, scripts/sandbox-browser-entrypoint.sh, src/agents/sandbox/browser.create.test.ts)

Remaining risk / open question:

  • The PR changes a security-sensitive Docker/CDP relay path without live proof that unauthenticated HTTP and WebSocket CDP requests are rejected while authenticated OpenClaw bridge operations still work.
  • The maintainer label means the PR should remain open for explicit maintainer handling even though the diff is focused.

Codex review notes: model gpt-5.5, reasoning high; reviewed against c9ec1dea716f.

@pgondhi987

Copy link
Copy Markdown
Contributor Author

Not applicable to this automation stage; changelog/release-note and external real behavior proof requirements are handled outside auto-pr stages.

Quoted comment from @clawsweeper:

Codex review: needs real behavior proof before merge.

Summary
The PR adds a generated sandbox browser CDP relay token, authenticated bridge CDP URLs, an authenticated Python relay, stale-image/container contract checks, credential redaction, and focused regression tests.

Reproducibility: no. high-confidence live reproduction yet. Source inspection on current main shows the relay relies on source-range filtering, but there is no before/after Docker proof showing unauthorized CDP access before the patch and rejection after it.

Real behavior proof
Needs real behavior proof before merge: Needs contributor action: the PR body provides only syntax/compile checks and says full Docker startup plus live CDP relay probing were not tested; add redacted terminal/log/screenshot/video proof and update the PR body for re-review.

Next step before merge
Protected maintainer label plus missing live proof for a security-sensitive Docker/CDP relay path makes this a maintainer review item, not a cleanup closure or automated repair lane.

Security
Cleared: Static security review found no concrete new supply-chain or code-execution regression in the diff, but the security behavior still needs live proof.

Review details

Best possible solution:

Land a relay-auth fix only after live Docker sandbox verification proves unauthenticated CDP HTTP/WS access is rejected and authenticated bridge CDP operations still work, while keeping explicit cdpSourceRange as a secondary filter and credentials out of status surfaces.

Do we have a high-confidence way to reproduce the issue?

No high-confidence live reproduction yet. Source inspection on current main shows the relay relies on source-range filtering, but there is no before/after Docker proof showing unauthorized CDP access before the patch and rejection after it.

Is this the best way to solve the issue?

Unclear as merge-ready. A per-container relay token is a plausible narrow fix, but the best path is to prove the HTTP and WebSocket CDP relay behavior in a real sandbox container before maintainer approval.

What I checked:

  • Checkout state: The review was performed on current main at c9ec1dea716f3248277c04aa739fe0a8be89c106, and the checkout remained clean after read-only inspection. (c9ec1dea716f)
  • Current main relay behavior: Current main starts a socat CDP relay and gates it with OPENCLAW_BROWSER_CDP_SOURCE_RANGE, so the PR is not obsolete and is changing the active sandbox browser relay path. (scripts/sandbox-browser-entrypoint.sh:175, c9ec1dea716f)
  • Current main source-range derivation: Current main auto-derives an effective CDP source range from the Docker network driver/gateway and fails when it cannot derive one, matching the source-filtering behavior the PR replaces with relay authentication. (src/agents/sandbox/browser.ts:261, c9ec1dea716f)
  • PR relay-auth implementation: The PR replaces the socat relay with a Python relay that checks Basic or Bearer auth before connecting to Chromium, while preserving explicit OPENCLAW_BROWSER_CDP_SOURCE_RANGE as an optional secondary filter. (scripts/sandbox-browser-entrypoint.sh:173, cc2eaf6d49ea)
  • PR bridge/token wiring: The PR generates OPENCLAW_BROWSER_CDP_AUTH_TOKEN, injects it into the container, builds authenticated CDP URLs for the bridge, recreates containers missing the token, and requires the updated browser image contract label. (src/agents/sandbox/browser.ts:53, cc2eaf6d49ea)
  • Real behavior proof gap: The supplied PR body says the author ran only bash -n plus embedded Python compilation and explicitly did not test full sandbox browser container rebuild/start or live CDP relay probing. (cc2eaf6d49ea)

Likely related people:

  • steipete: Current-main blame in the central files and recent commits show Peter Steinberger touching sandbox runtime cleanup, SSRF policy propagation, and the sandbox browser/CDP helper surfaces this PR changes. (role: recent area contributor; confidence: high; commits: 7625a8b6d650, 55a8f56a1546, 893c1d61ee0f; files: src/agents/sandbox/browser.ts, scripts/sandbox-browser-entrypoint.sh, extensions/browser/src/browser/cdp.helpers.ts)
  • dims: Commit fbf11ebdb7110632f93926d0ac7b48f04cb44d77 introduced the sandbox CDP source-range restriction and related tests that this PR replaces with application-layer relay auth. (role: introduced current source-range behavior; confidence: high; commits: fbf11ebdb711; files: src/agents/sandbox/browser.ts, scripts/sandbox-browser-entrypoint.sh, src/agents/sandbox/docker.ts)
  • Syysean: Commit c61be87b0e40de0ed178a6aff0ddb0700ef184e3 restored and hardened the sandbox browser CDP/noVNC lifecycle shape adjacent to the relay now being changed. (role: sandbox browser lifecycle contributor; confidence: medium; commits: c61be87b0e40; files: src/agents/sandbox/browser.ts, scripts/sandbox-browser-entrypoint.sh, src/agents/sandbox/browser.create.test.ts)

Remaining risk / open question:

  • The PR changes a security-sensitive Docker/CDP relay path without live proof that unauthenticated HTTP and WebSocket CDP requests are rejected while authenticated OpenClaw bridge operations still work.
  • The maintainer label means the PR should remain open for explicit maintainer handling even though the diff is focused.

Codex review notes: model gpt-5.5, reasoning high; reviewed against c9ec1dea716f.

@pgondhi987
pgondhi987 merged commit b6a94d4 into openclaw:main May 12, 2026
21 of 22 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
* fix: require auth for sandbox browser cdp relay

* addressing review-skill

* addressing review-skill

* addressing review-skill

* addressing codex review

* addressing claude review

* docs: add changelog entry for PR merge
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
* fix: require auth for sandbox browser cdp relay

* addressing review-skill

* addressing review-skill

* addressing review-skill

* addressing codex review

* addressing claude review

* docs: add changelog entry for PR merge
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
* fix: require auth for sandbox browser cdp relay

* addressing review-skill

* addressing review-skill

* addressing review-skill

* addressing codex review

* addressing claude review

* docs: add changelog entry for PR merge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docker Docker and sandbox tooling maintainer Maintainer-authored PR scripts Repository scripts size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant