Repository navigation
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 changesThis PR sanitizes workspace and session paths in baseline setup’s human-readable completion reports. Example: A POSIX workspace name contains café, an ANSI color sequence, and a newline before operator-forged.
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-output defect still present on main, uses the existing sanitizer, and has sufficient CLI proof with no actionable findings. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe baseline setup CLI resolves configured paths, creates workspace and session directories, and reports completion through human-readable output or structured JSON. flowchart TD
A[Baseline setup CLI] --> B[Setup owner]
B --> C[Workspace and session directories]
B --> D[Human completion paths]
D --> E[Existing terminal sanitizer]
E --> F[Terminal output]
B --> G[Raw JSON paths]
Technical reviewBest possible solution: Merge the focused display-boundary fix while preserving raw filesystem and JSON paths. Do we have a high-confidence way to reproduce the issue? Current-main source directly exposes both raw paths to terminal output, and the contributor supplies matching base/head CLI traces; this read-only review executed no target code. Is this the best way to solve the issue? This is the smallest complete fix: sanitize both human report values at their existing owner, retain raw paths elsewhere, and add one regression covering those boundaries. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against a9464aeba651. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +1, Tests +36, Docs +3. Total +40 across 3 files. Added test files: 0. View PR surface stats
Review metrics
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, 9:36 AM ET / 13:36 UTC. |
fix(cli): escape terminal controls in untrusted values through one owner CLI human-readable output printed user-controlled values such as config paths, names, directories, binding descriptions, plugin metadata and dead-letter scopes without neutralizing terminal control sequences, so a crafted value could inject ANSI, OSC 8 or C1 sequences into the terminal. Earlier fixes wrapped one call site at a time. A single owner now does this: `terminalText` in terminal-core's safe-text escapes interpolated values before styling, and the display-only `displayPath` delegates to it. Raw path shortening, JSON output and the trusted styling of `renderTable` are unchanged, and the per-site wrapping is replaced. This absorbs #184685, #184666, #184324, #184303, #176763, #176773 and #172873 by @Alix-007 and #184861 by @qingminglong, whose original commits are kept, and moves the earlier merged per-site fixes onto the same owner. Evidence: built CLI in a secretless container, with ESC/CSI, OSC 8 and C1 sequences injected into values for eleven commands across eight families. Main printed the raw sequences; this change printed them neutralized, normal colored output and JSON values were unchanged, and dead-letter errors keep their stderr and JSON contracts. Raw-byte captures: #185927 (comment). Production +81. Co-authored-by: Alix-007 <[email protected]> Co-authored-by: qingminlong <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
|
Thanks @Alix-007. This is now fixed at the root in #185927 (2d2b465): one |
fix(cli): escape terminal controls in untrusted values through one owner CLI human-readable output printed user-controlled values such as config paths, names, directories, binding descriptions, plugin metadata and dead-letter scopes without neutralizing terminal control sequences, so a crafted value could inject ANSI, OSC 8 or C1 sequences into the terminal. Earlier fixes wrapped one call site at a time. A single owner now does this: `terminalText` in terminal-core's safe-text escapes interpolated values before styling, and the display-only `displayPath` delegates to it. Raw path shortening, JSON output and the trusted styling of `renderTable` are unchanged, and the per-site wrapping is replaced. This absorbs openclaw#184685, openclaw#184666, openclaw#184324, openclaw#184303, openclaw#176763, openclaw#176773 and openclaw#172873 by @Alix-007 and openclaw#184861 by @qingminglong, whose original commits are kept, and moves the earlier merged per-site fixes onto the same owner. Evidence: built CLI in a secretless container, with ESC/CSI, OSC 8 and C1 sequences injected into values for eleven commands across eight families. Main printed the raw sequences; this change printed them neutralized, normal colored output and JSON values were unchanged, and dead-letter errors keep their stderr and JSON contracts. Raw-byte captures: openclaw#185927 (comment). Production +81. Co-authored-by: Alix-007 <[email protected]> Co-authored-by: qingminlong <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
|
Thanks @obviyus for consolidating this! Appreciate the guidance. |
What Problem This Solves
Fixes: baseline setup completion reports can execute terminal controls or show forged status rows when a workspace or session directory contains those bytes.
User Impact
User impact: directory confirmations remain readable for unusual POSIX names. Workspace/session creation and JSON paths retain their original values. No configuration, protocol, schema, security policy, migration or upgrade action changes.
Why This Change Was Made
Reuse the existing terminal-text sanitizer at the display owner. Both completion rows convert only their rendered path. No input rejection, global display policy or new helper/state is introduced.
Evidence
Scenario: Baseline setup renders workspace and session completion paths safely while preserving raw directory names, config bytes and JSON paths.
Entry: normal built openclaw.mjs setup --baseline, with human and --json output; disputed owner ran unmocked: src/commands/setup.ts setupUnderOwner completion reports, unmocked
Same command on base
1b6eb7band head38f683e:node proof-setup.mjs "$CHECKOUT" "$PHASE"Readback (subprocess,disk): Capture both real completion rows; independently stat the raw workspace/session directory names; parse the same setup command's JSON paths; compare exact config bytes; run the ordinary-path command control.
Proof harness: proof-common.mjs sha256=8a6d2e48b1b076878e98641b0791f7fb064f44bbff9522fe43d1d34c6ffb007f; proof-setup.mjs sha256=ea469fd8cebad0fb9db5b23244b4ce53a3f7736874418aa72a0654ce498a44fb
Control: Authoritative captured control counts: base [3,3], head [0,0]. Unicode preserved. Ordinary-path positive controls pass. Config byte changes=0; actual raw directory stat and JSON path equality pass. No syscall/write-operation counting is claimed.
Other callers checked: Workspace and session completion rows, raw JSON siblings, ordinary paths and existing setup failure/ownership/include controls inspected. Shared config reporting is a separate existing owner.
Tests: pnpm test src/commands/setup.test.ts --maxWorkers=1 => 15 passed; exit 0 (measured cost: 193.12s measured wall time including native wrapper/worker preparation. 15 cases pass; the real-filesystem setup contract verifies the raw directories and JSON boundary. The native wrapper compiles the selected owner graph; this preparation dominates the >30s run. No sleep, timeout increase, retry allowance, weaker assertion or test-only production seam added. CI seconds: NOT_RUN before PR creation.)
Not tested: Linux isolated baseline setup only; the POSIX control-byte filename regression is skipped on Windows because those filenames are invalid there. No guided onboarding, live Gateway, channel/model, native Windows/macOS, packaged install or released-version upgrade claim. Setup/config/session writers and migration behavior are unchanged.
Product head:
38f683e9a95800ce5c5bf53dbfe20a7e250a4f63; baseline:1b6eb7bf2e7f7cb31ce9ee71c6f1d778f7ee6ce0. Node26.12.1/pnpm12.15.0, Linux, clean normal CLI builds on both revisions.3 files; production +3/−2 LOC; tests +36/−0 LOC. Existing owner and sanitizer reused; no new state or production test seam.
Focused types, typed lint, formatting and whitespace pass. Independent complete-patch P0–P3 source review uses the user-approved subagent fallback; no official autoreview-helper success is claimed.
Regression controls also fail on the original base for the raw-control/forged-row reason. Existing ordinary path, ownership/refusal and JSON contracts remain covered.
Existing-solutions/competition: the shared terminal-core sanitizer already solves the transformation. Maintainer-accepted fix(config): sanitize validation log output to prevent control character injection #39116 covered config IO validation logs; fix(storage): escape terminal controls in location reports #183359/fix(agents): escape terminal controls in creation summaries #183360 covered different report owners. fix(cli): diagnose unreadable configuration in validation and setup #166573 changes read-failure admission/wording and does not repair these report paths. No viable competing same-root fix or Alix/Leon production-file overlap found in all-state semantic/symbol/file scans.
Cleanup: only synthetic task-owned HOME/config/state/workspace/temp data used; no credentials, production service/channel, model API, deployment or restart. Generated individual fixture directories/receipts remain available for audit and may be removed after review.
Not tested: Linux isolated baseline setup only; the POSIX control-byte filename regression is skipped on Windows because those filenames are invalid there. No guided onboarding, live Gateway, channel/model, native Windows/macOS, packaged install or released-version upgrade claim. Setup/config/session writers and migration behavior are unchanged. Required upstream CI is NOT_RUN before creation.
Actual baseline and exact-head CLI streams and independent readback
Streams are JSON-escaped so control bytes cannot execute. Generated private temporary roots are replaced with
$FIXTURE. The historical collector fieldunexpectedConfigWritesrecords the successful config-byte equality check; it is not a count of write operations. The missing-file assertion checks final absence, not create syscalls.{ "phase": "red", "head": "1b6eb7bf2e7f7cb31ce9ee71c6f1d778f7ee6ce0", "at": "2026-10-26T12:52:01.637Z", "runs": [ { "label": "setup-human", "args": [ "$CHECKOUT/openclaw.mjs", "setup", "--baseline" ], "code": 0, "signal": null, "stdout": "Config OK: $FIXTURE/openclaw.json\nWorkspace OK: $FIXTURE/workspace-café\u001b[31m\noperator-forged\tend\rrow\u0007\nSessions OK: $FIXTURE/state-café\u001b[31m\noperator-forged\tend\rrow\u0007/agents/main/sessions\n\nSetup complete: config, workspace, and session directories are ready.\nNext guided path: openclaw onboard.\nNext targeted changes: openclaw configure for models, channels, Gateway, plugins, skills, and health checks.\nAdd a chat channel later: openclaw channels add.\n", "stderr": "", "seconds": 6.079713419000001 }, { "label": "setup-json", "args": [ "$CHECKOUT/openclaw.mjs", "setup", "--baseline", "--json" ], "code": 0, "signal": null, "stdout": "{\n \"ok\": true,\n \"configPath\": \"$FIXTURE/openclaw.json\",\n \"configStatus\": \"unchanged\",\n \"workspaceDir\": \"$FIXTURE/workspace-café\\u001b[31m\\noperator-forged\\tend\\rrow\\u0007\",\n \"sessionsDir\": \"$FIXTURE/state-café\\u001b[31m\\noperator-forged\\tend\\rrow\\u0007/agents/main/sessions\"\n}\n", "stderr": "", "seconds": 5.211129861000001 }, { "label": "ordinary-control", "args": [ "$CHECKOUT/openclaw.mjs", "setup", "--baseline" ], "code": 0, "signal": null, "stdout": "Config OK: $FIXTURE/openclaw.json\nWorkspace OK: $FIXTURE/ordinary-workspace\nSessions OK: $FIXTURE/state/agents/main/sessions\n\nSetup complete: config, workspace, and session directories are ready.\nNext guided path: openclaw onboard.\nNext targeted changes: openclaw configure for models, channels, Gateway, plugins, skills, and health checks.\nAdd a chat channel later: openclaw channels add.\n", "stderr": "", "seconds": 5.440111925999999 } ], "observations": [ { "label": "workspace completion", "controls": 3, "forgedLine": true, "escapedLine": false, "unicode": true }, { "label": "session completion", "controls": 3, "forgedLine": true, "escapedLine": false, "unicode": true } ], "readback": { "rawWorkspaceExists": true, "rawSessionDirectoryExists": true, "jsonRawPathsPreserved": true, "configBytesUnchanged": true, "unexpectedConfigWrites": 0, "ordinaryControlPass": true } }{ "phase": "green", "head": "38f683e9a95800ce5c5bf53dbfe20a7e250a4f63", "at": "2026-10-26T13:09:35.023Z", "runs": [ { "label": "setup-human", "args": [ "$CHECKOUT/openclaw.mjs", "setup", "--baseline" ], "code": 0, "signal": null, "stdout": "Config OK: $FIXTURE/openclaw.json\nWorkspace OK: $FIXTURE/workspace-café\\noperator-forged\\tend\\rrow\nSessions OK: $FIXTURE/state-café\\noperator-forged\\tend\\rrow/agents/main/sessions\n\nSetup complete: config, workspace, and session directories are ready.\nNext guided path: openclaw onboard.\nNext targeted changes: openclaw configure for models, channels, Gateway, plugins, skills, and health checks.\nAdd a chat channel later: openclaw channels add.\n", "stderr": "", "seconds": 5.623654964 }, { "label": "setup-json", "args": [ "$CHECKOUT/openclaw.mjs", "setup", "--baseline", "--json" ], "code": 0, "signal": null, "stdout": "{\n \"ok\": true,\n \"configPath\": \"$FIXTURE/openclaw.json\",\n \"configStatus\": \"unchanged\",\n \"workspaceDir\": \"$FIXTURE/workspace-café\\u001b[31m\\noperator-forged\\tend\\rrow\\u0007\",\n \"sessionsDir\": \"$FIXTURE/state-café\\u001b[31m\\noperator-forged\\tend\\rrow\\u0007/agents/main/sessions\"\n}\n", "stderr": "", "seconds": 5.324876839999999 }, { "label": "ordinary-control", "args": [ "$CHECKOUT/openclaw.mjs", "setup", "--baseline" ], "code": 0, "signal": null, "stdout": "Config OK: $FIXTURE/openclaw.json\nWorkspace OK: $FIXTURE/ordinary-workspace\nSessions OK: $FIXTURE/state/agents/main/sessions\n\nSetup complete: config, workspace, and session directories are ready.\nNext guided path: openclaw onboard.\nNext targeted changes: openclaw configure for models, channels, Gateway, plugins, skills, and health checks.\nAdd a chat channel later: openclaw channels add.\n", "stderr": "", "seconds": 5.589531277999998 } ], "observations": [ { "label": "workspace completion", "controls": 0, "forgedLine": false, "escapedLine": true, "unicode": true }, { "label": "session completion", "controls": 0, "forgedLine": false, "escapedLine": true, "unicode": true } ], "readback": { "rawWorkspaceExists": true, "rawSessionDirectoryExists": true, "jsonRawPathsPreserved": true, "configBytesUnchanged": true, "unexpectedConfigWrites": 0, "ordinaryControlPass": true } }Reproduction collectors
Save the following two files outside each checkout, build that clean checkout normally with
pnpm build cliStartup, and runnode proof-setup.mjs "$CHECKOUT" redon the pinned base orgreenon this head. Collectors only use their own synthetic temporary directories.proof-common.mjs:proof-setup.mjs: