Skip to content

fix(browser): do not sticky-adopt policy-blocked openTab targets - #105301

Merged
steipete merged 3 commits into
openclaw:mainfrom
hugenshen:fix/browser-open-tab-sticky-blocked-target
Jul 16, 2026
Merged

steipete merged 3 commits into
openclaw:mainfrom
hugenshen:fix/browser-open-tab-sticky-blocked-target

Conversation

@hugenshen

@hugenshen hugenshen commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

openTab could mutate sticky-target, alias, or managed-tab-cleanup state before the browser's final result was safe and authoritative. A blocked redirect, late cancellation, failed discovery, or provisional CDP descriptor could therefore reject the open while still changing which tab a later targetless action selected.

Why This Change Was Made

All browser backends now converge on one final adoption boundary. Chrome MCP and Playwright results are adopted only after their final URL passes policy. Direct CDP attaches to the exact created target and reads browser-owned Page.getFrameTree state; raw /json/new observes the returned page WebSocket. Direct discovery is pure until the target is rediscovered and both authoritative URL views pass policy.

The refactor also moves stable alias ownership into target-id.ts, validates labels before browser mutation and again inside the exported alias-state owner, propagates endpoint-policy and cancellation errors, and keeps uncertain targets explicit but unadopted. The mixed helper and the synthetic committed live test were deleted.

User Impact

Before: A rejected, aborted, blocked, or undiscovered tab open could replace the previous implicit target, inherit an alias, or trigger managed cleanup.

After: Sticky target, alias, and cleanup state change together only after final navigation and target discovery are validated. Unsettled or undiscovered targets can still be returned explicitly, but cannot silently become the next implicit tab.

Evidence

  • Exact repaired head: e0154b92fe2f6bc567d56346a309a9b159ff5993.
  • Blacksmith Testbox: run 29483339867.
  • Focused target-id and tab-selection regressions: 2 files, 32/32 passed.
  • Full Browser plugin suite: 138 files, 1,822 passed, 1 skipped.
  • pnpm check:changed: passed in 2m09s, including format, prod/test tsgo, lint, SDK/dependency/database/runtime-sidecar/import-cycle guards.
  • Fresh final autoreview: no findings, confidence 0.83. A prior valid stale-final-URL finding was fixed and the complete proof rerun.
  • Independent whole-module/caller/sibling/CDP-contract audit: accepted after alias-owner validation was hardened.

Real Chrome proof

Chrome 144.0.7559.96 exercised the production CDP/navigation path:

  • server redirect to loopback: final loopback URL observed and rejected;
  • immediate client redirect to loopback: final loopback URL observed and rejected;
  • four-second slow subresource: safe main document adopted in 293ms without waiting for the subresource;
  • production openTab: rejection preserved the prior sticky target, aliases, targetless selection, and managed-tab set.
{"proof":"real-chrome-cdp-frame-tree-navigation","serverRedirectFinal":"http://127.0.0.1:35715/blocked","clientRedirectFinal":"http://127.0.0.1:35715/blocked","slowMainDocumentFinal":"http://192.168.127.119:35715/slow","slowSubresourceDelayMs":4000,"slowObservationElapsedMs":293}
{"proof":"production-openTab-rejects-blocked-frame-final","finalHost":"127.0.0.1","stickyPreserved":true,"aliasesPreservedUntilExplicitList":true,"targetlessSelectionPreserved":true}

The temporary real-Chrome harness was removed after proof; committed tests remain deterministic. The CDP ownership assumptions were checked against the official Page.getFrameTree and Frame contracts: the main frame exposes the current loader, document URL, separate fragment, and failed-navigation URL.

Known boundary

A client-side navigation scheduled after the short committed-document stability window is inherently best-effort; later browser actions retain their current-URL safety checks. This change deliberately does not close rejected targets because target disposal is a separate product decision.

  • AI-assisted (Cursor and Codex)
  • I understand what the code does
  • Change is focused and does not mix unrelated concerns

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. labels Jul 12, 2026
@clawsweeper

clawsweeper Bot commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 14, 2026, 2:44 PM ET / 18:44 UTC.

Summary
Moves Chrome MCP and CDP sticky-target adoption after final navigation-policy validation and adds focused unit plus live Chrome/CDP regression coverage.

PR surface: Source +12, Tests +332. Total +344 across 5 files.

Reproducibility: yes. from source with high confidence: current ordering mutates lastTargetId before final-URL policy validation on the affected creation paths, and the focused regressions exercise that sequence; the submitted live run provides convincing after-fix confirmation rather than a recorded current-main failure.

Review metrics: none identified.

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Risk before merge

  • [P1] The PR head is behind current main, so the exact three-way merge result should be refreshed and briefly rechecked across all browser tab-creation paths before landing.

Maintainer options:

  1. Decide the mitigation before merge
    Refresh the branch onto current main and land the adopt-after-validation ordering with the focused Chrome MCP, CDP, and live redirect regressions intact.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • No automated repair is needed; routine maintainer branch refresh, final merged-path review, and landing are the remaining actions.

Security
Cleared: The patch strengthens the browser SSRF boundary by delaying sticky state mutation until validation succeeds and introduces no dependency, permission, secret, publishing, or supply-chain change.

Review details

Best possible solution:

Refresh the branch onto current main and land the adopt-after-validation ordering with the focused Chrome MCP, CDP, and live redirect regressions intact.

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

Yes from source with high confidence: current ordering mutates lastTargetId before final-URL policy validation on the affected creation paths, and the focused regressions exercise that sequence; the submitted live run provides convincing after-fix confirmation rather than a recorded current-main failure.

Is this the best way to solve the issue?

Yes. Deferring the existing state mutation until the existing final-URL policy check succeeds is the narrowest maintainable fix and aligns the Chrome MCP/CDP paths with the established raw /json/new invariant without adding new policy or configuration.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against af3d796e199f.

Label changes

Label justifications:

  • P1: The existing ordering can let a policy-rejected browser target influence the next targetless browser action, affecting a real security-sensitive workflow.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR contains after-fix live Chrome/CDP output exercising the production redirect, final-URL rejection, sticky-state, and subsequent targetless-selection path, with focused unit coverage supplementing it.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR contains after-fix live Chrome/CDP output exercising the production redirect, final-URL rejection, sticky-state, and subsequent targetless-selection path, with focused unit coverage supplementing it.
Evidence reviewed

PR surface:

Source +12, Tests +332. Total +344 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 2 42 30 +12
Tests 3 332 0 +332
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 374 30 +344

What I checked:

Likely related people:

  • Leon-SK668: Authored the recently merged raw /json/new target-validation change that established the sibling adopt-only-after-validation invariant in the same tab-operations module. (role: adjacent behavior contributor; confidence: high; commits: 7027d2c22728; files: extensions/browser/src/browser/server-context.tab-ops.ts)
  • vincentkoc: Recent repository history shows repeated browser and CDP helper refactors, making this person a useful reviewer for cross-path browser-runtime consistency. (role: recent area contributor; confidence: medium; files: extensions/browser/src/browser/server-context.tab-ops.ts, extensions/browser/src/browser/cdp.ts)
  • steipete: Recent history includes browser route and network-policy maintenance, both directly adjacent to the SSRF validation and target-selection boundary changed here. (role: recent adjacent contributor; confidence: medium; files: extensions/browser/src/browser/server-context.tab-ops.ts, extensions/browser/src/browser/server-context.types.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (5 earlier review cycles)
  • reviewed 2026-07-12T11:01:12.356Z sha 4d5ce668e56aac9ebfe37d2cacdad3f8fc4da79d :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-12T14:16:54.133Z sha b8085d158f4e2991658527196737646b1b231b04 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-13T15:24:04.151Z sha 4f00b59a37f7d27d5c1f988c51d026a9124243e6 :: needs changes before merge. :: [P1] Preserve the previous sticky target when discovery times out
  • reviewed 2026-07-14T00:56:32.105Z sha 004f04a3a8a4508f96e63ee9d21a7976dd7bbfec :: needs maintainer review before merge. :: none
  • reviewed 2026-07-14T01:04:36.670Z sha 004f04a3a8a4508f96e63ee9d21a7976dd7bbfec :: needs maintainer review before merge. :: none

@hugenshen
hugenshen force-pushed the fix/browser-open-tab-sticky-blocked-target branch from 4d5ce66 to f1dc66f Compare July 12, 2026 13:47
@hugenshen

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@hugenshen
hugenshen force-pushed the fix/browser-open-tab-sticky-blocked-target branch from f1dc66f to b8085d1 Compare July 12, 2026 14:07
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jul 12, 2026
@hugenshen
hugenshen force-pushed the fix/browser-open-tab-sticky-blocked-target branch from b8085d1 to 4f00b59 Compare July 13, 2026 14:28
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jul 13, 2026
@hugenshen
hugenshen force-pushed the fix/browser-open-tab-sticky-blocked-target branch 2 times, most recently from 8a6388e to 004f04a Compare July 14, 2026 00:52
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jul 14, 2026
@hugenshen
hugenshen force-pushed the fix/browser-open-tab-sticky-blocked-target branch 2 times, most recently from 92b0ca2 to d2b43d8 Compare July 14, 2026 14:04
@hugenshen
hugenshen force-pushed the fix/browser-open-tab-sticky-blocked-target branch from d2b43d8 to 795c2cf Compare July 14, 2026 14:49
@steipete steipete self-assigned this Jul 16, 2026
@steipete

Copy link
Copy Markdown
Contributor

Land-ready maintainer proof for repaired head e0154b92fe2f6bc567d56346a309a9b159ff5993.

What changed:

  • One final adoption boundary now owns sticky-target, alias, and managed-cleanup mutation for Chrome MCP, Playwright, direct CDP, and raw /json/new.
  • Direct CDP observes browser-owned Page.getFrameTree state and rediscovery remains state-free until both URL views pass policy.
  • Invalid labels fail before browser mutation and again at the exported alias-state owner. Cancellation and discovered-endpoint policy failures propagate.
  • Unsettled or undiscovered targets remain explicit but unadopted. The mixed helper and synthetic committed live harness were removed.

Proof:

  • Blacksmith Testbox 29483339867: focused target-id/tab-selection 32/32; full Browser suite 138 files, 1,822 passed, 1 skipped; pnpm check:changed green.
  • Real Chrome 144.0.7559.96: server and immediate-client redirects reached blocked loopback finals; a four-second slow subresource retained a safe 293ms adoption; production openTab rejection preserved sticky state, aliases, targetless selection, and managed-tab set.
  • Final autoreview: no findings, confidence 0.83, after repairing its valid stale-final-URL finding. Independent whole-module/caller/sibling/CDP-contract audit also accepted after alias-owner hardening.
  • Official dependency contract checked: Page.getFrameTree and Frame provide the main-frame loader, document URL, separate fragment, and failed-navigation URL used here.
  • The contributor pushed 0330dd7 during review; it only narrowed wording in the now-deleted synthetic live test. The final transplant preserves that commit and is byte-identical to the fully tested immutable repair tree.
  • Current main 8090cb1c64e merges cleanly with this head.

Hosted-CI diagnosis:

  • Exact-head run 29488744751 has all completed Browser-relevant lanes green. Its check-test-types failure is unrelated: frozen base df722165805 contained a newly split Discord test without OpenClawConfig; current main fixed that exact import in 8f1760b667f.
  • The actual current-main merge tree passed the full check:test-types pipeline on fresh Testbox 29489922328, lease tbx_01kxn6hgarkth47031ye321m9r, then stopped cleanly.
  • The iOS Periphery failure occurred before repository code ran because Homebrew lost the downloaded xcodegen Cellar directory; only that failed job was rerun.

Known boundary: client-side navigation scheduled after the short committed-document stability window remains best-effort; later browser actions still apply current-URL guards. Closing rejected targets is intentionally a separate product decision.

@steipete
steipete merged commit 67699dd into openclaw:main Jul 16, 2026
103 of 111 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 17, 2026
…nclaw#105301)

* fix(browser): do not sticky-adopt policy-blocked openTab targets

* test(browser): narrow sticky redirect proof

Co-authored-by: NIO <[email protected]>

* fix(browser): validate tab adoption after navigation

Co-authored-by: NIO <[email protected]>

---------

Co-authored-by: Peter Steinberger <[email protected]>
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
…nclaw#105301)

* fix(browser): do not sticky-adopt policy-blocked openTab targets

* test(browser): narrow sticky redirect proof

Co-authored-by: NIO <[email protected]>

* fix(browser): validate tab adoption after navigation

Co-authored-by: NIO <[email protected]>

---------

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants