Repository navigation
fix(backup): remote namespace owner names can inject terminal control codes into backup output - #184597
fix(backup): remote namespace owner names can inject terminal control codes into backup output#184597KrasimirKralev wants to merge 1 commit into
Conversation
…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.
|
🦞👀 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 changesSanitize remote backup owner identities in namespace listings and ownership refusal messages. Example: A shared archive contains namespace laptop with hostname laptop\u001b[2J.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR fixes a concrete terminal-injection path still present on current main, with a minimal patch and no actionable findings. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherBackup commands read namespace owner metadata through the storage owner, then render namespace listings or reject writes belonging to another installation. flowchart LR
A[Shared storage owner metadata] --> B[Namespace reader]
B --> C[Backup listing]
B --> D[Ownership check]
C --> E[Terminal sanitizer]
D --> E
E --> F[Human output]
C --> G[Unchanged JSON output]
Technical reviewBest possible solution: Merge the focused output-boundary sanitization once existing required checks pass. Do we have a high-confidence way to reproduce the issue? Source traces remote nonempty strings directly into terminal output on main, and the contributor supplies matching before/after CLI traces; this read-only review ran no target code. Is this the best way to solve the issue? Reusing the existing terminal sanitizer at the two rendering boundaries is the smallest complete fix and preserves ownership decisions, storage bytes, and JSON consumers. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 9532824c38d7. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +2, Tests +84. Total +86 across 3 files. Added test files: 1. View PR surface stats
LabelsLabel 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 Reviewed October 26, 2026, 8:24 AM ET / 12:24 UTC. |
…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 @KrasimirKralev. 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 backup listand the namespace-ownership refusal ofopenclaw backup create --to <location>print another installation'sowner.jsonhostname (and device id) verbatim, so terminal escape sequences stored in a shared storage location reach the operator's terminal (clear screen, retitle the window, recolor or fake follow-up text).owner.jsoninbackups/<namespace>/is written by whichever installation claimed that namespace, and itshostname/deviceIdare only checked as non-empty strings. Both human output paths interpolate them raw.--jsonoutput and the storedowner.jsonkeep their original values; namespace validation, ownership checks, takeover (--claim-namespace) and every other backup message are untouched. Plain hostnames render byte-for-byte as before.fix(backup): escape schedule and record report controls), which applied the same sanitizer to the schedule acknowledgement and external record label but left these two remote-sourced fields raw.User Impact
User impact: operators who share a storage location between several installations see the other installations' hostnames as inert text in
backup listand in the "belongs to another OpenClaw installation" refusal; a hostile or corruptedowner.jsoncan no longer drive their terminal. Nothing changes for scripts that read--json.Why This Change Was Made
backupListCommand(src/commands/backup-remote.ts) wraps the namespace owner hostname insanitizeTerminalTextin its human branch only, andassertOwner(src/commands/backup-namespace.ts) sanitizes the owner hostname and the shortened device id inside the refusal message, the same boundary-only approach as fix(backup): escape terminal controls in schedule and record output #184153.ownerSchemaaccepts any non-empty string forhostname/deviceId(correctly: it is metadata, not an identifier we resolve), but the two places that show it to a person did not escape it.src/commands/backup-remote.namespace-output.test.tsplants a hostileowner.jsonin a real filesystem storage location and checks both outputs carry no control characters while the JSON result keeps the stored hostname. Both cases fail onmainand pass with this change. Local gates on the touched files:oxfmt --check,oxlint,tsgo:core, the commands test tsconfig shard, the line-cap ratchet and the assertion-safety ratchet all pass. The new test file contains novi.mockfactory;check-test-mock-exports.mtsdid not finish within 10 minutes on this machine, so it was not run locally.Evidence
openclaw backup listand by the ownership refusal ofopenclaw backup create --to.node --import ./scripts/tsx.mjs src/entry.ts, isolatedHOME/OPENCLAW_STATE_DIR/OPENCLAW_CONFIG_PATH, onefilesystemstorage location namedarchive(encryption: "none") initialized withopenclaw storage init archive. A foreign namespacelaptopwas planted with anowner.jsonwhose hostname islaptop\u001b]0;owned\u0007\u001b[2J\u001b[31mFAKE: backup OKplus one timestamped backup object. Output piped throughcat -vso control bytes are visible.node --import ./scripts/tsx.mjs src/entry.ts backup list --from archive,node --import ./scripts/tsx.mjs src/entry.ts backup create --to archive --namespace laptop,node --import ./scripts/tsx.mjs src/entry.ts backup list --from archive --jsonnode … backup listandnode … backup createfrom source, the ESC/BEL sequences (^[,^G) are gone from both human outputs while the readable hostname text stays; the refusal still exits 1 with the same guidance;--jsonstill returns the stored hostname unchanged, and listing the namespace's backups is unaffected.readNamespaceOwnerpath for every provider. Thebackup createrun stops at the ownership refusal, so no archive upload ran.beforelisting omits its trailing "No backups in archive/." line, which only names this machine's default namespace.