Skip to content

fix(auth): strip controls from masked API keys - #96445

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

vincentkoc merged 3 commits into
openclaw:mainfrom
lin-hongkuan:codex/mask-api-key-strip-controls

Conversation

@lin-hongkuan

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

Copy link
Copy Markdown
Contributor

What Problem This Solves

maskApiKey() trims credential-like values before redacting them, but embedded control characters were preserved in the masked diagnostic output. A copied value containing a newline or NUL could therefore make masked auth/setup text multiline or carry invisible control bytes even though the secret itself was redacted.

Why This Change Was Made

The masker now strips C0/C1/DEL control characters before applying the existing length-based redaction rules. This keeps the same visible masking format for printable values while making diagnostic output single-line/control-free.

A focused regression test covers newline, NUL, and all-control input.

User Impact

Onboarding, auth overview, and directive responses that display masked credentials no longer echo hidden control characters from malformed input.

Evidence

Direct behavior probe:

$ node --import tsx -e "import('./src/utils/mask-api-key.ts').then(({ maskApiKey }) => console.log(JSON.stringify({ newline: maskApiKey('abcd\nefghijklmnop'), nul: maskApiKey('abcd\u0000efghijklmnop'), delC1: maskApiKey('abcd\u007f\u0085efghijklmnop'), emptyControls: maskApiKey('\u0000\n\u0085') })))"
{"newline":"ab...op","nul":"ab...op","delC1":"ab...op","emptyControls":"missing"}

Targeted test:

$ node scripts/run-vitest.mjs run src/utils/mask-api-key.test.ts

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


 Test Files  1 passed (1)
      Tests  4 passed (4)
   Start at  21:29:22
   Duration  351ms (transform 30ms, setup 0ms, import 54ms, tests 5ms, environment 0ms)

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

Formatting:

$ node_modules\.bin\oxfmt.cmd --check src/utils/mask-api-key.ts src/utils/mask-api-key.test.ts
Checking formatting...

All matched files use the correct format.
Finished in 1246ms 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 25, 2026, 5:16 PM ET / 21:16 UTC.

Summary
The PR strips C0/C1/DEL control characters from API-key diagnostic masking before applying the existing redaction rules and adds focused regression coverage.

PR surface: Source +12, Tests +7. Total +19 across 2 files.

Reproducibility: yes. from source inspection: current main trims only at the edges, and the shared display callers then slice the same string into diagnostic labels. I did not run tests locally because this review is read-only.

Review metrics: none identified.

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

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

Rank-up moves:

  • none.

Risk before merge

  • [P1] Live PR status still had queued checks after the latest no-op retrigger commit during review; this is an ordinary merge-gate wait, not a code repair need.

Maintainer options:

  1. Decide the mitigation before merge
    Land the focused masker and regression test after normal maintainer merge gates, while keeping raw secret input normalization in the adjacent companion PR.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • No repair lane is needed; the patch is correct and the remaining action is normal maintainer review plus merge-gate completion.

Security
Cleared: No security or supply-chain regression found; the diff tightens an in-repo credential masking helper and adds a colocated unit test.

Review details

Best possible solution:

Land the focused masker and regression test after normal maintainer merge gates, while keeping raw secret input normalization in the adjacent companion PR.

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

Yes from source inspection: current main trims only at the edges, and the shared display callers then slice the same string into diagnostic labels. I did not run tests locally because this review is read-only.

Is this the best way to solve the issue?

Yes. Changing the shared diagnostic masker is the narrowest maintainable fix for the display problem; raw secret input normalization remains a separate boundary handled by #96444.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 13ecca5408cb.

Label changes

Label justifications:

  • P2: This fixes a real auth diagnostic-output bug with limited blast radius and no new config, migration, or product surface.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body includes copied terminal output from a direct after-fix behavior probe plus the targeted test run, which is sufficient for this non-visual utility change.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes copied terminal output from a direct after-fix behavior probe plus the targeted test run, which is sufficient for this non-visual utility change.
Evidence reviewed

PR surface:

Source +12, Tests +7. Total +19 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 13 1 +12
Tests 1 7 0 +7
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 20 1 +19

What I checked:

Likely related people:

  • rosenlo: git blame attributes the current shared masker implementation and auth display callers to commit f9e0dce. (role: introduced behavior; confidence: high; commits: f9e0dce73109; files: src/utils/mask-api-key.ts, src/utils/mask-api-key.test.ts, src/commands/models/list.auth-overview.ts)
  • Ayaan Zaidi: git show --format=fuller lists Ayaan Zaidi as committer for the commit that introduced the current shared masker and auth display caller files in this checkout. (role: committer; confidence: medium; commits: f9e0dce73109; files: src/utils/mask-api-key.ts, src/commands/models/list.auth-overview.ts, src/auto-reply/reply/directive-handling.auth.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
@vincentkoc
vincentkoc merged commit 2906d6c into openclaw:main Jun 29, 2026
93 checks passed
Rorqualx pushed a commit to Rorqualx/cortex that referenced this pull request Jun 29, 2026
* fix(auth): strip controls from masked API keys

* test(auth): cover DEL and C1 masked key controls

* chore: retrigger PR checks

---------

Co-authored-by: lin-hongkuan <lin-hongkuan@users.noreply.github.com>
(cherry picked from commit 2906d6c)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jun 30, 2026
* fix(auth): strip controls from masked API keys

* test(auth): cover DEL and C1 masked key controls

* chore: retrigger PR checks

---------

Co-authored-by: lin-hongkuan <lin-hongkuan@users.noreply.github.com>
chenyangjun-xy pushed a commit to chenyangjun-xy/openclaw that referenced this pull request Jul 1, 2026
* fix(auth): strip controls from masked API keys

* test(auth): cover DEL and C1 masked key controls

* chore: retrigger PR checks

---------

Co-authored-by: lin-hongkuan <lin-hongkuan@users.noreply.github.com>
wheakerd pushed a commit to wheakerd/clawdbot that referenced this pull request Jul 15, 2026
* fix(auth): strip controls from masked API keys

* test(auth): cover DEL and C1 masked key controls

* chore: retrigger PR checks

---------

Co-authored-by: lin-hongkuan <lin-hongkuan@users.noreply.github.com>
(cherry picked from commit 2906d6c)
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: 🐚 platinum hermit Good normal PR readiness with ordinary 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