Repository navigation
fix(cli): sanitize untrusted pairing request fields before rendering - #175179
wangmiao0668000666 wants to merge 1 commit into
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesRender pending pairing requests through the existing terminal-safe table renderer while preserving raw JSON output. Example: A pending request has senderId "snd\u001b]0;pwned\u0007PAIR_MARKER".
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a concrete terminal-control injection path still present on current main, using the existing sanitization owner with no actionable findings; exact-head CI remains pending. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe pairing CLI reads pending requests from the existing state owner and returns either structured JSON or a human-readable terminal table. flowchart LR
A[Channel pairing ingress] --> B[Pairing state owner]
B --> C[Pairing list CLI]
C --> D[Raw JSON output]
C --> E[Terminal safe renderer]
E --> F[Operator terminal]
Technical reviewBest possible solution: Merge the existing safe-renderer substitution after the exact-head CI gate passes. Do we have a high-confidence way to reproduce the issue? Current-main source exposes the unsafe rendering path, and contributor-supplied before/after CLI results demonstrate it with a genuine pending request; this review executed no target code. Is this the best way to solve the issue? The smallest complete fix is to reuse the established safe renderer at the human-output boundary, preserving canonical request data, JSON, and approval semantics. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 77d9f42c86bf. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +3, Tests +17. Total +20 across 2 files. Added test files: 0. View PR surface stats
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (11 earlier review cycles; latest 8 shown)
Reviewed October 20, 2026, 9:15 AM ET / 13:15 UTC (Revision 12). |
f799daf to
c4e3a49
Compare
|
@clawsweeper review |
|
🦞👀 Re-review progress:
|
…amilies (#186502) fix(cli): route remaining CLI reports through the terminal-text owner After #185927 added one owner for escaping untrusted values in CLI output, contributors kept opening one PR per command to escape the next report. This moves the remaining human-readable reports in the plugins, secrets, sessions, memory and memory-wiki, workboard, backup, pairing, oc-path, config and setup commands onto `terminalText` / `displayPath`, and extends the owner to neutralize bidirectional control characters. JSON output, persisted identities, raw exports and the CLI's own colors are unchanged, and the trusted styling of `renderTable` is untouched. This absorbs the per-site fixes from @Leon-SK668 (#184454, #184379, #185374, #186449, #184396, #184788, #184813, #184394), @huwei-xydt (#185895, #185719), @wangmiao0668000666 (#175600, #175181, #175179), @SunnyShu0925 (#184747), @KrasimirKralev (#184597) and @arpe1618 (#150599), whose original commits are kept. Families no PR touched (update, Doctor, install-trust producers and others) are listed under "Not fixed here". Evidence: 85 built-CLI invocations per ref with crafted control and bidi characters in the reported values, captured as raw stdout bytes. Main printed the raw sequences; this change printed them neutralized, with identical normal colors and unchanged JSON. Details: #186502 (comment). Co-authored-by: 胡伟0668000622 <[email protected]> Co-authored-by: Claude Code <[email protected]> Co-authored-by: Leon-SK668 <[email protected]> Co-authored-by: wangmiao0668000666 <[email protected]> Co-authored-by: SunnyShu <0668000539@local> Co-authored-by: Krasimir Kralev <[email protected]> Co-authored-by: arpe1618 <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
|
Thanks @wangmiao0668000666. This is now fixed at the root in #186502 (3bcca4f), which routes the remaining CLI reports through the shared |
…amilies (openclaw#186502) fix(cli): route remaining CLI reports through the terminal-text owner After openclaw#185927 added one owner for escaping untrusted values in CLI output, contributors kept opening one PR per command to escape the next report. This moves the remaining human-readable reports in the plugins, secrets, sessions, memory and memory-wiki, workboard, backup, pairing, oc-path, config and setup commands onto `terminalText` / `displayPath`, and extends the owner to neutralize bidirectional control characters. JSON output, persisted identities, raw exports and the CLI's own colors are unchanged, and the trusted styling of `renderTable` is untouched. This absorbs the per-site fixes from @Leon-SK668 (openclaw#184454, openclaw#184379, openclaw#185374, openclaw#186449, openclaw#184396, openclaw#184788, openclaw#184813, openclaw#184394), @huwei-xydt (openclaw#185895, openclaw#185719), @wangmiao0668000666 (openclaw#175600, openclaw#175181, openclaw#175179), @SunnyShu0925 (openclaw#184747), @KrasimirKralev (openclaw#184597) and @arpe1618 (openclaw#150599), whose original commits are kept. Families no PR touched (update, Doctor, install-trust producers and others) are listed under "Not fixed here". Evidence: 85 built-CLI invocations per ref with crafted control and bidi characters in the reported values, captured as raw stdout bytes. Main printed the raw sequences; this change printed them neutralized, with identical normal colors and unchanged JSON. Details: openclaw#186502 (comment). Co-authored-by: 胡伟0668000622 <[email protected]> Co-authored-by: Claude Code <[email protected]> Co-authored-by: Leon-SK668 <[email protected]> Co-authored-by: wangmiao0668000666 <[email protected]> Co-authored-by: SunnyShu <0668000539@local> Co-authored-by: Krasimir Kralev <[email protected]> Co-authored-by: arpe1618 <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Fixes:
openclaw pairing listprints a pending request's sender id verbatim, so an id carrying terminal control sequences (ESC/BEL) changes the operator's terminal while inspecting untrusted senders — requests exist precisely because the sender is not trusted yet.User Impact
User impact: the pairing table renders every cell literally without control sequences, and
--jsonkeeps the raw values for scripts.Why This Change Was Made
Classification: behavior-completing.
This table is the untrusted-input case the terminal renderer already anticipates:
packages/terminal-core/src/table.tsshipsrenderTerminalSafeTable("Render untrusted single-line values without changing renderTable's trusted ANSI contract") next torenderTable, andpairing listwas the remaining caller feeding remote sender metadata into the trusted renderer. The swap is one call; no new helper, option, or output format.Precedent: #172872, #172873, #174989 (same shape at other human report boundaries).
Revision 2026-10-20 — reopened, rebased, re-proved
Rebased onto current
main(2d03d5632a6). The branch's original parent was no longer inmain's history, so the commit was replayed withgit rebase --onto; the production hunk applied unchanged (renderTable→renderTerminalSafeTable, plus its import). The test was re-added against the file's current shape (mainrestructuredpairing-cli.test.tsinto top-levelbeforeEachhelpers and arunPairing(command, ...args)fixture), and it asserts the absence of the control bytes, not just the presence of the visible text.Fresh evidence on this head:
main)c4e3a49906d)src/cli/pairing-cli.test.tsstrips terminal controls from pairing ids and metadataopenclaw pairing list --channel telegram, raw bytesPAIR_MARKERpresentPAIR_MARKERpresentThe third row is the point: the sender-controlled text still renders (
PAIR_MARKER), only theESC ]0; … BELwrapper is removed — this is sanitization of a render path, not dropping the field.Proof setup: one genuine pending request seeded with the repo's own
upsertChannelPairingRequestinto an isolatedOPENCLAW_STATE_DIR,senderId=snd\x1b]0;pwned\x07PAIR_MARKER; the command was run through the repo's CLI entry on both trees with the same state dir. Byte counts and control-byte counts were taken from the captured output, not from a parsed render.Evidence
a45bf3ceb96, headf799dafc9bfe; secretless Linux container, Node 24.18.0, isolatedHOME/OPENCLAW_STATE_DIR.upsertChannelPairingRequest— one withmeta.senderId = "snd\^[]0;pwned\^GPAIR_MARKER", one plain.node --import ./scripts/tsx.mjs src/entry.ts pairing list --channel telegramtelegramUserIdcellsnd]0;pwnedPAIR_MARKERsndPAIR_MARKER0x1b,0x07)plain-senderplain-sender(unchanged)The
--jsonbranch returns{ channel, requests }before the table is built, so structured output is untouched by this diff.Focused regression:
node_modules/.bin/vitest run --config vitest.config.ts src/cli/pairing-cli.test.ts -t 'terminal controls' --maxWorkers=1Changed-file Oxfmt and Oxlint: clean. Whole diff: production
+5/-2, test+31; no new files, options, or output formats.Not tested: requests whose
codeorrequestedtimestamps are remote-controlled (both are generated locally by the pairing owner).