Skip to content

fix(cli): strip bidirectional controls from the pending-pairing table - #150599

Open
arpe1618 wants to merge 1 commit into
openclaw:mainfrom
arpe1618:improve/terminal-bidi-sanitize
Open

arpe1618 wants to merge 1 commit into
openclaw:mainfrom
arpe1618:improve/terminal-bidi-sanitize

Conversation

@arpe1618

@arpe1618 arpe1618 commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

A node sets its own displayName in the pairing request. openclaw nodes status
renders it verbatim in the pending-request table an operator reads to approve the
device (renderPendingPairingRequestsTable). sanitizeTerminalText escapes C0/C1
controls but passes bidirectional formatting controls through: overrides
(U+202A-202E), isolates (U+2066-2069), marks (U+200E/200F), and the Arabic letter
mark (U+061C) are category Cf. Those characters are invisible but reorder the
glyphs around them, so a device can name itself
Owner + U+2067 + U+202E + enohPi s + U+202C + box and render as
"Owner's iPhone" in the approval list (Trojan Source, CVE-2021-42574), letting an
attacker's device impersonate a trusted one.

Why This Change Was Made

The pairing renderer now removes bidirectional controls from each displayed cell.
The fix is local to this approval surface rather than in shared
sanitizeTerminalText, because other consumers of that helper (for example codex
catalog previews, which have an explicit test for it) rely on formatting
characters passing through. Strong-directional letters are not controls, so a
right-to-left device name still renders its letters.

User Impact

The pending-pairing table can no longer be reordered or spoofed by a crafted
device name. A bidirectional control in a displayed name, request id, or IP is
dropped; ordinary text, including right-to-left letters, is unchanged.

Evidence

CLI call path -- the renderer is what openclaw nodes list prints, unchanged
(src/cli/nodes-cli/register.status.ts):

.command("list")                                         // line 536
  -> callNodesGatewayCli("node.pair.list", opts, {})     // line 544  (Gateway RPC)
  -> parsePairingList(result)                            // line 545
  -> renderPendingPairingRequestsTable({ pending, ... }) // line 583
  -> defaultRuntime.log(rendered.table)                  // line 591  (verbatim to terminal)

The Gateway node.pair.list handler returns the stored pending requests
(listNodePairing), including the device-supplied displayName, and the CLI
prints rendered.table verbatim. Nothing transforms the string between the
renderer and defaultRuntime.log, so the renderer output below is exactly the
terminal output for the pending rows the Gateway returns.

Captured from the real renderPendingPairingRequestsTable, the function the
nodes list pending table prints. A pending request whose displayName is
Owner + U+2067 + U+202E + enohPi s + U+202C + box produces the Node cell
(other columns trimmed):

Before (current main), the override reaches the terminal and the row reorders to
read "Owner's iPhone":

| req_88f1 | Owner<U+2067><U+202E>enohPi s<U+202C>box | 10.0.0.9 | 1m ago |

Bidirectional controls present in the rendered table: U+2067, U+202E, U+202C.

After this change:

| req_88f1 | OwnerenohPi sbox | 10.0.0.9 | 1m ago |

Bidirectional controls present in the rendered table: none.

New tests in src/cli/nodes-cli/pairing-render.test.ts assert this on the
production render path and confirm a right-to-left name such as שלום Phone still
renders its letters.

@clawsweeper

clawsweeper Bot commented Sep 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.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 17, 2026
@clawsweeper

clawsweeper Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR removes bidirectional formatting controls from pending node-pairing table cells while preserving printable right-to-left letters.

Example: A pending node supplies displayName Owner\u2067\u202EenohPi s\u202Cbox.

  • Before: The terminal receives invisible controls that can reorder the displayed name.
  • After: The displayed value is OwnerenohPi sbox, without those controls.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) No discrete correctness defect was established in the introduced patch, but this head lacks required CLI proof and its useful behavior has already been absorbed.
Proof confidence 🧂 unranked krab (1/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An untrusted pending node name can carry invisible controls that reorder its terminal presentation during operator review.
Reason: Neutralizing display controls has clear value, and that value is now delivered by the merged shared-owner implementation.

Merge readiness

⛔ Blocked before merge - 2 items remain

Current main already covers this PR through #186502, but the recorded maintainer direction explicitly reserves closure for the assignee, fuller-stack-dev.

Priority: P2
Reviewed head: fd7d93801e80442f99b355bc1e07d0695c7f6159
Owner decision: Required. See Decision needed.

Decision needed

Before merge

  • Add real behavior proof - This head supplies constructed-request renderer output and unit coverage, rather than a shipped CLI run against a Gateway; fix(cli): sweep terminal value escaping and bidi controls in report families #186502 (comment) separately proves the absorbed implementation's built CLI behavior. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Await maintainer action - fuller-stack-dev should resolve the explicitly reserved disposition of this assigned PR.

Findings

None.

Tests

  • Missing end-to-end proof: If this branch is pursued for merge, its own evidence still needs after-fix nodes pending or nodes list output against a real Gateway; the merged replacement's CLI evidence does not execute this head.
Agent review details

How this fits together

The nodes CLI parses pending requests returned by the Gateway and renders their identifiers, names, and IP addresses into an operator-facing terminal table.

flowchart LR
  A[Pending node request] --> B[Gateway pairing list]
  B --> C[CLI pairing parser]
  C --> D[Pending table renderer]
  D --> E[Terminal text sanitizer]
  E --> F[Operator terminal]
Loading

Technical review

Best possible solution:

Retain the merged shared-owner fix and let fuller-stack-dev decide this PR's disposition with arpe1618's contribution credited.

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

The original source path allowed bidi controls through, but current main removes them through the shared sanitizer; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The merged shared-owner implementation solves the same problem without retaining a separate pairing-specific bidi policy.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against b2ecb073b2cf; fix evidence: commit 3bcca4f468ea, main fix timestamp 2026-10-28T05:12:57Z.

Provenance checked

Testing

Proof path: unit tests only.

Security

None.

Evidence

What I checked:

PR surface

Source +11, Tests +42. Total +53 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 14 3 +11
Tests 1 42 0 +42
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 56 3 +53

Root-cause cluster

Relationship: superseded
Canonical: #186502
Summary: The merged shared terminal-text sweep explicitly absorbs the pending-pairing bidi fix; disposition remains reserved for this PR's assignee.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The change addresses bounded terminal presentation hardening in node pairing; current main already supplies the fix.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

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 (10 earlier review cycles; latest 8 shown)
  • reviewed 2026-09-17T09:19:09.643Z sha ef922402594cf63db9ee4b2894393837c1c5a31b :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-17T10:59:26.871Z sha e039c80b64b6192b80f2a11147fa1271e5689bae :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-17T11:29:08.584Z sha 76e14a7fc3470e6e144c8630659e7d410b06f3a0 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-17T12:20:23.403Z sha fd7d938 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-18T04:49:44.552Z sha fd7d938 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-25T01:03:51.819Z sha fd7d938 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-27T15:03:06.694Z sha fd7d938 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-06T04:53:37.907Z sha fd7d938 :: needs real behavior proof before merge. :: none

Reviewed October 28, 2026, 1:55 AM ET / 05:55 UTC (Revision 11).

@arpe1618
arpe1618 force-pushed the improve/terminal-bidi-sanitize branch from 43eb520 to 452148e Compare September 17, 2026 05:41
@clawsweeper clawsweeper Bot added the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Sep 17, 2026
@arpe1618
arpe1618 force-pushed the improve/terminal-bidi-sanitize branch 3 times, most recently from f887f6b to e039c80 Compare September 17, 2026 10:48
@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes size: S and removed size: XS labels Sep 17, 2026
@arpe1618

Copy link
Copy Markdown
Contributor Author

Added the affected-CLI-flow proof: a new test in src/cli/nodes-cli/pairing-render.test.ts renders a bidi-spoofed displayName through the real renderPendingPairingRequestsTable and asserts the rendered table carries zero bidirectional controls (the Node cell becomes OwnerenohPi sbox), plus a sibling test showing a right-to-left name keeps its letters. The PR body Evidence now shows the rendered row. @clawsweeper please re-review.

@arpe1618
arpe1618 force-pushed the improve/terminal-bidi-sanitize branch from e039c80 to 76e14a7 Compare September 17, 2026 11:22
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 17, 2026
A node sets its own displayName in the pairing request, and `nodes status`
renders it verbatim in the pending-request table that an operator reads to
approve the device. sanitizeTerminalText escapes C0/C1 controls but passes
bidirectional formatting controls (overrides, isolates, marks, the Arabic
letter mark) through, so a device could name itself
`Owner<RLI><RLO>enohPi s<PDF>box` and render as "Owner's iPhone" in the
approval list (Trojan Source, CVE-2021-42574).

Strip those controls in the pairing renderer before display. The fix is local
to this approval surface rather than in shared sanitizeTerminalText, because
other consumers of that helper (for example codex catalog previews) rely on
formatting characters passing through. Strong-directional letters are not
controls, so a right-to-left device name still renders its letters.
@arpe1618
arpe1618 force-pushed the improve/terminal-bidi-sanitize branch from 76e14a7 to fd7d938 Compare September 17, 2026 12:11
@arpe1618 arpe1618 changed the title fix(terminal): neutralize bidirectional controls in sanitized terminal text fix(cli): strip bidirectional controls from the pending-pairing table Sep 17, 2026
@arpe1618

Copy link
Copy Markdown
Contributor Author

Reworked to a narrower, correct fix. A CI run surfaced that shared sanitizeTerminalText has consumers that deliberately preserve formatting characters (codex catalog previews have an explicit test for it), so changing the shared helper was wrong. The fix now strips bidirectional controls only in the pairing renderer (renderPendingPairingRequestsTable), the device-approval surface, leaving sanitizeTerminalText and its other consumers untouched. Evidence and the affected-flow tests are updated. @clawsweeper please re-review.

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Sep 17, 2026
@arpe1618

Copy link
Copy Markdown
Contributor Author

Updated Evidence with before/after output captured from the production renderPendingPairingRequestsTable (the function nodes status prints), with a codepoint scan of the rendered table: before = U+2067, U+202E, U+202C present (row reorders to "Owner's iPhone"); after = none present. CI is green. @clawsweeper please re-review.

@fuller-stack-dev fuller-stack-dev self-assigned this Sep 18, 2026
@arpe1618

Copy link
Copy Markdown
Contributor Author

Addressed the remaining proof point directly. The renderer is not separate from the CLI: openclaw nodes list calls it and prints its output verbatim — register.status.ts:536 .command("list") -> :544 callNodesGatewayCli("node.pair.list") (Gateway RPC) -> :545 parsePairingList -> :583 renderPendingPairingRequestsTable -> :591 defaultRuntime.log(rendered.table). The Gateway's node.pair.list returns the stored pending requests (listNodePairing) with the device-supplied displayName, and nothing transforms the string between the renderer and the log call. So the before/after rows in the PR body are exactly the after-fix terminal output for the pending rows the Gateway returns: before = U+2067/U+202E/U+202C present (row reorders to "Owner's iPhone"), after = none. @clawsweeper please re-review.

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

@fuller-stack-dev: #186502 (3bcca4f) routes the covered CLI report families through the shared terminalText owner and now neutralizes bidirectional controls too, which covers this PR's output site. @arpe1618's commit is kept there with co-author credit. Leaving the close to you since it's assigned to you.

Rechecked against current main 7b31ab208c80123884bb3d67842331122e48d3d6: The pending-pairing Request/Node/IP cells use terminalText, whose canonical sanitizer now removes Bidi_Control while retaining ordinary RTL letters. The site is fixed on main. This PR remains open for its assignee.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 28, 2026
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]>

This branch has not been deployed

No deployments
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. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants