Skip to content

security: RedactString misses secrets split by a NUL or ESC #969

Description

@michaelkillgta

Version / branch / commit

main at 27b319c (current origin/main)

OS and environment

Windows 10. Static review of internal/redaction; no provider call required.

Steps to reproduce

  1. Take a key that the shape matcher already catches, e.g. sk-ant-api03-abcdefghijklmnopqrstuvwxyz0123456789ABCD.
  2. Call RedactString on the unsplit value → it redacts.
  3. Insert a NUL (or ESC) in the body, e.g. sk-ant-api03-\x00abcdefghijklmnopqrstuvwxyz0123456789ABCD.
  4. Call RedactString again → no match.
  5. Strip the control byte from the result → the two fragments rejoin into the original secret.
    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 main for 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingissue-approvedReviewed and approved by the core team; community PRs may implement this issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions