Skip to content

fix(setup): escape terminal controls in directory confirmations - #184666

Closed
Alix-007 wants to merge 1 commit into
openclaw:mainfrom
Alix-007:fix/alix-setup-terminal-paths-20261026
Closed

Alix-007 wants to merge 1 commit into
openclaw:mainfrom
Alix-007:fix/alix-setup-terminal-paths-20261026

Conversation

@Alix-007

Copy link
Copy Markdown
Contributor

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 1b6eb7b and head 38f683e: node proof-setup.mjs "$CHECKOUT" "$PHASE"

    • Before (base): RED workspace completion: controls=3, forgedRow=true, escapedNewline=false; session completion: controls=3, forgedRow=true, escapedNewline=false
    • After (head): GREEN workspace completion: controls=0, forgedRow=false, escapedNewline=true; session completion: controls=0, forgedRow=false, escapedNewline=true
  • 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 field unexpectedConfigWrites records 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 run node proof-setup.mjs "$CHECKOUT" red on the pinned base or green on this head. Collectors only use their own synthetic temporary directories.

proof-common.mjs:

import assert from 'node:assert/strict';
import fs from 'node:fs';
import os from 'node:os';
import path from 'node:path';
import {createHash} from 'node:crypto';
import {execFileSync, spawn} from 'node:child_process';

export const unusual = 'café\x1b[31m\noperator-forged\tend\rrow\x07';

export function fixture(name) {
 const checkout=path.resolve(process.argv[2]);
 const phase=process.argv[3];
 assert.ok(['red','green'].includes(phase));
 const head=execFileSync('git',['rev-parse','HEAD'],{cwd:checkout,encoding:'utf8'}).trim();
 assert.equal(execFileSync('git',['status','--porcelain'],{cwd:checkout,encoding:'utf8'}).trim(),'');
 const stamp=JSON.parse(fs.readFileSync(path.join(checkout,'dist/.buildstamp')));
 assert.equal(stamp.head,head);
 assert.equal(stamp.inputsClean,true);
 const root=fs.mkdtempSync(path.join(os.tmpdir(),`alix-escape-${name}-`));
 for(const leaf of ['home','state','workspace','tmp'])fs.mkdirSync(path.join(root,leaf));
 const configPath=path.join(root,'openclaw.json');
 const config={agents:{ownership:'explicit',defaults:{systemAgent:{agentId:'main'}},entries:{main:{workspace:path.join(root,'workspace')}}},tools:{profile:'minimal'},plugins:{allow:[],slots:{memory:'none'}},logging:{level:'warn',consoleLevel:'warn',file:path.join(root,'runtime.log')}};
 const writeConfig=()=>fs.writeFileSync(configPath,JSON.stringify(config),{mode:0o600});
 writeConfig();
 const env={PATH:`${path.dirname(process.execPath)}:/usr/bin:/bin`,HOME:path.join(root,'home'),TMPDIR:path.join(root,'tmp'),LANG:'C.UTF-8',TZ:'UTC',TERM:'dumb',NO_COLOR:'1',COLUMNS:'320',CI:'1',DO_NOT_TRACK:'1',OPENCLAW_CONFIG_PATH:configPath,OPENCLAW_STATE_DIR:path.join(root,'state'),OPENCLAW_NO_RESPAWN:'1',OPENCLAW_DISABLE_BONJOUR:'1'};
 const receipt={name,phase,head,at:new Date().toISOString(),root,runs:[],observations:[],readback:{}};
 const save=()=>fs.writeFileSync(path.join(root,'receipt.json'),JSON.stringify(receipt,null,2));
 async function command(label, executable, args, options={}){
  const started=performance.now();
  const row=await new Promise((resolve,reject)=>{
   const child=spawn(executable,args,{cwd:checkout,env:{...env,...options.env},stdio:['ignore','pipe','pipe']});
   let stdout='',stderr='';
   const timer=setTimeout(()=>child.kill('SIGKILL'),90000);
   child.stdout.setEncoding('utf8').on('data',x=>{stdout+=x;});
   child.stderr.setEncoding('utf8').on('data',x=>{stderr+=x;});
   child.on('error',reject);
   child.on('close',(code,signal)=>{clearTimeout(timer);resolve({label,args,code,signal,stdout,stderr,seconds:(performance.now()-started)/1000});});
  });
  receipt.runs.push(row);save();
  assert.equal(row.signal,null,`${label}: setup/timeout is not product RED`);
  assert.equal(row.code,options.exit??0,`${label}: ${row.stderr}`);
  return row;
 }
 const run=async(label,args,options)=>command(label,process.execPath,[path.join(checkout,'openclaw.mjs'),...args],options);
 function text(label,output,options={}){
  const controls=[...output.matchAll(/[\x00-\x08\x0b-\x1f\x7f-\x9f]/g)].length;
  const forgedLine=output.includes('\noperator-forged');
  const observation={label,controls,forgedLine,escapedLine:output.includes('\\noperator-forged'),unicode:output.includes('café')};
  receipt.observations.push(observation);save();
  assert.equal(controls>0,phase==='red',`${label}: control result`);
  if(!options.table)assert.equal(forgedLine,phase==='red',`${label}: injected report row`);
  assert.equal(observation.unicode,true,`${label}: Unicode control`);
  if(phase==='green')assert.equal(observation.escapedLine,true,`${label}: retain visible escaped line`);
 }
 function finish(){receipt.result='PASS';save();console.log(JSON.stringify({name,phase,head,result:'PASS',receipt:path.join(root,'receipt.json'),observations:receipt.observations,readback:receipt.readback}));}
 return {checkout,root,configPath,config,writeConfig,env,receipt,run,command,text,save,finish,hash:bytes=>createHash('sha256').update(bytes).digest('hex')};
}

proof-setup.mjs:

import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import { fixture, unusual } from './proof-common.mjs';

const f = fixture('setup-paths');
const workspace = path.join(f.root, `workspace-${unusual}`);
const state = path.join(f.root, `state-${unusual}`);
f.config.agents.entries.main.workspace = workspace;
f.config.agents.defaults.skipBootstrap = true;
f.config.gateway = { mode: 'local' };
f.writeConfig();
const before = fs.readFileSync(f.configPath);
const env = { OPENCLAW_STATE_DIR: state };
const human = await f.run('setup-human', ['setup', '--baseline'], { env });
const workspaceLine = human.stdout.split('Workspace OK: ')[1]?.split('Sessions OK: ')[0];
const sessionsLine = human.stdout.split('Sessions OK: ')[1]?.split('Setup complete: ')[0];
assert.ok(workspaceLine && sessionsLine, 'actual setup must reach both completion reports');
f.text('workspace completion', workspaceLine);
f.text('session completion', sessionsLine);
assert.ok(fs.statSync(workspace).isDirectory());
const sessionsDir = path.join(state, 'agents', 'main', 'sessions');
assert.ok(fs.statSync(sessionsDir).isDirectory());
const json = await f.run('setup-json', ['setup', '--baseline', '--json'], { env });
const payload = JSON.parse(json.stdout);
assert.equal(payload.ok, true);
assert.equal(payload.configStatus, 'unchanged');
assert.equal(payload.workspaceDir, workspace);
assert.equal(payload.sessionsDir, sessionsDir);
assert.deepEqual(fs.readFileSync(f.configPath), before);
const ordinaryWorkspace = path.join(f.root, 'ordinary-workspace');
f.config.agents.entries.main.workspace = ordinaryWorkspace;
f.writeConfig();
const ordinaryBefore = fs.readFileSync(f.configPath);
const ordinary = await f.run('ordinary-control', ['setup', '--baseline']);
assert.ok(ordinary.stdout.includes(`Workspace OK: ${ordinaryWorkspace}\n`));
assert.ok(ordinary.stdout.includes(`Sessions OK: ${path.join(f.env.OPENCLAW_STATE_DIR, 'agents', 'main', 'sessions')}\n`));
assert.equal(/[\x00-\x08\x0b-\x1f\x7f-\x9f]/.test(ordinary.stdout), false);
assert.ok(fs.statSync(ordinaryWorkspace).isDirectory());
assert.deepEqual(fs.readFileSync(f.configPath), ordinaryBefore);
f.receipt.readback = { rawWorkspaceExists: true, rawSessionDirectoryExists: true, jsonRawPathsPreserved: true, configBytesUnchanged: true, unexpectedConfigWrites: 0, ordinaryControlPass: true };
f.finish();

@clawsweeper

clawsweeper Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@Alix-007
Alix-007 marked this pull request as ready for review October 26, 2026 13:18
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation commands Command implementations size: XS labels Oct 26, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 26, 2026
@clawsweeper

clawsweeper Bot commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This 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.

  • Before: The completion report emits terminal controls and displays operator-forged on a separate row.
  • After: The report strips ANSI controls and displays the newline as literal \n while filesystem and JSON paths retain their original values.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused, useful repair with exact-head CLI evidence, meaningful boundary coverage, passing CI gate, and no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The inspected PR body supplies built openclaw.mjs setup --baseline traces on the exact base and head in isolated Linux fixtures: both completion rows lose terminal controls and forged lines while raw directories, JSON paths, config bytes, Unicode, and ordinary-path output remain intact.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Unusual directory names can execute terminal controls or forge extra rows in successful baseline setup reports.
Reason: The change restores safe single-line reporting through an established sanitizer without rejecting valid paths or altering setup behavior.

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
Reviewed head: 38f683e9a95800ce5c5bf53dbfe20a7e250a4f63

Before merge

None.

Findings

None.

Agent review details

How this fits together

The 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]
Loading

Technical review

Best 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

  • Workspace completion and JSON output keeps the original intent (1cbe674: The earlier CLI repair separated human completion reports from structured JSON output; this patch preserves that distinction and all raw JSON values.)
  • Session-directory completion report keeps the original intent (694ca50: Supplied provenance associates this line with restoration of filesystem state after the SQLite refactor revert; sanitizing its display leaves directory creation and storage ownership intact.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Exact introduced patch: The production change imports the existing sanitizer and applies it only to the two completion-path interpolations; filesystem operations and JSON values are unchanged. (src/commands/setup.ts:264, 38f683e9a958)
  • Current main remains affected: Current main interpolates shortened workspace and session paths directly into runtime.log without sanitization. (src/commands/setup.ts:263, a9464aeba651)
  • Existing transformation owner: sanitizeTerminalText strips ANSI sequences and removes control characters while rendering carriage returns, newlines, and tabs as visible escapes. (packages/terminal-core/src/safe-text.ts:11, 38f683e9a958)
  • Shipped CLI behavior proof: The full PR body and collectors were inspected. Captured built-CLI runs on the pinned base and head show both completion rows changing from three controls and a forged row to zero controls and visible newline escapes; independent readback preserves raw directories, JSON paths, config bytes, Unicode, and ordinary-path output. (38f683e9a958)
  • Focused regression coverage: The added production-owner regression checks both completion rows, actual directory existence, unchanged JSON paths, and exact config-byte preservation using the existing fixture. (src/commands/setup.test.ts:75, 38f683e9a958)
  • History and ownership: Feature history identifies Peter Steinberger’s setup ownership and JSON-output work and Vincent Koc’s baseline skip-bootstrap repair. Blame verifies surviving lines from both contributors. Some deeper historical blobs were unavailable in the partial clone; supplied provenance and readable history cover the changed reports. (src/commands/setup.ts:259, a9464aeba651)

Likely related people:

  • Peter Steinberger: Raw commit 1cbe674 adds src/commands/setup.ts:287 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 1cbe674d6a6d; files: src/commands/setup.ts)

PR surface

Source +1, Tests +36, Docs +3. Total +40 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 3 2 +1
Tests 1 36 0 +36
Docs 1 3 0 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 42 2 +40

Review metrics

Metric Value Why it matters
Production versus test LOC Production +3/-2; tests +36/-0 The small production change reuses the canonical sanitizer; one integrated regression protects rendering and raw-path preservation without new production scaffolding.

Labels

Label changes:

  • add P2: Control-bearing POSIX directory names can manipulate baseline setup’s terminal reports, with limited impact and a narrow repair.
  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: Control-bearing POSIX directory names can manipulate baseline setup’s terminal reports, with limited impact and a narrow repair.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 26, 2026, 9:36 AM ET / 13:36 UTC.

obviyus added a commit that referenced this pull request Oct 27, 2026
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]>
@obviyus

obviyus commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

Thanks @Alix-007. This is now fixed at the root in #185927 (2d2b465): one terminalText owner in terminal-core's safe-text escapes untrusted values for all CLI human output, replacing the per-site wrapping. Your commit from this PR is kept in that merge and you're credited as co-author, so I'm closing this one as covered. For future output sites, please route values through terminalText (or displayPath for paths) instead of opening a PR per call site.

@obviyus obviyus closed this Oct 27, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 28, 2026
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]>
@Alix-007

Copy link
Copy Markdown
Contributor Author

Thanks @obviyus for consolidating this! Appreciate the guidance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants