Repository navigation
fix(cli): prevent descriptor controls in skill and hook reports - #172872
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 skill and hook metadata before human-readable CLI rendering while preserving existing JSON behavior. Example: An installed hook description contains "Readable\u001b[2J description", and the user runs
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a concrete terminal-rendering defect still present on main; the prior test-type finding is resolved, and no actionable introduced bugs remain. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherSkill and hook loaders produce raw inventory reports; CLI formatters turn those reports into styled terminal text or JSON. flowchart LR
A[Installed descriptors] --> B[Discovery and status owners]
B --> C[CLI report commands]
C --> D[Human text sanitization]
D --> E[Trusted styling and terminal output]
C --> F[Existing JSON serialization]
Technical reviewBest possible solution: Merge the focused presentation-boundary repair once existing checks pass, retaining raw descriptors and the established JSON contracts. Do we have a high-confidence way to reproduce the issue? The unsanitized interpolation paths remain on current main, and supplied built-CLI comparisons demonstrate actual OSC, CSI, and C1 emission from installed descriptors; no target code was executed during this review. Is this the best way to solve the issue? The patch uses existing terminal sanitizers at human presentation boundaries, preserves trusted styling and descriptor data, and shares the historical whitespace-preserving implementation without introducing another parser or state owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against cba956feca63. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +20, Tests +133, Docs +7. Total +160 across 8 files. Added test files: 1. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. 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 HistoryReviewed October 22, 2026, 7:45 PM ET / 23:45 UTC (Revision 3). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Exact head d205ee1: real CLI-created agent/workspace plus shipped local skill/hook installation, not constructed report objects. Raw stdout bytes show actual OSC8/BEL/CSI/C1 controls in main skill/hook list/info/check reports (lists twice), and0 in candidate no-color human reports. Forced-color candidate retains exactly50 skill/30 hook SGR sequences while removing hostile controls. All6 decoded JSON reports equal main after only task-root normalization, preserving existing skill normalization and original hook values; clean Unicode/whitespace controls and input bytes unchanged.35 focused tests, formatting/lint pass. Supporting gpt-5-mini agent smoke returned CLI_LIVE_OK; credential removed. Shared diagnostic construction remains raw, with sanitation only at human presentation boundaries. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Head 6b0b3a8 fixes the hosted test-type error by removing the regression’s obsolete managedHooksDir option. That option was ignored at runtime; production code and causal proof inputs are unchanged. The corrected hook suite passes12 tests, with formatting/lint passing; the prior four-suite35-test result and installed-loader stdout/JSON/color comparisons remain applicable. A fresh bounded real-provider smoke on this head returned CLI_LIVE_OK using a per-PR-only proof mount and key cleanup. No CI jobs were rerun; this is a committed test API repair. |
|
Merged—thank you @Alix-007 for the descriptor terminal-safety repair. Built installed-loader proof confirmed human controls are neutralized while the six JSON reports, normal Unicode/whitespace, and trusted styling retain their contracts. |
…claw#172872) fix(skills): strip terminal control sequences from skill and hook text in human reports Strings from installed skills and hooks (names, descriptions, paths) were printed raw in the human-readable skills and hooks list, info and check reports, so an installed skill or hook could put terminal control sequences into your terminal. Human reports now pass those strings through the shared terminal-safe text owner, keeping OpenClaw's own colors; JSON reports are unchanged. Evidence: built CLI with a skill and a hook installed through the shipped agents add, skills install and plugins hook install commands. On main the six human reports contained 18/24/12 controls for skills and 18/30/12 for hooks, including OSC 8, CSI and C1 (twice); with this change they contain none, OpenClaw's own colors stay, and all six JSON reports are identical. Production +69/-49. Thanks @Alix-007. Co-authored-by: Ayaan Zaidi <[email protected]>
#172872 wrapped hooks read failures in the single-line terminal sanitizer, so owner remedies such as the remote-Gateway "Config:/Fix:" lines reached stderr as literal \n escapes while the JSON envelope kept real newlines. Sanitize each line instead: controls are still stripped, line breaks stay.
openclaw#172872 wrapped hooks read failures in the single-line terminal sanitizer, so owner remedies such as the remote-Gateway "Config:/Fix:" lines reached stderr as literal \n escapes while the JSON envelope kept real newlines. Sanitize each line instead: controls are still stripped, line breaks stay.
|
Thanks @obviyus for the extra verification and for landing this! |
What Problem This Solves
Installed skill and hook descriptor strings can inject terminal controls into human
list,info, andcheckreports. Descriptions, emoji, and missing requirements can clear the screen or open an OSC 8 hyperlink instead of remaining display text.Changes
Neutralize untrusted values before trusted styling, using the existing terminal-core single-line sanitizer. Share the existing whitespace-preserving skill descriptor sanitizer with hook rendering rather than introducing another ANSI parser. Keep descriptor/report objects and the existing JSON paths unchanged.
Thanks to @Alix-007 for the repair and regressions; their commits are retained. Current main's inline skill-name rendering is preserved instead of restoring a removed helper.
Evidence
Built main
722ad802bc2801eadd83c8b484cd9715480b1f97and candidate independently in isolated Node 24.22.1 Linux Docker. Created an agent/workspace throughagents add; installed valid external skill directories throughskills install, and external hook descriptors throughplugins install --link --force. No internal report objects or databases were seeded. Descriptor metadata contains escaped OSC/CSI/C1 values which the real loaders decode into actual terminal-control characters.Captured raw stdout/stderr bytes from the built shipped CLI, initially with trusted color disabled:
skills list --verbose, twiceskills infoskills checkhooks list --verbose, twicehooks infohooks checkThe sequences include real ESC clear-screen, OSC 8/BEL links, and C1 controls—not literal backslash output. Readable names/markers remain. With trusted color forced on, candidate info reports retain exactly the same 50 skill / 30 hook SGR styling sequences, while removing the hostile OSC/clear-screen/C1 controls.
All six decoded JSON reports are equal across arms after normalizing only task-root paths. This preserves the preexisting distinction: skill JSON already normalizes terminal controls, while hook JSON retains original descriptor values. Normal Unicode/emoji clean-info controls are unchanged after task root/profile normalization; ordinary hook-description line breaks/tabs and JSON description whitespace are preserved. Independent input-file readback confirms descriptor bytes were never changed.
All 35 focused discovery/formatter/hook tests pass; changed-file formatting and lint pass.
The change reuses existing presentation owners and keeps diagnostic construction raw until the human-output boundary. Redundant sanitation and per-entry sanitizer arrays in compact hook output are removed. Whole PR production +69/-49 (net +20, 118 changed lines), tests +134/-1, plus documentation. There is no shim, SDK, schema, configuration, permission, or authorization change.
Merge danger: two-way presentation change, no state migration. Blast radius is human skill/hook reporting and descriptor-bearing human errors; existing JSON data/shapes and trusted styling retain their behavior.