Skip to content

fix(cli): sanitize untrusted pairing request fields before rendering - #175158

Closed
wangmiao0668000666 wants to merge 1 commit into
openclaw:mainfrom
wangmiao0668000666:fix/pairing-report-terminal-controls
Closed

wangmiao0668000666 wants to merge 1 commit into
openclaw:mainfrom
wangmiao0668000666:fix/pairing-report-terminal-controls

Conversation

@wangmiao0668000666

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: openclaw pairing list prints a pending request's sender id verbatim, so an id carrying terminal control sequences (ESC/BEL) changes the operator's terminal while inspecting untrusted senders — requests exist precisely because the sender is not trusted yet.

User Impact

User impact: the pairing table renders every cell literally without control sequences, and --json keeps the raw values for scripts.

Why This Change Was Made

Classification: behavior-completing.

This table is the untrusted-input case the terminal renderer already anticipates: packages/terminal-core/src/table.ts ships renderTerminalSafeTable ("Render untrusted single-line values without changing renderTable's trusted ANSI contract") next to renderTable, and pairing list was the remaining caller feeding remote sender metadata into the trusted renderer. The swap is one call; no new helper, option, or output format.

Precedent: #172872, #172873, #174989 (same shape at other human report boundaries).

Evidence

  • Base a45bf3ceb96, head f799dafc9bfe; secretless Linux container, Node 24.18.0, isolated HOME/OPENCLAW_STATE_DIR.
  • Fixture: two pending telegram requests created through the production ingress owner upsertChannelPairingRequest — one with meta.senderId = "snd\u001b]0;pwned\u0007PAIR_MARKER", one plain.
  • Real entry, identical command on both revisions: node --import ./scripts/tsx.mjs src/entry.ts pairing list --channel telegram
base this head
rendered telegramUserId cell snd]0;pwnedPAIR_MARKER sndPAIR_MARKER
unsafe control chars in the report (C0 minus tab/LF/CR, DEL, C1) 2 (0x1b, 0x07) 0
plain request row plain-sender plain-sender (unchanged)

The --json branch returns { channel, requests } before the table is built, so structured output is untouched by this diff.

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

base:  × strips terminal controls from pairing ids and metadata
       AssertionError: expected 'Pairing requests (2)…' not to match /\p{Cc}/u
head:  ✓ strips terminal controls from pairing ids and metadata

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

Not tested: requests whose code or requested timestamps are remote-controlled (both are generated locally by the pairing owner).

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

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: XS r: too-many-prs Auto-close: author has more than twenty active PRs. labels Oct 17, 2026
@openclaw-barnacle

Copy link
Copy Markdown

Closing this PR because the author has more than 20 active PRs in this repo. Please reduce the active PR queue and reopen or resubmit once it is back under the limit. You can close your own PRs to get back under the limit.

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

Labels

cli CLI command changes r: too-many-prs Auto-close: author has more than twenty active PRs. size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant