Repository navigation
security: RedactString misses secrets split by a NUL or ESC #969
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't workingissue-approvedReviewed and approved by the core team; community PRs may implement this issue.Reviewed and approved by the core team; community PRs may implement this issue.
Description
Activity
- addedissue-approvedReviewed and approved by the core team; community PRs may implement this issue.Reviewed and approved by the core team; community PRs may implement this issue.
on Aug 27, 2026 - added a commit that references this issue
on Sep 1, 2026 - added 9 commits that reference this issue
on Sep 5, 2026 Decision on the two PRs for this: #1067 is the fix. Disclosure: it's mine. It's the one that holds on the measured cases. On the same inputs it exposes no usable credential, and jatmn has approved it; its known limit (the tail of a key whose front part is complete on its own) is stated in its description. The details on #1075, including the two cases that still leak a usable GitHub token or JWT and the two quadratic paths, are in my last review there.
@cairn-intern thank you for #1075. It found a real improvement over main that mine doesn't have (two AWS keys glued end to end), and that's worth a separate small PR if you want to carry it over.
- added a commit that references this issue
on Oct 12, 2026 - added a commit that references this issue
on Oct 12, 2026
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingissue-approvedReviewed and approved by the core team; community PRs may implement this issue.Reviewed and approved by the core team; community PRs may implement this issue.
Version / branch / commit
mainat 27b319c (current origin/main)OS and environment
Windows 10. Static review of
internal/redaction; no provider call required.Steps to reproduce
sk-ant-api03-abcdefghijklmnopqrstuvwxyz0123456789ABCD.RedactStringon the unsplit value → it redacts.sk-ant-api03-\x00abcdefghijklmnopqrstuvwxyz0123456789ABCD.RedactStringagain → no match.RedactString(internal/redaction/redaction.go) matches shapes on the raw string. It never strips C0/C1 bytes first. There is no split-case test in the package.This is the AGENTS.md “normalize before matching” gap: redacting by shape and then (or never) stripping control bytes lets a split credential pass as two fragments and be rejoined on the way out. An unsplit pass is not evidence.
Expected behavior
The split form is redacted the same as the unsplit form. A regression test fails on current
mainfor the NUL-split case.Actual behavior
Unsplit: redacted. NUL-split: secret survives. After dropping the NUL, the original key is visible again.
Relevant logs, screenshots, or error messages
Strip/normalize control bytes first, then match. Add a split-case test (NUL and ESC). Do not treat an unsplit-only test as coverage.