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 human-readable sandbox explanation values before styling while preserving original JSON paths. Example: A Linux workspace directory contains café followed by ESC[2J, BEL, a newline, and FORGED.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR provides a minimal fix for a current-main diagnostic rendering bug, with no actionable defects found and passing exact-head CI. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe sandbox explain CLI resolves configuration and session facts into a payload, then emits structured JSON or a styled terminal report. flowchart TD
A[CLI arguments] --> B[Sandbox explanation owner]
C[Configuration and session facts] --> B
B --> D[Original JSON payload]
B --> E[Sanitized display values]
E --> F[Styled terminal report]
Technical reviewBest possible solution: Apply the existing terminal sanitizer at the shared display renderer while retaining raw values for JSON and runtime use. Do we have a high-confidence way to reproduce the issue? Current-main source exposes the raw-path rendering failure, and the contributor supplies matching built-CLI before/after observations; this read-only review executed no target code. Is this the best way to solve the issue? This is the smallest complete fix using existing owners: one sanitizer call protects shared display values, and one command regression checks text safety without changing JSON. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 820e3ce6b95a. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +1, Tests +28. Total +29 across 2 files. Added test files: 0. View PR surface stats
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 (1 earlier review cycle)
Reviewed October 26, 2026, 5:07 AM ET / 09:07 UTC (Revision 2). |
…e owner conflicts
|
@clawsweeper re-review Updated head: Current-head evidence and inspectable output. Exact-head CI is green; targeted types, lint, format, line-cap check and independent source/publication reviews passed. Thank you for reviewing the updated revision. |
|
🦞👀 Re-review progress:
|
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]>
|
@shakkernerd: #185927 (2d2b465) landed a root-cause fix that routes the covered CLI report values through one Rechecked against current main |
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]>
|
Hi @shakkernerd, could you take a look at the final disposition here when you have a chance? It's been open for over a week; #185927 already includes the fix with co-author credit. Thanks! |
|
Closing this as absorbed by the merged #185927, with contributor credit retained. Thanks @obviyus for integrating the fix, and @shakkernerd for taking a look! |
What Problem This Solves
Fixes:
sandbox explaincan clear terminal output or insert extra report lines when a configured workspace path contains control characters.User Impact
User impact: operators can read effective sandbox paths safely. JSON paths and the effective sandbox/workspace configuration keep their original values.
Why This Change Was Made
Apply the existing terminal sanitizer in the central human-readable value renderer, before styling. JSON returns before this renderer, so consumers retain the original filesystem paths. No config/default, protocol/schema, permission/security-policy, dependency, compatibility, or migration changes.
Evidence
Current-head maintenance — October 26, 2026
70b78d7a30dbe25fac1d7d7e4d900bc46536bf92; integrated main:423ae422ef67159dd85c84c417f4a7ea304e131c; independently reviewed clean tree:ff73f7dad505a2fb267dcfb88d94204b3d9ec4b5. Ordinary merge, existing contributor history retained, no force-push.node <checkout>/openclaw.mjs sandbox explain [--json]; canonical owner:src/commands/sandbox-explain.ts, unmocked, from a normalpnpm build:runtimewith a matching clean-head buildstamp. Node 26.12.1/Linux, isolated HOME/config/state. Build and CLI proof each exited 0; this is not a mocked command action or direct internal-function proof.node proof-sandbox.mjs "$CHECKOUT" <red|green>; current run uses green. Complete collector and helper retained below; collector SHA-256 cd2663f6f7fd0de720e6bddbe30737f1a9996927d4de311c188d233e51e65df8 (only the helper import uses the task-local layout); helper SHA-256 9618fa1e6e0263e7ce22d485b7c1620a8db3cd0dee2ef11727c0d4253bace8cb. Scenario and all assertions are unchanged.70b78d7a30dbe25fac1d7d7e4d900bc46536bf92, freshly run at 2026-10-26T08:40:10.650Z: 0 unsafe controls and 0 injected lines; 2 visible escaped newlines; JSON retains both original paths, fs.stat reads the real directory, config bytes are unchanged, ordinary workspace succeeds. All three real CLI processes exit 0.Current-head normal-built CLI stdout/stderr and real filesystem readback
{ "name": "sandbox-terminal", "phase": "green", "head": "70b78d7a30dbe25fac1d7d7e4d900bc46536bf92", "time": "2026-10-26T08:40:10.650Z", "root": "<isolated-fixture>", "runs": [ { "label": "sandbox-explain", "args": [ "sandbox", "explain" ], "code": 0, "stdout": "Effective sandbox:\n agentId: main\n sessionKey: agent:main:main\n mainSessionKey: agent:main:main\n runtime: direct\n mode: off scope: agent\n workspaceAccess: none workspaceRoot: <isolated-fixture>/state/sandboxes\n effectiveHostWorkspaceRoot: <isolated-fixture>/café\\nFORGED/workspace\n backend: docker runtimeWorkdir: <isolated-fixture>/café\\nFORGED/workspace workspaceSource: direct\n\nSandbox tool policy:\n allow (default): exec, process, read, ls, write, edit, apply_patch, view_image, github_read, github_search, github_publish, sessions_list, sessions_history, sessions_search, sessions_send, sessions_spawn, sessions_yield, subagents, session_status, get_goal, create_goal, update_goal\n deny (default): browser, canvas, computer, mobile_ui, nodes, automations, gateway, feishu, googlechat, nostr, buzz, msteams, mattermost, nextcloud-talk, matrix, raft, a2a, line, zalo, clickclack, x, zalouser, sms, synology-chat, tlon, discord, imessage, irc, reef, signal, slack, telegram, twitch, whatsapp\n\nElevated:\n enabled: true\n channel: (unknown)\n allowedByConfig: false\n\nFix-it:\n - tools.sandbox.tools.allow\n - tools.sandbox.tools.alsoAllow\n - tools.sandbox.tools.deny\n - agents.entries.*.tools.sandbox.tools.allow\n - agents.entries.*.tools.sandbox.tools.alsoAllow\n - agents.entries.*.tools.sandbox.tools.deny\n - tools.elevated.enabled\n\nDocs: https://docs.openclaw.ai/sandbox\n\n", "stderr": "" }, { "label": "raw-path-json-control", "args": [ "sandbox", "explain", "--json" ], "code": 0, "stdout": "{\n \"docsUrl\": \"https://docs.openclaw.ai/sandbox\",\n \"agentId\": \"main\",\n \"sessionKey\": \"agent:main:main\",\n \"mainSessionKey\": \"agent:main:main\",\n \"sandbox\": {\n \"mode\": \"off\",\n \"scope\": \"agent\",\n \"backend\": \"docker\",\n \"workspaceAccess\": \"none\",\n \"workspaceRoot\": \"<isolated-fixture>/state/sandboxes\",\n \"effectiveHostWorkspaceRoot\": \"<isolated-fixture>/café\\u001b[2J\\u0007\\nFORGED/workspace\",\n \"runtimeWorkdir\": \"<isolated-fixture>/café\\u001b[2J\\u0007\\nFORGED/workspace\",\n \"workspaceMounts\": [],\n \"workspaceSource\": \"direct\",\n \"sessionIsSandboxed\": false,\n \"tools\": {\n \"allow\": [\n \"exec\",\n \"process\",\n \"read\",\n \"ls\",\n \"write\",\n \"edit\",\n \"apply_patch\",\n \"view_image\",\n \"github_read\",\n \"github_search\",\n \"github_publish\",\n \"sessions_list\",\n \"sessions_history\",\n \"sessions_search\",\n \"sessions_send\",\n \"sessions_spawn\",\n \"sessions_yield\",\n \"subagents\",\n \"session_status\",\n \"get_goal\",\n \"create_goal\",\n \"update_goal\"\n ],\n \"deny\": [\n \"browser\",\n \"canvas\",\n \"computer\",\n \"mobile_ui\",\n \"nodes\",\n \"automations\",\n \"gateway\",\n \"feishu\",\n \"googlechat\",\n \"nostr\",\n \"buzz\",\n \"msteams\",\n \"mattermost\",\n \"nextcloud-talk\",\n \"matrix\",\n \"raft\",\n \"a2a\",\n \"line\",\n \"zalo\",\n \"clickclack\",\n \"x\",\n \"zalouser\",\n \"sms\",\n \"synology-chat\",\n \"tlon\",\n \"discord\",\n \"imessage\",\n \"irc\",\n \"reef\",\n \"signal\",\n \"slack\",\n \"telegram\",\n \"twitch\",\n \"whatsapp\"\n ],\n \"sources\": {\n \"allow\": {\n \"source\": \"default\",\n \"key\": \"tools.sandbox.tools.allow\"\n },\n \"deny\": {\n \"source\": \"default\",\n \"key\": \"tools.sandbox.tools.deny\"\n }\n }\n }\n },\n \"elevated\": {\n \"enabled\": true,\n \"allowedByConfig\": false,\n \"alwaysAllowedByConfig\": false,\n \"allowFrom\": {},\n \"failures\": []\n },\n \"fixIt\": [\n \"tools.sandbox.tools.allow\",\n \"tools.sandbox.tools.alsoAllow\",\n \"tools.sandbox.tools.deny\",\n \"agents.entries.*.tools.sandbox.tools.allow\",\n \"agents.entries.*.tools.sandbox.tools.alsoAllow\",\n \"agents.entries.*.tools.sandbox.tools.deny\",\n \"tools.elevated.enabled\"\n ]\n}\n", "stderr": "" }, { "label": "normal-workspace-control", "args": [ "sandbox", "explain" ], "code": 0, "stdout": "Effective sandbox:\n agentId: main\n sessionKey: agent:main:main\n mainSessionKey: agent:main:main\n runtime: direct\n mode: off scope: agent\n workspaceAccess: none workspaceRoot: <isolated-fixture>/state/sandboxes\n effectiveHostWorkspaceRoot: <isolated-fixture>/workspace\n backend: docker runtimeWorkdir: <isolated-fixture>/workspace workspaceSource: direct\n\nSandbox tool policy:\n allow (default): exec, process, read, ls, write, edit, apply_patch, view_image, github_read, github_search, github_publish, sessions_list, sessions_history, sessions_search, sessions_send, sessions_spawn, sessions_yield, subagents, session_status, get_goal, create_goal, update_goal\n deny (default): browser, canvas, computer, mobile_ui, nodes, automations, gateway, feishu, googlechat, nostr, buzz, msteams, mattermost, nextcloud-talk, matrix, raft, a2a, line, zalo, clickclack, x, zalouser, sms, synology-chat, tlon, discord, imessage, irc, reef, signal, slack, telegram, twitch, whatsapp\n\nElevated:\n enabled: true\n channel: (unknown)\n allowedByConfig: false\n\nFix-it:\n - tools.sandbox.tools.allow\n - tools.sandbox.tools.alsoAllow\n - tools.sandbox.tools.deny\n - agents.entries.*.tools.sandbox.tools.allow\n - agents.entries.*.tools.sandbox.tools.alsoAllow\n - agents.entries.*.tools.sandbox.tools.deny\n - tools.elevated.enabled\n\nDocs: https://docs.openclaw.ai/sandbox\n\n", "stderr": "" } ], "observations": [ { "controls": 0, "forged": 0, "stdout": "Effective sandbox:\n agentId: main\n sessionKey: agent:main:main\n mainSessionKey: agent:main:main\n runtime: direct\n mode: off scope: agent\n workspaceAccess: none workspaceRoot: <isolated-fixture>/state/sandboxes\n effectiveHostWorkspaceRoot: <isolated-fixture>/café\\nFORGED/workspace\n backend: docker runtimeWorkdir: <isolated-fixture>/café\\nFORGED/workspace workspaceSource: direct\n\nSandbox tool policy:\n allow (default): exec, process, read, ls, write, edit, apply_patch, view_image, github_read, github_search, github_publish, sessions_list, sessions_history, sessions_search, sessions_send, sessions_spawn, sessions_yield, subagents, session_status, get_goal, create_goal, update_goal\n deny (default): browser, canvas, computer, mobile_ui, nodes, automations, gateway, feishu, googlechat, nostr, buzz, msteams, mattermost, nextcloud-talk, matrix, raft, a2a, line, zalo, clickclack, x, zalouser, sms, synology-chat, tlon, discord, imessage, irc, reef, signal, slack, telegram, twitch, whatsapp\n\nElevated:\n enabled: true\n channel: (unknown)\n allowedByConfig: false\n\nFix-it:\n - tools.sandbox.tools.allow\n - tools.sandbox.tools.alsoAllow\n - tools.sandbox.tools.deny\n - agents.entries.*.tools.sandbox.tools.allow\n - agents.entries.*.tools.sandbox.tools.alsoAllow\n - agents.entries.*.tools.sandbox.tools.deny\n - tools.elevated.enabled\n\nDocs: https://docs.openclaw.ai/sandbox\n\n", "jsonPathsUnchanged": true, "realDirectoryReadback": true, "configBytesUnchanged": true, "configHash": "549f8fae7d2152fc7b4121bdb5dd9f00d3d22cad4c7ffc29d78969a5a9d2fad6", "legalWorkspaceControl": true } ], "result": "PASS", "rawReceiptSha256": "18bd3004a6f89fca9bda39345faf11a8930109e9d742058dae4ed2f49b07ef72", "buildStamp": { "builtAt": 1793003812148, "head": "70b78d7a30dbe25fac1d7d7e4d900bc46536bf92", "inputsClean": true, "inputSignature": "db08350500a23229c0efcb7becfa9826b2330cb6078daaa64c49d9d11d669b42" }, "buildCommand": "pnpm build:runtime" }Historical baseline, collector and previous-head observations
Everything below retains its original SHA, timestamp and test counts; it is not the current-head run.
Normal-built CLI, Node 26.1.0 on Linux, isolated HOME/config/state, no external services or production credentials:
e63269c28a22a6eec7c0758d54dc6dbe674e2886(RED run 2026-10-19T01:09:29.619Z).2a30dc5cfb78889c02a308c1e93a68e6240b94ee(GREEN run 2026-10-19T01:37:37.219Z).node <checkout>/openclaw.mjs sandbox explain [--json]; canonical owner:src/commands/sandbox-explain.ts.sandbox explainThe fixture creates a real POSIX directory with
café\x1b[2J\x07\nFORGEDin its name. HEAD prints visiblecafé\nFORGEDin the report;--jsonreturns the unchanged path andfs.statconfirms it is the existing directory. No container needs to run to reproduce this display bug.Controls: 0 unsafe controls and 0 injected lines; two visible escaped newlines; JSON retains both original paths and fs.stat confirms the actual directory; ordinary workspace remains readable; config bytes unchanged.
Focused regressions:
OPENCLAW_VITEST_RUNTIME=node pnpm test src/commands/sandbox-explain.test.ts --maxWorkers=1— 10/10 pass, exit 0; 103.19 s selected shard, 110.60 s including wrapper. Core and canonical commands-test type checks, explicit type-aware lint (including the modified test), format, line-cap ratchet, and independent adversarial review passed. The host's older glibc cannot load tsrs, so type checks used the documentedOPENCLAW_TYPECHECKER=tsgofallback.Generated proof receipt
e63269cand head2a30dc5:node proof-sandbox.mjs <checkout> <red|green>Reproduce the real CLI proof
Install the pinned dependencies in clean checkouts at the SHAs above, then build normally with
pnpm build qaRuntime(used on BASE) orpnpm build cliStartup(used on HEAD; core CLI only). Save the two files below together outside the checkout. The same collector and scenario run on both versions:Invocation form:
node proof-sandbox.mjs <checkout> <red|green>. Only the helper import path is flattened for copying. The collector checks clean Git HEAD against the build stamp and records stdout, stderr, exit status, and readback in its printed temporary receipt directory.proof-sandbox.mjs:proof-cli-common.mjs:Scope and limitations
Two files; production/test LOC (added, removed):
Type-check reuse: the core and commands-test graphs passed at cc10221. The follow-up only renames a local fixture variable and expresses the same ESC/BEL exclusions as string assertions; production is byte-identical. Focused tests, explicit modified-test type-aware lint, formatting and ratchet were rerun; the normal CLI build and behavior proof were rerun at the final head.
Existing-solutions preflight: reused the canonical terminal-core sanitizer; no new abstraction. Sibling coverage: all human value renderer consumers including workspace root, host workspace, runtime workdir, mount paths and tool policy; JSON returns before rendering; trusted headings and enums unchanged.
Not tested: Docker/Podman/remote runtime launches, sandbox enforcement, rich PTY colors, Windows/macOS terminals and full CI suite locally; real filesystem path proof is Linux-only. Fixtures remain in their printed temporary directories for inspection; remove only those generated directories after inspecting them. No production data, existing sessions, channels or service configuration were loaded or changed.