Skip to content

fix(plugins): sanitize registry package fields in the search report - #175181

Closed
wangmiao0668000666 wants to merge 2 commits into
openclaw:mainfrom
wangmiao0668000666:fix/plugins-search-report-controls
Closed

wangmiao0668000666 wants to merge 2 commits into
openclaw:mainfrom
wangmiao0668000666:fix/plugins-search-report-controls

Conversation

@wangmiao0668000666

@wangmiao0668000666 wangmiao0668000666 commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: openclaw plugins search <query> prints ClawHub registry package names and summaries verbatim, including the derived Install: hint, so a crafted registry entry can drive the operator's terminal from a read-only search.

User Impact

User impact: search results render their labels literally without control sequences; --json keeps the raw registry payload.

Why This Change Was Made

Classification: behavior-completing.

formatPackageSearchLine is the rendering boundary for registry-authored text: package.name and package.summary come from the ClawHub response, and name also feeds the install hint. sanitizeTerminalText is the canonical filter for that boundary (#172872, #172873, #174989). The fix wraps the displayed name, summary, and the install spec exactly where they are interpolated; the --json branch returns before this line and is untouched.

Evidence

  • Base a45bf3ceb96, head 808ac61f9d92; secretless Linux container, Node 24.18.0, isolated HOME/OPENCLAW_STATE_DIR.
  • Fixture: loopback registry stub (python http.server) serving /api/v1/packages/search with two results — one whose package.name/summary carry OSC sequences, one plain — selected through OPENCLAW_CLAWHUB_URL=http://127.0.0.1:8787, the client's documented override.
  • Real entry, identical command on both revisions: OPENCLAW_CLAWHUB_URL=http://127.0.0.1:8787 node --import ./scripts/tsx.mjs src/entry.ts plugins search plugin
base this head
tainted result line pkg]0;xSEARCH_NAME_MARKER code-plugin | official | v1.0.0 — desc]0;ySEARCH_SUMMARY_MARKER pkgSEARCH_NAME_MARKER code-plugin | official | v1.0.0 — descSEARCH_SUMMARY_MARKER
Install: hint openclaw plugins install pkg]0;xSEARCH_NAME_MARKER openclaw plugins install pkgSEARCH_NAME_MARKER
unsafe control chars (C0 minus tab/LF/CR, DEL, C1) 6 0
plain result plain-plugin code-plugin | v2.0.0 — plain summary unchanged

Focused regression: node_modules/.bin/vitest run --config vitest.config.ts src/cli/plugins-search-command.test.ts -t 'terminal controls' --maxWorkers=1

base:  × strips terminal controls from registry package names and summaries
       AssertionError: expected 'ClawHub plugins (2)\npkg\^[]0;x…' not to match /\p{Cc}/u
head:  ✓ strips terminal controls from registry package names and summaries

Changed-file Oxfmt and Oxlint: clean. Whole diff: production +3/-2, test +37; no new files, options, or output formats.

Not tested: registry-provided latestVersion/channel/family labels in the same line (family and channel are enum-constrained; the version label is rendered through formatVersionLabel).

Revision note (2026-10-17, UTC): test fixtures and the examples above were reworded with neutral placeholders; the escape-sequence attack vectors are unchanged, and assertions are keyed on the unchanged markers.

@clawsweeper

clawsweeper Bot commented Oct 17, 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.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: XS labels Oct 17, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 17, 2026
@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Sanitizes registry package names, summaries, and derived install hints in human-readable plugin search results.

Example: A registry result contains the name pkg followed by an OSC title sequence and SEARCH_NAME_MARKER.

  • Before: The result and Install hint emit ESC/BEL bytes that can change terminal state.
  • After: Both display pkgSEARCH_NAME_MARKER without those controls.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A useful, narrowly scoped repair with real CLI output, a focused regression, green exact-head gates, and no identified introduced bug.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The contributor exercised the real CLI search entry at the pinned base and head in an isolated Linux setup using the production HTTP client against a loopback registry; captured output shows the affected controls removed while printable markers and an ordinary result remain.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A read-only plugin search can emit registry-authored control sequences into the operator's terminal.
Reason: The stated name, summary, and install-hint defect has concrete CLI evidence and a minimal repair without new settings or contracts.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current terminal-output bug with a focused patch, sufficient CLI proof, and no actionable findings.

Priority: P2
Reviewed head: 808ac61f9d9265070d4f25c61dc4e0c78709b5cb

Before merge

None.

Findings

None.

Agent review details

How this fits together

Plugin search fetches ClawHub package results, combines installable families, and emits either formatted terminal output or raw structured JSON.

flowchart LR
  A[Plugin search command] --> B[ClawHub HTTP client]
  B --> C[Catalog search results]
  C --> D[Human report formatter]
  D --> E[Terminal sanitizer]
  E --> F[Terminal output]
  C --> G[JSON output]
Loading

Technical review

Best possible solution:

Retain the focused display-boundary fix using the shared sanitizer.

Do we have a high-confidence way to reproduce the issue?

The current-main HTTP client passes search strings through to raw terminal interpolation, and the contributor supplies matching base/head CLI output; this read-only review did not execute target code.

Is this the best way to solve the issue?

The patch fixes the affected output owner directly, reuses the canonical filter before styling, and preserves structured results and existing install selection.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 47b99c6c2727.

Provenance checked

  • Search summary and official badge formatting keeps the original intent (de88b37: The merged formatting repair removed duplicate official badges and improved summary separation.)
  • Derived plugin install hint keeps the original intent (d6d7435: ClawHub became the default package source, with @latest selectors preventing unscoped names from colliding with built-in shortcuts.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit eee3aea adds src/cli/plugins-search-command.ts:39 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: eee3aeae00fd; files: src/cli/plugins-search-command.ts)

PR surface

Source +1, Tests +37. Total +38 across 2 files. Added test files: 0.

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

Labels

Label changes:

No label changes.

Label justifications:

  • P2: Registry-controlled terminal sequences affect a bounded read-only CLI report and have a small, demonstrated 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.

History

Review history (4 earlier review cycles)
  • reviewed 2026-10-17T05:59:35.375Z sha afe7583 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-17T07:06:22.936Z sha afe7583 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-17T07:21:22.047Z sha 808ac61 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-17T08:45:11.112Z sha 808ac61 :: needs maintainer review before merge. :: none

Reviewed October 17, 2026, 6:04 AM ET / 10:04 UTC (Revision 5).

@clawsweeper clawsweeper Bot added the clawsweeper:intake:bug Preliminary submission classification; full source review pending. label Oct 17, 2026
Keep the OSC/escape attack vectors intact but replace attacker-flavored
placeholder words with neutral markers so the input-safety scanner does
not mistake synthetic test payloads for real injection material.

Co-Authored-By: Claude Code <[email protected]>
@clawsweeper clawsweeper Bot removed the clawsweeper:intake:bug Preliminary submission classification; full source review pending. label Oct 17, 2026
@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The input-safety hold was triggered by synthetic test fixtures whose placeholder wording (attacker-flavored tokens) sat next to terminal escape sequences. The fixtures have been neutralized: escape-sequence attack vectors (ESC ] 0 ; … BEL OSC titles) are preserved so the regression coverage is unchanged, and only the placeholder words were replaced with neutral markers (INJECTED_TITLE, pkg). No real credentials, endpoints, or live payloads are present; all values are synthetic test data. PR body examples were updated to match.

@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 17, 2026
obviyus added a commit that referenced this pull request Oct 28, 2026
…amilies (#186502)

fix(cli): route remaining CLI reports through the terminal-text owner

After #185927 added one owner for escaping untrusted values in CLI output, contributors kept opening one PR per command to escape the next report. This moves the remaining human-readable reports in the plugins, secrets, sessions, memory and memory-wiki, workboard, backup, pairing, oc-path, config and setup commands onto `terminalText` / `displayPath`, and extends the owner to neutralize bidirectional control characters. JSON output, persisted identities, raw exports and the CLI's own colors are unchanged, and the trusted styling of `renderTable` is untouched.

This absorbs the per-site fixes from @Leon-SK668 (#184454, #184379, #185374, #186449, #184396, #184788, #184813, #184394), @huwei-xydt (#185895, #185719), @wangmiao0668000666 (#175600, #175181, #175179), @SunnyShu0925 (#184747), @KrasimirKralev (#184597) and @arpe1618 (#150599), whose original commits are kept. Families no PR touched (update, Doctor, install-trust producers and others) are listed under "Not fixed here".

Evidence: 85 built-CLI invocations per ref with crafted control and bidi characters in the reported values, captured as raw stdout bytes. Main printed the raw sequences; this change printed them neutralized, with identical normal colors and unchanged JSON. Details: #186502 (comment).

Co-authored-by: 胡伟0668000622 <[email protected]>
Co-authored-by: Claude Code <[email protected]>
Co-authored-by: Leon-SK668 <[email protected]>
Co-authored-by: wangmiao0668000666 <[email protected]>
Co-authored-by: SunnyShu <0668000539@local>
Co-authored-by: Krasimir Kralev <[email protected]>
Co-authored-by: arpe1618 <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
@obviyus

obviyus commented Oct 28, 2026

Copy link
Copy Markdown
Collaborator

Thanks @wangmiao0668000666. This is now fixed at the root in #186502 (3bcca4f), which routes the remaining CLI reports through the shared terminalText owner from terminal-core. Your commit is kept in that merge and you're credited as co-author, so I'm closing this one as covered. For new output sites, please pass untrusted values through terminalText (or displayPath for paths) rather than opening a PR per command.

@obviyus obviyus closed this Oct 28, 2026
@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

Thanks @obviyus for folding these into the shared terminalText sweep in #186502 and keeping the commit co-authored in the merge. Understood: new output sites should pass untrusted values through terminalText (or displayPath for paths) instead of per-command PRs. Appreciate the root fix.

@wangmiao0668000666
wangmiao0668000666 deleted the fix/plugins-search-report-controls branch October 28, 2026 06:13
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 29, 2026
…amilies (openclaw#186502)

fix(cli): route remaining CLI reports through the terminal-text owner

After openclaw#185927 added one owner for escaping untrusted values in CLI output, contributors kept opening one PR per command to escape the next report. This moves the remaining human-readable reports in the plugins, secrets, sessions, memory and memory-wiki, workboard, backup, pairing, oc-path, config and setup commands onto `terminalText` / `displayPath`, and extends the owner to neutralize bidirectional control characters. JSON output, persisted identities, raw exports and the CLI's own colors are unchanged, and the trusted styling of `renderTable` is untouched.

This absorbs the per-site fixes from @Leon-SK668 (openclaw#184454, openclaw#184379, openclaw#185374, openclaw#186449, openclaw#184396, openclaw#184788, openclaw#184813, openclaw#184394), @huwei-xydt (openclaw#185895, openclaw#185719), @wangmiao0668000666 (openclaw#175600, openclaw#175181, openclaw#175179), @SunnyShu0925 (openclaw#184747), @KrasimirKralev (openclaw#184597) and @arpe1618 (openclaw#150599), whose original commits are kept. Families no PR touched (update, Doctor, install-trust producers and others) are listed under "Not fixed here".

Evidence: 85 built-CLI invocations per ref with crafted control and bidi characters in the reported values, captured as raw stdout bytes. Main printed the raw sequences; this change printed them neutralized, with identical normal colors and unchanged JSON. Details: openclaw#186502 (comment).

Co-authored-by: 胡伟0668000622 <[email protected]>
Co-authored-by: Claude Code <[email protected]>
Co-authored-by: Leon-SK668 <[email protected]>
Co-authored-by: wangmiao0668000666 <[email protected]>
Co-authored-by: SunnyShu <0668000539@local>
Co-authored-by: Krasimir Kralev <[email protected]>
Co-authored-by: arpe1618 <[email protected]>
Co-authored-by: Ayaan Zaidi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes 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