Repository navigation
fix(cli): sanitize stored strings in directory, cron show, agents, channels, and sessions output - #123797
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
d50b665 to
d5e1969
Compare
|
Codex review: found issues before merge. Reviewed August 14, 2026, 3:28 PM ET / 19:28 UTC. ClawSweeper reviewWhat this changesThis PR sanitizes several stored or plugin-provided values in human-readable CLI output while retaining raw JSON output. Merge readinessKeep open: the prior P1 remains unresolved because channel-status errors and warnings still reach human terminal output without sanitization. Priority: P1 Review scores
Verification
How this fits togetherCLI commands format stored configuration, plugin metadata, and Gateway status into either terminal text or JSON. The changed terminal formatting paths feed operator-facing inspection commands, while JSON remains the machine-readable path. flowchart LR
A[Stored config and plugin data] --> C[CLI formatters]
B[Gateway status payload] --> C
C --> D[Labels and status fragments]
D --> E[Human terminal output]
C --> F[JSON output]
Before merge
Findings
Agent review detailsSecurityNeeds attention: The branch improves terminal safety but leaves reachable channel-status text unsanitized. PR surfaceSource +11, Tests +265. Total +276 across 15 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Complete the channel text boundary by sanitizing dynamic bit values and Gateway-only warning or issue fields before human rendering, preserving raw JSON exactly. Do we have a high-confidence way to reproduce the issue? Yes—source-reproducible with high confidence: hostile stateReason, lastError, or Gateway warning text is interpolated into human output without the sanitizer; no live command was run in this read-only review. Is this the best way to solve the issue? No—the label-only repair is too narrow. Sanitizing dynamic values at the shared status-fragment and Gateway-rendering boundaries preserves intentional styling and JSON while covering the remaining injection paths. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 3289e08c3005. LabelsLabel justifications:
EvidenceSecurity concerns:
What I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
…annels, and sessions output (openclaw#123797) * fix(cli): sanitize stored strings in table surfaces * fix(cli): use resolved identity agent id * test(cli): keep cron delivery status typed * test(cli): assert agent JSON non-sanitization without path equality
What Problem This Solves
Completes the terminal-injection perimeter opened by #123671. That PR added
renderTerminalSafeTableand fixed the exec-approvals tables, but the same asymmetry remained on every sibling surface:cron listsanitized stored strings while its siblings interpolated them raw into terminal output.Stored or peer-controlled values containing raw ANSI, OSC/BEL, backspace, carriage-return, or embedded newlines reached the operator's terminal unsanitized on:
openclaw directory(self/peers/groups/members) — plugin-provided ids and namesopenclaw cron show— job/owner/model/delivery/error/diagnostic values (exact sibling asymmetry tocron list, same file)openclaw agents list/--bindings/agents set-identityecho — agent id, identity name, workspace path, modelopenclaw channels list/channels status— account and channel display namesopenclaw sessionslistings and cleanup dry-run — session ids, keys, models, policy keysRaw escapes from stored data are a real terminal-injection vector: cursor manipulation, terminal-title spoofing, and line-erasure concealment of what the operator is actually approving or inspecting.
Why This Change Was Made
One canonical flow, per Repair Doctrine. Rather than adding per-command scrubbers, every surface now routes through the boundary that already exists:
directory) swaprenderTable→renderTerminalSafeTable(added in fix(cli): approval listings no longer execute stored terminal escapes #123671).sanitizeTerminalTexthelper at the value-interpolation boundary — incron showvia a localshowValuethat also folds in the existingstringifyCellnull handling, replacing hand-rolled?? "-"chains.renderTableitself is untouched, so its deliberate trusted-ANSI / OSC-link / multiline contract (asserted bypackages/terminal-core/src/table.test.ts) still holds for styled consumers. JSON output is untouched on every surface and stays byte-exact.User Impact
Operators inspecting cron jobs, agents, channels, directory entries, or sessions can no longer have their terminal manipulated by strings that arrived through a plugin, a peer, or an earlier agent run. Printable Unicode still renders; CR/LF/tab become visible escapes. Machine-readable
--jsonoutput is unchanged, so scripts are unaffected.Evidence
node scripts/run-vitest.mjs src/cli/directory-cli.test.ts src/cli/cron-cli/shared.test.ts src/commands/agents.commands.list.test.ts src/commands/channels.list.test.ts src/commands/sessions.test.ts src/commands/agents.identity.test.tscron list(src/cli/cron-cli/shared.ts) and the approvals tables from fix(cli): approval listings no longer execute stored terminal escapes #123671.src/commands/message-format.ts,src/cli/logs-cli.ts,src/commands/channels/logs.ts.Follow-up to #123671.