Skip to content

fix: external plugin tabs fail under gateway auth - #107323

Merged
steipete merged 4 commits into
openclaw:mainfrom
paulpitchford:fix/plugin-tab-gateway-auth
Jul 16, 2026
Merged

steipete merged 4 commits into
openclaw:mainfrom
paulpitchford:fix/plugin-tab-gateway-auth

Conversation

@paulpitchford

@paulpitchford paulpitchford commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Closes #107255

What Problem This Solves

External plugin Control UI tabs rendered in sandboxed iframes cannot attach the Gateway bearer header, so gateway-authenticated plugin routes fail with 401 Unauthorized.

Security Decision

The authenticated Control UI bootstrap now mints five-minute, signed, HttpOnly frame grants only for visible external tabs that declare auth: "gateway". Each grant is bound to the plugin id, canonical route path, exact-or-prefix match mode, and current Gateway auth generation.

The plugin HTTP auth stage accepts a valid grant only for GET and HEAD, always derives operator.read, and rejects it for mutation requests and WebSockets. Per-process, per-plugin cookie names prevent plugins with the same route root from sharing a credential.

Before mounting the real plugin iframe, the UI runs an authenticated Gateway-owned probe inside an opaque sandbox. Blocked third-party cookies, insecure non-local HTTP contexts, expired grants, or route mismatches leave the plugin iframe unmounted. The probe uses an exact parent origin, a restrictive frame-ancestors policy, and never exposes plugin content or auth state cross-origin.

The browser cookie is a hostname credential boundary; ports do not isolate cookies. Documentation now warns operators not to co-host mutually untrusted services on the Gateway hostname. SameSite=None; Secure is required because opaque sandbox descendants are cross-site; the live probe provides fail-closed browser-policy detection.

Plugin-managed-auth tabs remain direct and unchanged. Query/fragment tab descriptors share one canonical pathname resolver across server and UI grant matching.

User Impact

Gateway-authenticated external plugin tabs work without exposing the shared Gateway token in iframe URLs, JavaScript, plugin requests, or plugin runtime scopes.

Evidence

  • Exact rebased head 2d56aaef95553d3d1d39b6269bc0abfee2a68a40: CI run 29505922873
    • 60 jobs succeeded, 10 skipped, zero failures.
  • node scripts/run-vitest.mjs src/gateway/control-ui-plugin-tabs.test.ts src/gateway/control-ui.http.test.ts src/gateway/server.plugin-http-auth.test.ts src/gateway/server.plugin-frame-auth.test.ts ui/src/app/config.test.ts ui/src/pages/plugin/plugin-page.test.ts
    • 170 tests passed: 155 Gateway and 15 Control UI.
  • Targeted oxlint, oxfmt --check, and git diff --check
    • Passed after the final gate cleanup and test split.
  • Blacksmith Testbox: Actions run 29502010396
    • Focused tests, check:test-types, and full Gateway/SDK/Control UI build passed for the security implementation.
  • Real Chrome profile against a local token-auth Gateway:
    • authenticated sandbox probe returned 200;
    • the separate plugin frame and child asset loaded;
    • two gateway-auth plugin tabs on distinct paths both loaded;
    • plugin root and asset requests carried no Authorization header;
    • plugin runtime scopes were only operator.read;
    • unauthenticated, sibling, nested-other-plugin, encoded-traversal, and cookie-only POST requests were rejected.
  • Fresh maintainer autoreview after the final cleanup
    • No actionable findings.

AI-assisted: yes. Codex performed whole-surface review, implementation, regression coverage, exact-head CI validation, Testbox validation, and real-browser proof. The maintainer reviewed the resulting security boundary and evidence before landing.

@paulpitchford
paulpitchford requested a review from a team as a code owner July 14, 2026 09:35
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: M channel: msteams Channel integration: msteams channel: feishu Channel integration: feishu and removed size: S channel: msteams Channel integration: msteams channel: feishu Channel integration: feishu labels Jul 14, 2026
@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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. labels Jul 14, 2026
@clawsweeper

clawsweeper Bot commented Jul 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge. Reviewed July 15, 2026, 11:14 PM ET / July 16, 2026, 03:14 UTC.

Summary
Adds short-lived signed, route-scoped HttpOnly cookies so authenticated Control UI iframes can access matching external plugin routes protected by Gateway auth.

PR surface: Source +260, Tests +250. Total +510 across 8 files.

Reproducibility: yes. The linked issue provides a concrete v2026.7.1 browser reproduction, and the contributor’s Chromium run against a real Gateway observes the relevant before-and-after HTTP outcomes.

Review metrics: 2 noteworthy metrics.

  • Credential lifetime: 5 minutes. The short expiry limits exposure but does not prevent authorization from crossing a nested route boundary.
  • Grant bindings: 4 present: path, auth generation, scopes, expiry. The current design materially hardens the initial proposal while still lacking authoritative route identity.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #107255
Summary: This PR is the candidate implementation for the canonical shipped plugin-tab authentication bug.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🐚 platinum hermit
Patch quality: 🦐 gold shrimp
Result: needs maintainer review before merge.

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

Rank-up moves:

  • [P2] Add real-server or focused regression proof that a parent-path cookie cannot authorize a distinct nested route.

Risk before merge

  • [P1] A cookie for a prefix tab such as /secure-hook can be sent to and accepted for a distinct supported nested route such as /secure-hook/admin, transferring the parent grant’s operator scopes across route ownership.

Maintainer options:

  1. Bind to resolved route (recommended)
    Carry authoritative route or descriptor identity through cookie issuance and validation, with an overlapping-route regression test.
  2. Define prefix ownership
    Merge only if maintainers intentionally define a tab prefix as granting every same-auth plugin route nested beneath it and document that security contract.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Add regression coverage for overlapping routes such as `/secure-hook` and `/secure-hook/admin`; bind plugin-tab cookie authorization to the resolved route or descriptor identity so child assets of the same route remain allowed but a distinct nested route is denied.

Next step before merge

  • [P2] The blocker is a narrow route-identity repair with a precise overlapping-route regression path.

Security
Needs attention: The cookie is bounded by expiry, generation, scopes, and path, but path-prefix matching can cross a supported nested plugin-route boundary.

Review findings

  • [P1] Bind the grant to the resolved plugin route — src/gateway/control-ui-plugin-auth-cookie.ts:15
Review details

Best possible solution:

Authorize the cookie against the resolved plugin route or descriptor identity, preserving child assets owned by that route while denying separately registered nested routes.

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

Yes. The linked issue provides a concrete v2026.7.1 browser reproduction, and the contributor’s Chromium run against a real Gateway observes the relevant before-and-after HTTP outcomes.

Is this the best way to solve the issue?

No, not yet. A signed cookie handoff is maintainable, but request-path prefix alone is not the narrowest safe authority when supported nested plugin routes can overlap.

Full review comments:

  • [P1] Bind the grant to the resolved plugin route — src/gateway/control-ui-plugin-auth-cookie.ts:15
    A cookie minted for a prefix tab like /secure-hook also path-matches /secure-hook/admin, so it can authorize a separately registered nested gateway-auth route even though overlapping same-auth routes are supported. This is a late discovery on code unchanged from the prior reviewed head; add an overlapping-route regression and bind the grant to resolved route or descriptor identity while preserving assets owned by the same route.
    Confidence: 0.93
    Late finding: first raised on code an earlier review cycle already covered.

Overall correctness: patch is incorrect
Overall confidence: 0.9

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. Copied live output from Chromium against a real Gateway demonstrates iframe success plus direct, sibling, expired, and rotated-generation rejection with sensitive values redacted.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp. Replaced prior rating: 🧂 unranked krab.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P2: The PR addresses a real but limited external-plugin tab regression and has one focused blocking security defect.
  • merge-risk: 🚨 security-boundary: Merging would add a browser credential path that can authorize a distinct nested protected plugin route.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🦐 gold shrimp. Replaced prior rating: 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Sufficient (live_output): Copied live output from Chromium against a real Gateway demonstrates iframe success plus direct, sibling, expired, and rotated-generation rejection with sensitive values redacted.
  • proof: sufficient: Contributor real behavior proof is sufficient. Copied live output from Chromium against a real Gateway demonstrates iframe success plus direct, sibling, expired, and rotated-generation rejection with sensitive values redacted.
Evidence reviewed

PR surface:

Source +260, Tests +250. Total +510 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 6 289 29 +260
Tests 2 254 4 +250
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 543 33 +510

Security concerns:

  • [high] Parent tab grant can authorize a nested route — src/gateway/control-ui-plugin-auth-cookie.ts:15
    The browser and server both accept child paths, but the signed grant lacks route identity, so a distinct nested route may inherit the parent tab’s operator scopes.
    Confidence: 0.93

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs src/gateway/control-ui.http.test.ts src/gateway/server.plugin-http-auth.test.ts.
  • [P1] git diff --check origin/main..HEAD.
  • [P1] node scripts/run-oxlint.mjs src/gateway/control-ui-plugin-auth-cookie.ts src/gateway/http-auth-utils.ts src/gateway/server-http.ts src/gateway/server/plugins-http.ts src/gateway/server.plugin-http-auth.test.ts.

What I checked:

Likely related people:

  • steipete: Control UI and Gateway authentication history connects this person to secure UI auth and device-bound credential behavior adjacent to the changed boundary. (role: control UI authentication feature owner; confidence: high; commits: f76e3c1, d8cc7db, dfbf6ac; files: ui/src/ui/gateway.ts, src/gateway/control-ui.ts)
  • BunsDev: Recent merged work covers Control UI authentication, connection handling, and operator-read scope behavior adjacent to the scopes carried by this cookie. (role: recent Control UI auth contributor; confidence: medium; commits: 3e2b3bd, 42b3c52, 79ae814; files: ui/src/ui/gateway.ts)
  • YuzuruS: Relevant history ties this contributor to default operator-scope behavior projected by the new browser credential into plugin runtime scopes. (role: operator-scope contributor; confidence: medium; commits: 6f7e5f9; files: ui/src/ui/gateway.ts, src/gateway/method-scopes.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 (9 earlier review cycles; latest 8 shown)
  • reviewed 2026-07-14T13:45:01.688Z sha b3271af274647b344d8e8270eff13819f8c2018e :: needs real behavior proof before merge. :: [P1] Bind the plugin-tab grant to revocation and its route
  • reviewed 2026-07-14T14:14:25.750Z sha 96b82cbe97cb8d7f6cd7a35f9659982823157ed3 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-14T14:29:27.769Z sha 96b82cbe97cb8d7f6cd7a35f9659982823157ed3 :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-15T02:28:12.331Z sha 242bd0a6a56b00168b0a9fc652f067e6509390bc :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-15T03:43:08.029Z sha 242bd0a6a56b00168b0a9fc652f067e6509390bc :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-15T04:55:55.299Z sha 242bd0a6a56b00168b0a9fc652f067e6509390bc :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-15T06:09:50.868Z sha 242bd0a6a56b00168b0a9fc652f067e6509390bc :: needs real behavior proof before merge. :: none
  • reviewed 2026-07-15T07:20:59.947Z sha a55be80 :: needs real behavior proof before merge. :: none

@paulpitchford

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 14, 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:

@paulpitchford

Copy link
Copy Markdown
Contributor Author

Updated the PR body with redacted live browser proof on head 15e2d188649c8cd6d3c947a31c6a4770007e39aa: iframe 200, direct/sibling 401, cookie flags/expiry, expired payload 401, and auth-generation rotation 401.\n\n@clawsweeper re-review

@paulpitchford

Copy link
Copy Markdown
Contributor Author

Rebased onto current main and refreshed the proof on head 886aeb594a843fdddb0787b70b0f25b976ffd181.\n\n@clawsweeper re-review

@paulpitchford

Copy link
Copy Markdown
Contributor Author

Verification update after rebasing onto latest openclaw/main:

  • Pushed refreshed head 242bd0a from fix/plugin-tab-gateway-auth
  • Targeted gateway auth tests pass locally: node scripts/run-vitest.mjs src/gateway/control-ui.http.test.ts src/gateway/server.plugin-http-auth.test.ts (2 files, 131 tests)
  • git diff --check origin/main..HEAD is clean
  • Previous full CI run on the same patch before the final rebase passed; fresh checks are now running on 242bd0a
  • Fresh quick gates already passing include Scan changed paths (precise), Opengrep OSS, security-sensitive-guard, dependency-guard, Real behavior proof, preflight, and security-fast

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 15, 2026
@paulpitchford

Copy link
Copy Markdown
Contributor Author

Rebased onto current openclaw/main and pushed refreshed head 3caa49b from fix/plugin-tab-gateway-auth.

Verification after rebase:

  • Targeted gateway auth tests pass locally: node scripts/run-vitest.mjs src/gateway/control-ui.http.test.ts src/gateway/server.plugin-http-auth.test.ts (2 files, 131 tests)
  • git diff --check origin/main..HEAD is clean

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 15, 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.

@paulpitchford

Copy link
Copy Markdown
Contributor Author

Follow-up: main moved again after the previous refresh, so I rebased once more and pushed refreshed head f8bef085 from fix/plugin-tab-gateway-auth.

Verification after this rebase:

  • Targeted gateway auth tests pass locally: node scripts/run-vitest.mjs src/gateway/control-ui.http.test.ts src/gateway/server.plugin-http-auth.test.ts (2 files, 131 tests)
  • git diff --check origin/main..HEAD is clean

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 15, 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.

@paulpitchford

Copy link
Copy Markdown
Contributor Author

Rebased again onto current openclaw/main after the transient Actions failures and pushed refreshed head a55be801 from fix/plugin-tab-gateway-auth.

Verification after this rebase:

  • Targeted gateway auth tests pass locally: node scripts/run-vitest.mjs src/gateway/control-ui.http.test.ts src/gateway/server.plugin-http-auth.test.ts (2 files, 131 tests)
  • git diff --check origin/main..HEAD is clean

The previous failed Actions appeared to be transient GitHub/API/base-fetch failures rather than failures in this PR.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jul 15, 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:

@paulpitchford

Copy link
Copy Markdown
Contributor Author

Added an inspectable proof harness on a throwaway branch, separate from this PR branch:

https://github.com/paulpitchford/openclaw/tree/prototype/plugin-tab-auth-proof

Command run locally from that branch:

node scripts/run-vitest.mjs src/gateway/plugin-tab-auth-proof.prototype.test.ts

Result:

Test Files  1 passed (1)
Tests       1 passed (1)

The prototype uses Chromium against a real createGatewayHttpServer instance on this PR head, not a mocked request object. It first makes an authenticated Control UI bootstrap-config read to mint the HttpOnly plugin-tab cookie into Chromium's browser cookie jar, then loads the plugin route from a same-origin iframe without an Authorization header.

Redacted proof matrix from .artifacts/plugin-tab-auth-proof/proof.md:

direct unauthenticated plugin route rejects: /secure-hook => 401
authenticated Control UI read mints plugin-tab cookie: /control-ui-config.json => 200
iframe route load uses browser cookie: /secure-hook => 200
child path under bound route accepts: /secure-hook/asset.js => 200
sibling gateway-auth route rejects route-scoped cookie: /other-secure-hook => 401
auth-generation rotation invalidates existing cookie: /secure-hook => 401
expired signed cookie payload rejects: /secure-hook => 401

The generated artifact redacts loopback port and token values. The prototype source is intentionally not part of this PR; it is linked as inspectable browser proof for the credential/cookie behavior requested by review.

@clawsweeper re-review

@steipete steipete self-assigned this Jul 16, 2026
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: XL and removed size: L labels Jul 16, 2026
@steipete
steipete merged commit efa8075 into openclaw:main Jul 16, 2026
124 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
* fix: load plugin tabs with gateway auth

* fix: harden plugin tab cookie signature compare

* fix(gateway): authenticate external plugin tabs

Co-authored-by: Paul Pitchford <[email protected]>

* refactor(gateway): simplify plugin frame auth proof

---------

Co-authored-by: Peter Steinberger <[email protected]>
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
* fix: load plugin tabs with gateway auth

* fix: harden plugin tab cookie signature compare

* fix(gateway): authenticate external plugin tabs

Co-authored-by: Paul Pitchford <[email protected]>

* refactor(gateway): simplify plugin frame auth proof

---------

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

app: web-ui App: web-ui docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: External Control UI tab cannot render gateway-auth plugin route under token auth

2 participants