Repository navigation
fix(cli): sweep terminal value escaping and bidi controls in report families - #186502
Merged
Merged
Conversation
Plugin ids and lifecycle warnings printed by openclaw plugins enable/disable are config-derived and could carry ANSI/C0 controls into the operator terminal. Sanitize human report lines with sanitizeTerminalText and extract the policy path into plugins-cli.enable.ts so the grandfathered runtime module does not grow past its line-cap ratchet. Co-Authored-By: Claude Code <[email protected]>
Plugin ids and lifecycle warnings printed by openclaw plugins enable/disable are config-derived and could carry ANSI/C0 controls into the operator terminal. Sanitize human report lines with sanitizeTerminalText and extract the policy path into plugins-cli.enable.ts so the grandfathered runtime module does not grow past its line-cap ratchet. Co-Authored-By: Claude Code <[email protected]>
Config paths, finding text, and preflight warnings are untrusted; keep human CLI lines from controlling the terminal via sanitizeTerminalText. Co-Authored-By: Claude Code <[email protected]>
…ll preview The uninstall preview sanitizes the manifest display name (#183708) but renders preview.pluginId and package-entry ids raw. Local-path installs only path-validate ids (validatePluginId), so a manifest id carrying ESC/BEL reaches the dry-run preview terminal output unchanged, bypassing the name sanitization. Strip control characters from the owner id and package entry ids with the existing sanitizeTerminalText helper, matching the id handling in plugins list/inspect (#172873).
Human-readable sessions cleanup output inserted the store path and agent id verbatim into runtime.log, so a store path carrying C0/C1 terminal controls (ESC color sequences, BEL, newline/tab) could forge terminal output and break single-line formatting. renderAppliedResult and the dry-run path now route both the store path and agent id through sanitizeTerminalText, matching the existing label handling in the same file and the store-header fix in sessions.ts.
…efusals backup list printed the owner.json hostname from a shared storage location verbatim, and the namespace ownership refusal embedded the remote hostname and device id raw, so terminal control sequences written by another installation reached the operator's terminal. Apply the existing terminal sanitizer at those human output boundaries; JSON output and stored owner records keep their original values.
A node sets its own displayName in the pairing request, and `nodes status` renders it verbatim in the pending-request table that an operator reads to approve the device. sanitizeTerminalText escapes C0/C1 controls but passes bidirectional formatting controls (overrides, isolates, marks, the Arabic letter mark) through, so a device could name itself `Owner<RLI><RLO>enohPi s<PDF>box` and render as "Owner's iPhone" in the approval list (Trojan Source, CVE-2021-42574). Strip those controls in the pairing renderer before display. The fix is local to this approval surface rather than in shared sanitizeTerminalText, because other consumers of that helper (for example codex catalog previews) rely on formatting characters passing through. Strong-directional letters are not controls, so a right-to-left device name still renders its letters.
Contributor
|
🦞👀 Pull request received. I will update this pull request when review starts. |
Collaborator
Author
Built CLI raw-byte proofPinned main vs candidate |
Collaborator
Author
|
@clawsweeper re-review |
Contributor
|
🦞👀 Re-review progress:
|
This was referenced Oct 28, 2026
obviyus
added a commit
that referenced
this pull request
Oct 28, 2026
fix(policy): escape untrusted values in policy CLI reports The policy CLI's human-readable reports printed filename-derived values and error text raw, so a crafted name could inject BEL, C1, bidi or ANSI control sequences into the terminal. These reports now go through the shared terminalText owner, as the other CLI reports do since #186502, and the local writePolicyLine sanitizer is removed. JSON output is unchanged. Evidence: built CLI on Node 24.22.1 with real PTY captures. On main, both the clean and the finding report emitted the injected BEL, C1 NEL, bidi override and ANSI bytes (twice each); with this change they were removed in all four captures and ordinary Unicode was kept. JSON stdout was byte-identical, help kept its 237 intended color sequences, exit codes stayed 0 and 1, and policy files were unchanged. Details: #186453 (comment). Thanks @Leon-SK668. Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Oct 29, 2026
…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]>
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Oct 29, 2026
fix(policy): escape untrusted values in policy CLI reports The policy CLI's human-readable reports printed filename-derived values and error text raw, so a crafted name could inject BEL, C1, bidi or ANSI control sequences into the terminal. These reports now go through the shared terminalText owner, as the other CLI reports do since openclaw#186502, and the local writePolicyLine sanitizer is removed. JSON output is unchanged. Evidence: built CLI on Node 24.22.1 with real PTY captures. On main, both the clean and the finding report emitted the injected BEL, C1 NEL, bidi override and ANSI bytes (twice each); with this change they were removed in all four captures and ordinary Unicode was kept. JSON stdout was byte-identical, help kept its 237 intended color sequences, exit codes stayed 0 and 1, and policy files were unchanged. Details: openclaw#186453 (comment). Thanks @Leon-SK668. Co-authored-by: Ayaan Zaidi <[email protected]>
obviyus
added a commit
that referenced
this pull request
Oct 29, 2026
… output (#187666) fix(cli): escape untrusted fields in templates add and validate output openclaw templates add --dry-run and templates validate printed MCP, workspace and project fields from the template raw, so a crafted template could inject terminal control sequences (for example clearing the screen) into human output. These fields now go through the shared terminalText owner, as the other CLI reports do since #186502. JSON output is unchanged. Evidence: built templates add --dry-run and templates validate in real PTYs, twice per command per ref. Main printed the control sequences from MCP, workspace and project fields; with this change the clear-screen sequence was removed and embedded newlines were escaped. The full raw --json stdout was byte-identical between refs for both commands. Details: #187666 (comment). Thanks @SunnyShu0925. Co-authored-by: SunnyShu <0668000539@local> Co-authored-by: Ayaan Zaidi <[email protected]>
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Oct 30, 2026
… output (openclaw#187666) fix(cli): escape untrusted fields in templates add and validate output openclaw templates add --dry-run and templates validate printed MCP, workspace and project fields from the template raw, so a crafted template could inject terminal control sequences (for example clearing the screen) into human output. These fields now go through the shared terminalText owner, as the other CLI reports do since openclaw#186502. JSON output is unchanged. Evidence: built templates add --dry-run and templates validate in real PTYs, twice per command per ref. Main printed the control sequences from MCP, workspace and project fields; with this change the clear-screen sequence was removed and embedded newlines were escaped. The full raw --json stdout was byte-identical between refs for both commands. Details: openclaw#187666 (comment). Thanks @SunnyShu0925. Co-authored-by: SunnyShu <0668000539@local> Co-authored-by: Ayaan Zaidi <[email protected]>
This was referenced Nov 1, 2026
This was referenced Nov 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
File-derived names, paths, plugin metadata and pairing fields can carry terminal escape sequences or bidirectional formatting controls into human reports. The first owner sweep (#185927) established value encoding; these sixteen follow-on fixes identify additional consumers and a missing bidi case in the owner.
Root cause and owner
packages/terminal-core/src/safe-text.tsowns terminal value encoding. ExtendsanitizeTerminalTextto UnicodeBidi_Control, preserving printable RTL text and emoji joiners. UseterminalTextfor value interpolation before styling, existing safe table/value-display helpers, and the existing official-plugin terminal-safe-text facade. There is no sink filter, SGR allowlist, or change torenderTable's trusted-ANSI contract.Cut over the contributor fixes to that owner, remove the private pairing bidi regex and redundant per-site wrappers/extraction/tests, and cover adjacent human output in the same bounded command families. Shared wiki renderers keep raw defaults for model-facing consumers; their CLI formatter supplies the encoder once. Backup namespace refusals use the existing
ExpectedCliErrorhuman/machine boundary, rather than filtering root error reports. The small finalize-search sibling keeps credential-source presentation together without growing the already over-cap wizard module.JSON fields, persisted identifiers, operational paths, raw source/page exports and install-trust report forwarding retain their existing contracts. Theme styling is applied after values are encoded; authored multiline layout is preserved.
Absorbed work and credit
Original primary fix commits are retained with unchanged authorship before the owner cutover:
Thanks to Leon-SK668, huwei-xydt, wangmiao0668000666, SunnyShu0925, KrasimirKralev and arpe1618. This builds on the earlier owner sweep and the reports by Alix-007 and qingminglong credited there.
Ownership checked before adoption and again before publication. #150599 is assigned to maintainer fuller-stack-dev and must not be closed as superseded. The other fifteen are unassigned, with no maintainer commits observed; the lead owns their disposition after landing. This PR does not close or comment on those PRs.
Validation
Secretless Docker, node:24.22.1, built
/work/openclaw.mjs, isolated task-owned profiles/state/config/SQLite paths; no live Gateway or real provider credentials. Pinned main:dafda2f722f19dfc1a56216e8be5af4ff9fe46a3.Raw stdout/stderr and hex captures exercise config paths, setup directories, secrets findings, cleanup stores, backup owner refusals, channel/node pairing, plugin author/build/validate/pack/install/search/marketplace/update/uninstall, memory search/status, wiki local reports, workboard cards and oc-path inspection. Inputs combine ESC/CSI, OSC 8, C1 CSI, bidi controls and LF/TAB. Main already protects some C0/C1 sites from the earlier sweep; those reproduce the remaining bidi leak, not a claimed regression of the old protection. Normal theme SGR, decoded JSON identities, on-disk names and raw exports are explicit controls.
Focused checks include changed-file oxfmt/oxlint, the owner matrix (red on pinned main, green on candidate), config/pairing consumers, backup path consumers and wizard finalize consumers. Contributor code and commit-hook checks run only inside Docker; host commits have hooks disabled. Full typechecks, broad suites and cross-platform checks belong to hosted CI.
Not fixed here
This is a bounded follow-on, not a claim that every CLI sink is safe. Deferred:
src/cli/update-cli/**,src/cli/update-cli.ts; qa-lab/internal QA.src/skills/lifecycle/{clawhub.ts,source-install.ts}and plugin install-security-scan runtime. Trusted install-box marker forwarding is unchanged.Release-note context: human reports in the listed families neutralize untrusted terminal and bidi controls without altering stored or machine-readable values. No CHANGELOG edit (release-owned).
Simplification and exact local results
Removed the contributor-only enable extraction, private pairing bidi policy and per-site regression scaffolding. The canonical owner and existing display helpers remain; necessary growth is caller cutover, presentation-only callback plumbing, typed recovery-message projection and the small credential-summary sibling required by the line-cap ratchet. Against merged main
d5016796673c813cdaaf5fcc0ce0e34e7291408d: production +677/-481 (net +196); tests +35/-36 (net -1); docs +5/-2. Formatter wrapping is included, not hidden.Observed: changed-file oxfmt/oxlint and full staged commit hook including line-cap growth ratchet passed inside Docker. Owner suite 10/10, config/pairing 74/74, backup paths 6/6, finalize 57/57, device/marketplace 54/54, completion 10/10, config/backup integration 21/21, and config recovery owner 1/1 passed. The new owner assertions fail on pinned main in exactly the two bidi boundaries; the memory-wiki package-local compile passes after its optional-value repair. Both built lanes complete 85 CLI invocations each, with all harness assertions passing and identical normal-color SGR arrays. Interactive configure menus and actual remote plugin upgrades were source-audited but not interactively exercised; plugin update proof uses the real untracked-selection error path.
Raw-byte evidence on final merged head: #186502 (comment)
First-head CI/review identified three owned regressions, fixed in
468a7e0fc90b9: restore version encoding before marketplace label formatting; retain existing device identity/IP CR/LF deletion before canonical bidi encoding rather than changing that behavior or weakening its tests; stringify optional wiki lookup values before encoding. The affected device/marketplace suites pass 54/54, the memory-wiki package-local TypeScript compile passes, and changed-file lint, the full Docker staged hook and all 85 built candidate CLI invocations pass again after the repairs. No consumer assertions were changed.The completed first-head CI also identified an owned config recovery-layout regression and a backup integration harness missing the canonical root expected-error projection. Recovery errors now keep raw machine text while encoding value fields before their authored newline; the existing backup harness projects expected errors through
formatCliFailureLines. No assertions were weakened. Consolidating detector inputs keeps every owner case while meeting the zero-net-test-growth constraint.Current main was merged only after GitHub reported a real conflict; setup completion preserves its new optional UTF-8 failure guidance. The latest contributor integration commit from #185895 is also retained, followed by the same complete owner cutover. Final built-source receipts match all 68 selected source/consumer paths byte-for-byte.
Exact scheduled-main evidence for the original-head inherited UI failures (all four cases match; zero cancelled jobs): #186502 (comment). UI repairs remain out of scope.
Latest
6d75cfb0db7d0ad5cbb8bffe3fb544211f5ec22bchanges only the verified backup harness formatter title and owner-test consolidation; production bytes are identical to the 85-command built proof. Focused test-type compilation preserves the repository's ambient roots and passes. A late review's additional DM-policy fatal-layout scenario did not reproduce on built main in either the initial invocation or the explicit-plugin/channel-enabled retry: both exit zero and emit a warning, not the legacy fatal formatter. Exact counterevidence (not relabelled as a passing fatal-layout proof): #186502 (comment).Exact-head landing checks
On
6d75cfb0db7d0ad5cbb8bffe3fb544211f5ec22b, CI run 40634008195 is green, with zero failing and zero cancelled jobs;openclaw/ci-gateandopenclaw/security-sensitive-revieware SUCCESS. ClawSweeper's exact-head review has no established findings / nothing before merge, rating 4/6 (its score was generated while broad CI was still pending). GitHub reports MERGEABLE / CLEAN. No merge or contributor-PR closure has been performed here.