Repository navigation
fix(dashboard): open widget links through the host instead of sandbox popups - #128125
Conversation
… popups Widget frames granted allow-popups/allow-popups-to-escape-sandbox to every rendered widget, including grantState "none" widgets that never reach an operator approval card. CSP has no navigate-to, so a popup bypassed the connect-src 'none' containment those widgets otherwise run under. Scripted window.open was blocked only by the document guard's open lock, which is emitted solely when blockDescendantFrames is set, so two unrelated knobs had to agree for the boundary to hold. Restore both sandbox strings and route user-clicked links through the existing ticket-bound bridge: a trusted click on a ticketed board widget's http(s) target="_blank" anchor forwards to the Control UI, which opens the tab with noopener,noreferrer. Links keep working for every rendered widget, the host owns the scheme filter instead of trusting widget-authored rel attributes, and scripted popups are impossible by construction rather than by coincidence. Also collapses the unreachable controlUiBaseUrl branch and corrects both docs pages, including the claim that links opened for every rendered widget, which was never true for MCP-App board widgets. Follow-up to #127315; refs #127314.
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs changes before merge. Reviewed August 23, 2026, 4:16 AM ET / 08:16 UTC. ClawSweeper reviewWhat this changesThe PR removes widget iframe popup permissions and routes trusted HTTP(S) new-tab links through the Control UI host. Regression provenancePossible regression — suspected (reviewed change). No predecessor PR is attributed. Merge readinessNeeds changes before merge: the new host routing drops middle-button navigation and overrides widget handlers that cancel a link click. Priority: P2 Review scores
Verification
Live VerificationCommand: Result: PASS (completed) Assertions:
How this fits togetherDashboard widget HTML runs inside nested sandboxes and uses a ticket-bound bridge to ask the Control UI to perform allowed host actions. This change moves external-link navigation from iframe popup permissions to the Control UI’s safe external-navigation owner. flowchart LR
A[Widget HTML] --> B[Injected widget wrapper]
B --> C[Ticket-bound bridge]
C --> D[Control UI controller]
D --> E[Safe external navigation]
E --> F[New browser tab]
G[Sandbox policy] --> B
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +30, Tests +57, Docs +2. Total +89 across 12 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Copy recommended automerge instructionTechnical reviewBest possible solution: Keep the host-owned HTTP(S) navigation design, but route trusted auxiliary activation and let ordinary widget cancellation suppress navigation before opening a tab. Do we have a high-confidence way to reproduce the issue? Yes, from source: a middle click produces auxclick/button 1 while the wrapper handles only primary click, and both sandbox layers now deny the native popup fallback. Is this the best way to solve the issue? No: the host-owned opener is the right boundary, but the current capture-phase primary-click-only hook is narrower than the existing navigation contract. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 79e675521f7c. LabelsLabel justifications:
EvidenceAcceptance criteria:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
Live dashboard after the changeBoth widgets rendering in the real Control UI on an isolated dev gateway: the granted widget (all four link variants) and one with no declared capabilities that never saw an approval card. Appearance is unchanged by design — links still render and still work; what changed is that the |
… owner The widget bridge opened links with a local window.open helper, which the lint:ui:no-raw-window-open boundary guard rejects. Delegate to openExternalUrlSafe(), the Control UI owner for external navigation: it applies noopener/noreferrer, detaches the opener handle, and keeps one canonical open path. The bridge keeps a narrower absolute-http(s) gate, since widget-supplied links must not reach blob: URLs that the shared external-link policy permits.
…licks Address ClawSweeper review on #128125. The wrapper only handled primary click, so with popup permission removed from both sandbox layers a middle-button activation silently did nothing. It also listened on capture, so a widget handler's preventDefault could not cancel the link the wrapper then opened itself. Match the Control UI activation contract in ui/src/app/native-link-routing.ts: listen for click and auxclick, gate on !defaultPrevented && !shiftKey && !altKey && (click+button 0 || auxclick+button 1), and listen on bubble so widget cancellation stays effective. A middle click now routes for any widget link, not just target=_blank, since middle-click always means new tab and leaving plain links unrouted would keep the same silent-no-op class. Move the wrapped-document test into src/canvas/wrap.test.ts: it exercises buildWidgetDocument, so it belongs with its owner, and the added assertions would otherwise push widget-tool.test.ts past the max-lines cap that AGENTS.md forbids suppressing.
|
Both findings were real and are fixed in [P2] Route middle-button widget links — fixed. The wrapper now listens for [P2] Honor widget-canceled link clicks — fixed. The listeners moved from capture to bubble, so a widget handler's Both merge risks are therefore resolved: every supported activation path is preserved, and the navigation semantics now match the Control UI contract rather than being narrower than it. Rank-up moves — both applied, not skipped. Live re-verification
Also in this pushAdding the assertions pushed Acceptance criteria from the review all pass locally: |
|
@clawsweeper re-review Both P2 findings are addressed in |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
Merged via squash.
|
… popups (openclaw#128125) * fix(dashboard): open widget links through the host instead of sandbox popups Widget frames granted allow-popups/allow-popups-to-escape-sandbox to every rendered widget, including grantState "none" widgets that never reach an operator approval card. CSP has no navigate-to, so a popup bypassed the connect-src 'none' containment those widgets otherwise run under. Scripted window.open was blocked only by the document guard's open lock, which is emitted solely when blockDescendantFrames is set, so two unrelated knobs had to agree for the boundary to hold. Restore both sandbox strings and route user-clicked links through the existing ticket-bound bridge: a trusted click on a ticketed board widget's http(s) target="_blank" anchor forwards to the Control UI, which opens the tab with noopener,noreferrer. Links keep working for every rendered widget, the host owns the scheme filter instead of trusting widget-authored rel attributes, and scripted popups are impossible by construction rather than by coincidence. Also collapses the unreachable controlUiBaseUrl branch and corrects both docs pages, including the claim that links opened for every rendered widget, which was never true for MCP-App board widgets. Follow-up to openclaw#127315; refs openclaw#127314. * fix(dashboard): open widget links through the Control UI external-url owner The widget bridge opened links with a local window.open helper, which the lint:ui:no-raw-window-open boundary guard rejects. Delegate to openExternalUrlSafe(), the Control UI owner for external navigation: it applies noopener/noreferrer, detaches the opener handle, and keeps one canonical open path. The bridge keeps a narrower absolute-http(s) gate, since widget-supplied links must not reach blob: URLs that the shared external-link policy permits. * fix(dashboard): route middle-button widget links and honor canceled clicks Address ClawSweeper review on openclaw#128125. The wrapper only handled primary click, so with popup permission removed from both sandbox layers a middle-button activation silently did nothing. It also listened on capture, so a widget handler's preventDefault could not cancel the link the wrapper then opened itself. Match the Control UI activation contract in ui/src/app/native-link-routing.ts: listen for click and auxclick, gate on !defaultPrevented && !shiftKey && !altKey && (click+button 0 || auxclick+button 1), and listen on bubble so widget cancellation stays effective. A middle click now routes for any widget link, not just target=_blank, since middle-click always means new tab and leaving plain links unrouted would keep the same silent-no-op class. Move the wrapped-document test into src/canvas/wrap.test.ts: it exercises buildWidgetDocument, so it belongs with its owner, and the added assertions would otherwise push widget-tool.test.ts past the max-lines cap that AGENTS.md forbids suppressing.

Follow-up to #127315; refs #127314.
What Problem This Solves
Resolves a problem where any pinned dashboard widget — including one that declares no capabilities and therefore never shows an operator approval card — could open an arbitrary external site in a new, fully unsandboxed tab as soon as the operator clicked anything the widget rendered.
#127315 shipped widget links by adding
allow-popups allow-popups-to-escape-sandboxto the widget iframe sandbox. Those flags were applied to every rendered frame, not only to widgets whose capability grant is active. Widgets ingrantState: "none"are otherwise fully network-contained byconnect-src 'none',img-src data:,form-action 'none', andframe-src 'none'(src/gateway/board-sandbox.ts). CSP has nonavigate-todirective, so a popup bypasses all of it, and widget HTML is model-authored.The second problem was structural. The only thing preventing a widget from calling
window.open(...)from script waslock(globalThis,"open",undefined)insidebuildSandboxDocumentGuardHtml, which is emitted only whenblockDescendantFramesis true (src/agents/sandbox-host.ts:22).board-sandbox.tsis its sole caller. Two unrelated knobs — one about embedded frames, one about popups — had to agree for the boundary to hold, with nothing documenting or testing the coupling.#127314 proposed granting popups only after a capability grant is active. The merged implementation was broader than that.
Why This Change Was Made
Both sandbox strings are restored to their pre-#127315 values, and user-clicked links now travel through the existing ticket-bound bridge instead of through a sandbox permission. The widget wrapper installs a capture-phase click listener that forwards a trusted click on a ticketed board widget's
http/httpstarget="_blank"anchor to the Control UI, which performs thewindow.openand appliesnoopener,noreferreritself.This removes the escalation rather than narrowing it: scripted popups are now impossible by construction rather than by coincidence,
noopenerno longer depends on the widget author writingrelcorrectly, and the host owns the scheme filter. It also decouples popup behaviour fromblockDescendantFramesentirely, so relaxing that unrelated flag can no longer hand widgets a popup channel.Non-goal: this does not change the shipped product decision that a user-clicked link is ordinary navigation. An operator who clicks a widget's link still reaches that destination. What changes is that the destination now passes through one trusted, testable place, which is where any future policy would go.
Also collapses the unreachable
controlUiBaseUrlbranch (the only production caller always passes a non-empty string) and corrects both docs pages, including the claim that links open "for every rendered widget" — never true for MCP-App board widgets, which render throughmcp-app-view.tsand never had popup flags.User Impact
Dashboard widget links keep working exactly as they do today, for granted and ungranted widgets alike. Operators get a materially smaller blast radius: a widget that was never approved can no longer be handed an unsandboxed browsing context, and no widget can open a tab without a real click. Widget authors no longer need to remember
rel="noopener noreferrer"— the host applies it regardless. There is no visual change and no configuration change.Evidence
Live: isolated Gateway (own
OPENCLAW_STATE_DIR, ephemeral port,gateway.controlUi.basePath=/openclaw), two widgets pinned viaboard.widget.put— one granted, one with no declared capabilities — driven in real Chromium against the real Control UI dashboard.allow-scripts allow-same-origin allow-forms— no popupstarget="_blank"withrelhttps://example.com/live-prooftarget="_blank"withoutrelhttps://example.com/norel,window.openerfalsejavascript:link__jsRanfalsedata:linkwindow.openTypeError: window.open is not a function.click()isTrustedgate)openclaw.host.controlUiBaseUrlhttp://127.0.0.1:51750/openclawChromium's own console confirms the sandbox is closed again while http/https links keep working:
A separate two-origin Playwright probe confirmed the load-bearing assumption before implementation: a click inside a popup-less cross-origin iframe still grants the top window transient activation (
hostActivationActive=true), so the host'swindow.openis not popup-blocked.Regression coverage: 12 new/updated assertions. All fail on pre-fix code for the intended reasons (verified by reverting only the production files) and pass after — 7 UI (
host.openscheme handling, blocked-popup reporting, ungranted-frame sandbox), 4 gateway (proxy popup flags, and the decoupling test asserting the inner sandbox grants no popups regardless ofblockDescendantFrames), 1 canvas (widget document bytes).Suites: core widget/sandbox 45 passed; UI board suites 203 passed / 15 skipped;
node scripts/check-changed.mjsgreen across core, coreTests, ui, docs;pnpm buildclean.Review: Codex autoreview on the branch — clean, no accepted or actionable findings,
patch is correct (0.99).LOC: production +47/-14, tests +68/-11, docs +7/-5. 13 of the production additions are the two invariant comments the repo's comment doctrine requires at the sandbox and
host.opensites.UI proof: the dashboard is visually unchanged by design — the screenshot below shows both widgets (granted, and "no declared capabilities") rendering normally with working links after the change. The meaningful evidence is the behavioural matrix above.