Repository navigation
fix(approvals): sanitize plugin titles and exec paths at the creation boundary - #123742
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: found issues before merge. Reviewed August 14, 2026, 4:35 PM ET / 20:35 UTC. ClawSweeper reviewWhat this changesThe PR sanitizes plugin approval text and selected exec approval display fields when records are created, with regression coverage for escaped text and post-sanitization limits. Merge readinessThe PR closes several approval-text spoofing paths, but a routing-bound node identifier remains raw and is interpolated directly into forwarded reviewer text. That leaves the central security invariant incomplete. Priority: P1 Review scores
Verification
How this fits togetherGateway approval requests become pending records, then feed reviewer broadcasts to chat, push, and the Control UI. Node approvals also retain exact binding data so an authorization can only execute on its original node. flowchart LR
A[Plugin or exec request] --> B[Gateway approval creation]
B --> C[Pending approval record]
C --> D[Node binding check]
C --> E[Reviewer broadcast]
E --> F[Chat and push prompt]
E --> G[Control UI]
Before merge
Findings
Agent review detailsSecurityNeeds attention: A raw node binding still reaches the forwarded approval prompt, leaving reviewer-spoofing protection incomplete. PR surfaceSource +73, Tests +128. Total +201 across 6 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:
Technical reviewBest possible solution: Preserve raw node/session values for authorization, add escaped reviewer-display values, and make chat and Control UI rendering consume those values with an end-to-end hostile-node regression. Do we have a high-confidence way to reproduce the issue? Yes: create a node approval with bidi or invisible characters in its node identifier and inspect the forwarded Is this the best way to solve the issue? No: mutating the stored node identifier would break exact authorization binding; a separate escaped display projection is the maintainable repair. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 8cd749f2ed39. LabelsLabel justifications:
EvidenceSecurity concerns:
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 (8 earlier review cycles)
|
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
… boundary Plugin approval title/description/detail were stored raw and flowed unescaped into channel messages, iOS lock-screen push, and the web modal — bidi/invisible characters could spoof what the operator approves. Exec approvals already sanitize command text at creation; mirror that for the plugin request and for exec's display-only cwd/resolvedPath fields. Re-check the protocol size caps after escaping so a spoof-heavy title fails as INVALID_REQUEST instead of a misleading registration throw.
…boundary The node-policy approval runtime truncated title/description but never sanitized them, so the identical broadcast/forwarder/push paths stayed spoofable through this sibling creator (ClawSweeper P1 finding). Normalize first so a whitespace-only title still fails closed at register.
ClawSweeper follow-ups: pluginId/toolName/fallback agentId are interpolated into channel approval text and were stored raw; the stored detail skipped the 16,384 cap the durable presentation applies, so escape expansion could exceed it. Sanitize the metadata at the same boundary (host-minted runtime identity stays authoritative) and cap detail at storage.
4aa0cc6 to
698cb37
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
toolName and fallback agentId from node-policy code are interpolated into channel approval text; escape them like the RPC ingress. Host-minted runtime identity values stay authoritative.
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
security/ask are closed enums — arbitrary strings now null out via the canonical normalizers instead of reaching reviewer meta rows; host gets the display escape (identity for valid values). nodeId/agentId/sessionKey stay raw by design: they are matched against the node registry and session routing, noted inline.
|
Merged via squash.
|
… boundary (openclaw#123742) * fix(approvals): sanitize plugin titles and exec paths at the creation boundary Plugin approval title/description/detail were stored raw and flowed unescaped into channel messages, iOS lock-screen push, and the web modal — bidi/invisible characters could spoof what the operator approves. Exec approvals already sanitize command text at creation; mirror that for the plugin request and for exec's display-only cwd/resolvedPath fields. Re-check the protocol size caps after escaping so a spoof-heavy title fails as INVALID_REQUEST instead of a misleading registration throw. * fix(gateway): sanitize node-policy plugin approvals through the same boundary The node-policy approval runtime truncated title/description but never sanitized them, so the identical broadcast/forwarder/push paths stayed spoofable through this sibling creator (ClawSweeper P1 finding). Normalize first so a whitespace-only title still fails closed at register. * fix(approvals): sanitize plugin metadata and cap stored detail ClawSweeper follow-ups: pluginId/toolName/fallback agentId are interpolated into channel approval text and were stored raw; the stored detail skipped the 16,384 cap the durable presentation applies, so escape expansion could exceed it. Sanitize the metadata at the same boundary (host-minted runtime identity stays authoritative) and cap detail at storage. * fix(gateway): sanitize node-policy approval metadata too toolName and fallback agentId from node-policy code are interpolated into channel approval text; escape them like the RPC ingress. Host-minted runtime identity values stay authoritative. * fix(approvals): normalize exec policy enums and escape host at creation security/ask are closed enums — arbitrary strings now null out via the canonical normalizers instead of reaching reviewer meta rows; host gets the display escape (identity for valid values). nodeId/agentId/sessionKey stay raw by design: they are matched against the node registry and session routing, noted inline.
What Problem This Solves
Plugin approval
title/description/detailwere stored raw and flowed unescaped to every live reviewer surface: channel messages (buildPluginApprovalRequestMessage), iOS lock-screen push (APNs alert body), and the web modal title/<pre>body. Exec approvals' display-onlycwd/resolvedPathhad the same gap in the UI meta rows and the forwarder'sCWD:line. Bidi override and invisible characters — the exact class the exec sanitizer names — can visually spoof what an operator thinks they are approving. The agent (i.e., a prompt-injected model) controls these strings, so this is attacker-reachable.Why This Change Was Made
The intended pattern already exists on the sibling: exec command text is sanitized once at request creation (
sanitizeExecApprovalDisplayTextWithStatusinexec-approval.ts), so the stored record — and every event/surface built from it — is safe. The durable presentation (approval-presentation.ts) sanitizes its own copy, the TUI sanitizes locally, and the CLI was fixed by #123671, but the live event payload is built from the raw stored record and reaches push/channels/web modal unsanitized.Fix at the creation boundary (the owner): sanitize plugin
title/description/detailinplugin.approval.request, and exec's display-onlycwd/resolvedPathinexec.approval.request. Sanitization is idempotent (escapes are plain ASCII), so downstream re-sanitizes become harmless defense. One dead-end fixed alongside: escaping expands invisibles to\u{...}so a spoof-heavy title can exceed the protocol cap post-sanitize — that used to surface as a misleading registration throw ("approval cannot be persisted without a valid reviewer presentation"); it is now a proper INVALID_REQUEST at the boundary.Execution binding is unaffected: exec runs bind
effectiveCwdviasystemRunBinding(verifiednode-invoke-system-run-approval-match.tsbuilds the actual binding from its own cwd), andresolvedPath's only non-display consumers are outside the approval record. Noted inline.User Impact
Approval prompts on channels, iOS push, and the Control UI can no longer be visually spoofed via bidi/invisible characters in plugin-supplied titles or agent-supplied paths. Oversized-after-sanitize titles fail with a clear request error instead of an internal registration failure.
Evidence
git stashproof: 3 failed pre-fix): stored+broadcast plugin payload sanitized; post-sanitize cap rejection; exec cwd/resolvedPath escaped.plugin-approval.test.ts(37),exec-approval.agent-runtime.test.ts(5),approval-presentation.test.ts,exec-approval-forwarder.test.ts,exec-approval-ios-push.test.ts.pnpm tsgoclean; oxfmt/oxlint clean.Production LOC delta: +33 (sanitize-at-boundary + cap re-check + invariant comments); tests +75.
Update (addendum commit)
ClawSweeper's P1 finding was correct: the node-policy approval runtime (
src/gateway/node-invoke-plugin-policy.ts) — the sibling creator feeding the identical broadcast/forwarder/push paths — truncated title/description but never sanitized them. The addendum routes it through the same boundary: normalize → sanitize → truncate (normalize-first keeps the whitespace-only-title fail-closed register behavior; sanitize-before-truncate keeps escape expansion inside the caps). New regression test (node-invoke-plugin-policy.test.ts"sanitizes node-policy approval titles at creation like the RPC ingress") proves the stored record carries escaped text through the realmanager.create→register→ broadcast path; the pre-existing "fails closed before routing an unrenderable persistent policy approval" test still passes, proving the whitespace contract held. Full suite: 25/25.On the real-behavior-proof gate: the changed path is gateway-internal record construction; the added tests execute the real approval manager, real registration (including durable presentation validation), and the real broadcast payload builder — no mock gateway is interposed on the changed surface. Channel/push delivery consume
record.requestverbatim (unchanged code), which the tests pin post-sanitize.Update 2 (metadata + detail-cap addendum)
Both re-review findings verified and fixed at the same boundary:
pluginId/toolName/fallbackagentIdare interpolated into channel approval text (buildPluginApprovalRequestMessageTool:/Plugin:/Agent:lines) and were stored raw. Untrusted values now getsanitizeExecApprovalDisplayText; host-minted runtime identity values (approvalOwnerPluginId,trustedAgentRuntime.agentId, session-owner agentId) stay authoritative and unescaped (noted inline).detailnow appliestruncatePluginApprovalDetailpost-sanitize, matching the durable presentation's copy — a detail passing the protocol's raw 16,384 cap can no longer exceed it in storage via escape expansion.Regression test extended: hostile metadata escaped in the stored record; oversized-after-sanitize detail capped with the truncation suffix. Suites green:
plugin-approval.test.ts(35),node-invoke-plugin-policy.test.ts(25),exec-approval.agent-runtime.test.ts(5). Autoreview on the addendum: clean, 0.99.Update 3 (node-policy metadata)
Final sibling closed per the re-review: the node-policy creator's
toolNameand fallbackagentId(interpolated into channel approval text) now go through the same display escape via a sharedsanitizeOptionalMetahelper; host-mintedcallerIdentityvalues stay authoritative. Regression extended to assert escaped metadata in the stored record through the real registration path.node-invoke-plugin-policy.test.ts25/25 green; autoreview clean 0.99.Update 4 (exec reviewer metadata)
Remaining exec metadata addressed per the latest review:
security/askare closed enums, so they now go through the canonicalnormalizeExecSecurity/normalizeExecAskat creation — arbitrary strings null out instead of reaching reviewer meta rows (stronger than escaping; decision resolution already treated invalid values as null).hostgets the display escape (identity for the valid enum values).nodeId/agentId/sessionKeyintentionally stay raw — they are matched against the node registry and session routing, so escaping would break real lookups without display gain; noted inline. Regression extended (hostile security/ask null out); 21 exec-approval tests green; autoreview clean 0.99.