Skip to content

fix(secrets): escape terminal controls in readable env values - #184141

Merged
steipete merged 1 commit into
openclaw:mainfrom
Alix-007:alix/terminal-secrets-20261026
Oct 26, 2026
Merged

steipete merged 1 commit into
openclaw:mainfrom
Alix-007:alix/terminal-secrets-20261026

Conversation

@Alix-007

@Alix-007 Alix-007 commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes terminal control sequences and forged output rows when secrets store list or secrets store get displays a readable environment value.

User Impact

Human output safely displays environment values. JSON and plain output preserve the original bytes, and secret-kind entries remain write-only.

Why This Change Was Made

Apply the existing sanitizeTerminalText policy at the two human-output boundaries. Storage, validation, and machine-readable output stay with their existing owners. Thanks to @Alix-007 for the fix and regression coverage.

Evidence

  • The new command-boundary regression fails on the unchanged main implementation: human list/get emits actual controls instead of visible escapes; the other 16 tests pass. The affected production file is identical between the tested main checkout and current origin/main.
  • Patched regression: all 17 tests pass. node scripts/run-vitest.mjs src/cli/secrets-store-cli.test.ts --maxWorkers=1; red command wall time 129.44s, green 204.68s, dominated by cold compiled-worker preparation.
  • Targeted oxlint, oxfmt, and git diff --check pass.
  • Contributor's isolated Linux CLI proof at 1137567ba3b82e0a3b5c429996ad87808df582d0 used normal builds and real SQLite state: both human paths changed from three control bytes plus a forged row to safe output; JSON/plain readback retained exact values and secret reads exited 2 without disclosure.
  • Fresh macOS live replay was not completed: pnpm openclaw refused runtime artifact publication because it could not verify the affected Gateway was offline. No running Gateway or operator state was changed.
  • Production: +6/-2 lines (net +4); tests: +29/-0. The small increase is the canonical sanitizer import and two calls; no new formatter, state, or test-only seam.
  • Independent Codex review: no actionable P0–P2 findings. Exact-head CI watcher: GREEN for 1137567ba3b82e0a3b5c429996ad87808df582d0, run 40262838779; non-green rollup entries are superseded.

@clawsweeper

clawsweeper Bot commented Oct 26, 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 docs Improvements or additions to documentation cli CLI command changes size: XS labels Oct 26, 2026
@clawsweeper clawsweeper Bot added 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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 26, 2026
@clawsweeper

clawsweeper Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Sanitize readable environment values in human secret-store output while preserving JSON and plain output.

Example: SERVICE_MODE contains café, an ANSI color sequence, newline, tab, carriage return, and bell.

  • Before: Human list/get output executes controls and displays operator-forged text on another row.
  • After: ANSI and bell controls disappear, line controls become visible escapes, and café remains readable.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused owner-level repair with reusable shipped-CLI evidence, a meaningful regression, successful exact-head gates, and no open findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Reused proof for unchanged head 1137567 records normally built Linux CLI list/get commands against isolated SQLite state, safe human rendering, exact JSON/plain values, Unicode preservation, and secret-read rejection; the current body corroborates those results.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Valid environment values can execute terminal controls and forge rows when operators inspect the store.
Reason: The patch applies established terminal-display policy at the existing CLI owner and preserves supported raw-output paths.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current CLI rendering defect with a focused change; no actionable correctness or security findings remain.

Priority: P2
Reviewed head: 1137567ba3b82e0a3b5c429996ad87808df582d0

Before merge

None.

Findings

None.

Agent review details

How this fits together

The secrets CLI reads metadata and environment values from the SQLite store and renders human or machine-readable output; secret-kind values remain write-only.

flowchart TD
  A[Secrets store CLI] --> B[SQLite store reader]
  B --> C[Metadata and env values]
  C --> D[Human output sanitizer]
  D --> E[Terminal text]
  C --> F[JSON or plain output]
Loading

Technical review

Best possible solution:

Land the existing sanitizer calls at both human-output boundaries while retaining raw-output and write-only-secret contracts.

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

Current-main source exposes both raw interpolations, and retained exact-head proof records matching baseline failures; no target code was executed during this review.

Is this the best way to solve the issue?

This is the smallest complete fix: reuse the existing display sanitizer in both human renderers without changing storage, validation, or machine-readable output.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 872cb2afe987.

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Pinned introduced change: The introduced diff applies the existing sanitizer only to the two human environment-value renderings, adds a command-output regression, and documents raw-output alternatives. (src/cli/secrets-store-cli.ts:189, 1137567ba3b8)
  • Current main remains affected: Fetched main still interpolates valuePreview and result.value directly into human output; the affected files are unchanged from the pinned baseline. (src/cli/secrets-store-cli.ts:186, 872cb2afe987)
  • Canonical terminal policy: sanitizeTerminalText strips ANSI sequences, visibly escapes newline/tab/carriage return, and removes other C0/C1 controls; its existing tests cover cursor controls and OSC clipboard sequences. (packages/terminal-core/src/safe-text.ts:11, 1137567ba3b8)
  • Reused exact-head CLI proof: The current body and prior completed review record normally built Linux CLI commands against isolated SQLite state, safe human list/get output, exact JSON/plain readback, and write-only secret rejection. The prior review identifies the original proof body as be70effac9b1e7ab6e8d5c8b39d0bee4881fd6133b4b0d5fa1e3e8c4af9240e6. Original replay streams are absent from the current body; retrieving archived review logs was blocked by the host allowlist. This inspection limitation does not invalidate the recorded proof for the unchanged head. (1137567ba3b8)
  • Feature intent and history: Merged feat(secrets): SQLite-backed secret store with CLI and store SecretRef source #121559 introduced readable environment values and write-only secrets; merged fix(cli): keep secrets JSON failures machine-readable #136142 established the shared JSON-output owner. Path history also identifies subsequent store-worker and Gateway-owner refactors. A follow-history traversal encountered an unavailable promisor object; readable creation hunks and supplied provenance establish the relevant intent. (src/cli/secrets-store-cli.ts:362, 872cb2afe987)
  • Exact-head gates: The reviewed head has successful CI-gate, dependency-review, and security-sensitive-review statuses; changed-code checks and security checks succeeded. The cancelled auto-response entry has successful replacements and identifies no product failure. (1137567ba3b8)

Likely related people:

  • Peter Steinberger: Raw commit 11eaa00 adds src/cli/secrets-store-cli.ts:185 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 11eaa003bc8c; files: src/cli/secrets-store-cli.ts)
  • qingminlong: Raw commit aa88b1d adds src/cli/secrets-store-cli.ts:325 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: aa88b1d95dcd; files: src/cli/secrets-store-cli.ts)

PR surface

Source +4, Tests +29, Docs +2. Total +35 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 6 2 +4
Tests 1 29 0 +29
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 37 2 +35

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +6/-2; tests +29/-0 The small production increase reuses one sanitizer at two boundaries; the regression protects human rendering and exact machine-readable values without new scaffolding.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: A bounded CLI rendering defect allows stored environment controls to execute or forge human-readable rows.
  • 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 (1 earlier review cycle)
  • reviewed 2026-10-26T03:26:20.536Z sha 1137567 :: needs maintainer review before merge. :: none

Reviewed October 26, 2026, 2:50 AM ET / 06:50 UTC (Revision 2).

@steipete

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 26, 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. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 26, 2026
@steipete
steipete merged commit 6b72c79 into openclaw:main Oct 26, 2026
142 of 143 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

@Alix-007

Copy link
Copy Markdown
Contributor Author

Thanks @steipete for merging this! Appreciate your time.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 27, 2026
…aw#184141)

Escape terminal controls in human-readable env list/get output while preserving exact JSON/plain values and write-only secret semantics.

Validation: regression fails on base and all 17 owner tests pass on the reviewed head; targeted lint/format and exact-head CI pass.

Co-authored-by: Alix-007 <[email protected]>
RomneyDa added a commit that referenced this pull request Oct 28, 2026
Escape terminal controls in human-readable env list/get output while preserving exact JSON/plain values and write-only secret semantics.

Validation: regression fails on base and all 17 owner tests pass on the reviewed head; targeted lint/format and exact-head CI pass.

Co-authored-by: Alix-007 <[email protected]>

(cherry picked from commit 6b72c79)

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 964cae5c1ecb30d5b074a71eadd0c025a32aa68a)
RomneyDa added a commit that referenced this pull request Oct 28, 2026
Escape terminal controls in human-readable env list/get output while preserving exact JSON/plain values and write-only secret semantics.

Validation: regression fails on base and all 17 owner tests pass on the reviewed head; targeted lint/format and exact-head CI pass.

Co-authored-by: Alix-007 <[email protected]>

(cherry picked from commit 6b72c79)

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 08265b251159d270c8ff8a41de33092fc453ed09)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation 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