Skip to content

fix(secrets): strip control characters from secret input - #96444

Merged
vincentkoc merged 3 commits into
openclaw:mainfrom
lin-hongkuan:codex/secret-input-strip-controls
Jun 29, 2026
Merged

vincentkoc merged 3 commits into
openclaw:mainfrom
lin-hongkuan:codex/secret-input-strip-controls

Conversation

@lin-hongkuan

@lin-hongkuan lin-hongkuan commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

normalizeSecretInput() strips line breaks and non-Latin1 characters from copied credentials, but it still preserved other embedded terminal/header control characters such as NUL, TAB, DEL, and C1 controls. Those characters can still make downstream header construction fail or carry invisible garbage in configured secrets.

Why This Change Was Made

The existing character filter now also drops C0/C1/DEL control characters while continuing to preserve printable Latin-1 and ordinary internal spaces. This keeps the documented Bearer <token> style behavior intact.

A focused regression test covers embedded controls and verifies ordinary spaces are still preserved.

User Impact

Copied API keys and tokens with hidden control characters normalize to usable values instead of failing later in provider request setup. Human-readable values with intentional spaces remain unchanged apart from edge trimming.

Evidence

Direct behavior probe:

$ node --import tsx -e "import('./src/utils/normalize-secret-input.ts').then(({ normalizeSecretInput }) => console.log(JSON.stringify({ controls: normalizeSecretInput(' sk-\u0000ab\tc\u007f\u0085 '), spaces: normalizeSecretInput(' Bearer token value ') })))"
{"controls":"sk-abc","spaces":"Bearer token value"}

Targeted test:

$ node scripts/run-vitest.mjs run src/utils/normalize-secret-input.test.ts

 RUN  v4.1.8 C:/Users/lin20/Documents/New project 3/openclaw


 Test Files  1 passed (1)
      Tests  7 passed (7)
   Start at  21:26:26
   Duration  270ms (transform 27ms, setup 0ms, import 42ms, tests 5ms, environment 0ms)

[test] starting test/vitest/vitest.unit-fast.config.ts
[test] passed 1 Vitest shard in 7.04s

Formatting:

$ node_modules\.bin\oxfmt.cmd --check src/utils/normalize-secret-input.ts src/utils/normalize-secret-input.test.ts
Checking formatting...

All matched files use the correct format.
Finished in 1335ms on 2 files using 32 threads.

Whitespace:

$ git diff --check

AI-assisted

Prepared with Codex. I reviewed the change, understand the touched code path, and kept the PR focused on the bug described above.

@lin-hongkuan

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper

clawsweeper Bot commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed June 27, 2026, 2:37 PM ET / 18:37 UTC.

Summary
The branch adds C0/C1/DEL filtering to the shared secret normalizer and web-content provider secret normalizer, plus focused regression tests that preserve ordinary spaces.

PR surface: Source +10, Tests +14. Total +24 across 4 files.

Reproducibility: yes. from source inspection. Current main accepts C0/C1/DEL controls in both relevant normalizers because they pass the codePoint <= 0xff filter, and callers use those normalized values for provider credentials.

Review metrics: none identified.

Root-cause cluster
Relationship: canonical
Canonical: #96444
Summary: This PR is the canonical raw secret/runtime credential normalization fix; the companion masked-output PR overlaps on control-character hygiene but owns a separate diagnostic display boundary.

Members:

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

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Next step before merge

  • [P2] No repair lane is needed; the patch and proof are sufficient, so the remaining action is ordinary maintainer merge-gate review.

Security
Cleared: No security or supply-chain regression found; the diff tightens in-repo secret-string normalization and adds colocated tests without dependency, workflow, package, storage, or execution changes.

Review details

Best possible solution:

Land this narrow normalization fix after normal maintainer merge gates; keep the companion masked-output PR separate because it owns diagnostic redaction rather than raw credential input.

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

Yes from source inspection. Current main accepts C0/C1/DEL controls in both relevant normalizers because they pass the codePoint <= 0xff filter, and callers use those normalized values for provider credentials.

Is this the best way to solve the issue?

Yes. Updating both the exported core helper and the web-content private copy is the narrow maintainable fix for the observed runtime paths; extracting a new shared package boundary would be broader than this bug requires.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 98ed83f848de.

Label changes

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. Sufficient: copied terminal output now covers the core helper and the updated readWebProviderEnvValue runtime credential path, with focused test output and redacted-safe values.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): Sufficient: copied terminal output now covers the core helper and the updated readWebProviderEnvValue runtime credential path, with focused test output and redacted-safe values.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove status: 🔁 re-review loop: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a scoped credential-normalization bug fix with limited blast radius and no new config, migration, or product surface.
  • 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. Sufficient (terminal): Sufficient: copied terminal output now covers the core helper and the updated readWebProviderEnvValue runtime credential path, with focused test output and redacted-safe values.
  • proof: sufficient: Contributor real behavior proof is sufficient. Sufficient: copied terminal output now covers the core helper and the updated readWebProviderEnvValue runtime credential path, with focused test output and redacted-safe values.
Evidence reviewed

PR surface:

Source +10, Tests +14. Total +24 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 12 2 +10
Tests 2 14 0 +14
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 26 2 +24

What I checked:

  • Current main core behavior: Current main removes line separators and non-Latin1 characters but accepts any code point <= 0xff, so NUL, TAB, DEL, and C1 controls still pass through the shared helper. (src/utils/normalize-secret-input.ts:28, 98ed83f848de)
  • Current main web-content behavior: The web-content package has a private copy of the same <= 0xff normalizer used by readWebProviderEnvValue and provider credential checks. (packages/web-content-core/src/provider-runtime-shared.ts:59, 98ed83f848de)
  • Runtime callers checked: Web search and web fetch runtime credential detection both route through hasWebProviderEntryCredential/readWebProviderEnvValue, so the web-content copy is on a real provider credential path. (src/web-search/runtime.ts:86, 98ed83f848de)
  • PR diff coverage: The PR adds an isControl guard to both normalizers and tests NUL, TAB, DEL, C1 stripping while preserving Bearer-style internal spaces. (src/utils/normalize-secret-input.ts:28, 2cd97943602b)
  • Contributor proof after prior blocker: The latest comments include copied terminal output for focused tests and a direct readWebProviderEnvValue runtime probe showing controls normalize to sk-abc and Bearer token spaces are preserved. (2cd97943602b)
  • Relevant CI/proof checks: Live status rollup shows later duplicate Real behavior proof and auto-response runs succeeded, and core check-lint, check-prod-types, check-test-types, and check-guards succeeded for the PR head. (2cd97943602b)

Likely related people:

  • steipete: GitHub commit history shows steipete authored the original pasted-key line-break normalization helper and authored the web-content core package extraction that owns the private runtime copy. (role: introduced helper behavior and web-content package extraction; confidence: high; commits: 42a07791c4e6, a20b2dc74023; files: src/utils/normalize-secret-input.ts, packages/web-content-core/src/provider-runtime-shared.ts)
  • vignesh07: GitHub commit history shows vignesh07 authored the ByteString Latin-1 hardening in the shared helper that this PR extends to control characters. (role: adjacent behavior hardening; confidence: high; commits: 1ab9393212b2; files: src/utils/normalize-secret-input.ts, src/utils/normalize-secret-input.test.ts)
  • vincentkoc: Recent web provider/runtime history includes provider-runtime facade and runtime-web-tools changes by vincentkoc near the same credential-detection surface. (role: recent adjacent web provider contributor; confidence: medium; commits: e122cd09ab0f, 21728777dfa0; files: src/web/provider-runtime-shared.ts, src/secrets/runtime-web-tools.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added 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. P2 Normal backlog priority with limited blast radius. labels Jun 24, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed 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. labels Jun 25, 2026
@lin-hongkuan

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review after applying the same C0/C1/DEL filtering to the web-content provider secret normalizer and adding env credential regression coverage. Targeted core/web-content tests, oxfmt, and diff check pass.

@clawsweeper

clawsweeper Bot commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

@clawsweeper clawsweeper Bot added status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jun 26, 2026
@lin-hongkuan

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review after adding the requested live proof for the web-content runtime credential path.

The PR already included code/tests for the web-content provider secret normalizer. I re-ran the focused validation on the current branch and added a direct runtime probe for readWebProviderEnvValue:

$ node scripts/run-vitest.mjs run src/utils/normalize-secret-input.test.ts packages/web-content-core/src/provider-runtime-shared.test.ts
✓ unit-fast src/utils/normalize-secret-input.test.ts (7 tests)
✓ unit packages/web-content-core/src/provider-runtime-shared.test.ts (7 tests)
Test Files 1 passed (1)
Tests 7 passed (7)
Test Files 1 passed (1)
Tests 7 passed (7)
[test] passed 2 Vitest shards in 11.69s

$ node - <<'NODE'
import { readWebProviderEnvValue } from './packages/web-content-core/src/provider-runtime-shared.ts';
const value = readWebProviderEnvValue(['API_KEY'], { API_KEY: ' sk-\u0000ab\tc\u007f\u0085 ' });
const bearer = readWebProviderEnvValue(['API_KEY'], { API_KEY: ' Bearer token value ' });
console.log('webProviderControlProbe=' + JSON.stringify(value));
console.log('webProviderBearerSpaceProbe=' + JSON.stringify(bearer));
NODE
webProviderControlProbe="sk-abc"
webProviderBearerSpaceProbe="Bearer token value"

$ git diff --check
# no output

This covers the previously missing web-content runtime credential path while preserving ordinary internal spaces.

@clawsweeper clawsweeper Bot added 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. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed 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. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Jun 27, 2026
@clawsweeper clawsweeper Bot added status: 🔁 re-review loop A fresh ClawSweeper review was explicitly requested after the latest review. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jun 27, 2026
@lin-hongkuan

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

No additional code changes appear necessary after the current head 2cd97943602b8055dc8273081f8f2ca91c5026e4. The latest durable review said the code shape was acceptable and only needed stronger proof for the web-content runtime credential path; that proof was posted previously and I re-ran focused validation.

Fresh focused validation on the current PR head:

$ node scripts/run-vitest.mjs run src/utils/normalize-secret-input.test.ts packages/web-content-core/src/provider-runtime-shared.test.ts
✓ unit-fast src/utils/normalize-secret-input.test.ts (7 tests)
✓ unit packages/web-content-core/src/provider-runtime-shared.test.ts (7 tests)
Test Files 1 passed (1)
Tests 7 passed (7)
Test Files 1 passed (1)
Tests 7 passed (7)
[test] passed 2 Vitest shards in 13.29s

$ oxfmt --check --threads=1 src/utils/normalize-secret-input.ts src/utils/normalize-secret-input.test.ts packages/web-content-core/src/provider-runtime-shared.ts packages/web-content-core/src/provider-runtime-shared.test.ts
All matched files use the correct format.

$ git diff --check origin/main...HEAD
# no output

$ diff secret scan over origin/main...HEAD
secret_scan=clean

Current PR checks include older cancelled duplicate auto-response / Real behavior proof runs, but later duplicate runs for the same contexts are successful. Please refresh the review/verdict against 2cd97943602b8055dc8273081f8f2ca91c5026e4.

@clawsweeper clawsweeper Bot added 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 🔁 re-review loop A fresh ClawSweeper review was explicitly requested after the latest review. labels Jun 27, 2026
@vincentkoc
vincentkoc merged commit bc7f0f1 into openclaw:main Jun 29, 2026
173 of 196 checks passed
Rorqualx pushed a commit to Rorqualx/cortex that referenced this pull request Jun 29, 2026
)

* fix(secrets): strip control characters from secret input

* chore: retrigger PR checks

* fix(web-content): strip controls from provider secrets

---------

Co-authored-by: lin-hongkuan <[email protected]>
(cherry picked from commit bc7f0f1)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jun 30, 2026
)

* fix(secrets): strip control characters from secret input

* chore: retrigger PR checks

* fix(web-content): strip controls from provider secrets

---------

Co-authored-by: lin-hongkuan <[email protected]>
chenyangjun-xy pushed a commit to chenyangjun-xy/openclaw that referenced this pull request Jul 1, 2026
)

* fix(secrets): strip control characters from secret input

* chore: retrigger PR checks

* fix(web-content): strip controls from provider secrets

---------

Co-authored-by: lin-hongkuan <[email protected]>
wheakerd pushed a commit to wheakerd/clawdbot that referenced this pull request Jul 15, 2026
)

* fix(secrets): strip control characters from secret input

* chore: retrigger PR checks

* fix(web-content): strip controls from provider secrets

---------

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

Labels

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