fix(#6165): tighten auth_header redactor pattern to prevent JSON corruption - #6166
fix(#6165): tighten auth_header redactor pattern to prevent JSON corruption#6166fullsend-ai-coder[bot] wants to merge 2 commits into
Conversation
…uption
The auth_header structural pattern used \S{8,} as its capture group,
which matches any non-whitespace character including JSON structural
delimiters (", }, ], etc.). When the matched text reached the end of
a JSON string value, the capture group consumed the closing quote,
and mask() replaced it, destroying JSON validity.
Two changes to the regex:
1. Replace \S{8,} with [^\s"'}\]),;]{16,} — excludes JSON/YAML
structural delimiters from the capture group, preventing the
capture from eating past string boundaries.
2. Raise minimum match length from 8 to 16 — short technical
references like "token_value" in conceptual discussion of
auth headers are not real secrets. Real auth tokens are
almost always 20+ characters.
Added four test cases covering: false positive rejection on short
technical references, JSON structure preservation after redaction,
real secret detection, and the specific regression where \S ate
past JSON closing quotes.
Closes #6165
|
🤖 Finished Review · ✅ Success · Started 6:57 AM UTC · Completed 7:13 AM UTC Commit: |
ReviewFindingsLow
Previous runReviewFindingsLow
Labels: PR modifies internal security scanner/redactor code and fixes a documented bug |
|
/fs-fix fix CI issue and review comments |
|
🤖 Finished Fix · ✅ Success · Started 8:41 AM UTC · Completed 8:53 AM UTC Commit: |
The auth_header pattern change in the previous commit (8→16 char minimum, excluding structural delimiters) correctly stops the regex from double-masking already-redacted prefix output and eating the closing quote. Update TestExtractSafeContext to match the new (correct) behavior: the ghp_ prefix pattern redacts the token to "ghp_..." and the closing quote is preserved. Addresses review feedback on #6166
🔧 Fix agent — iteration 1 (human-triggered)Fixed CI failure caused by a test expectation that encoded the old buggy auth_header behavior (double-masking and quote-eating). The test now expects the correct output where the prefix pattern redacts the token and structural delimiters are preserved. Acknowledged the reviewer's low-severity finding about the 8-to-16 minimum as an intentional tradeoff per #6165. Fixed (1):
Disagreed (1):
Tests: passedNext steps:
|
|
🤖 Review · ❌ Terminated · Started 8:54 AM UTC · Ended 9:06 AM UTC Commit: |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
🤖 Finished Review · ✅ Success · Started 8:54 AM UTC · Completed 9:06 AM UTC Commit: |
Summary
Tightens the
auth_headerstructural pattern ininternal/security/redactor.goto fix two compounding bugs: (1) the\S{8,}capture group consumed JSON structural characters (",},]), corrupting JSON output aftermask()replaced the match, and (2) the 8-character minimum triggered false positives on short technical references in triage agent output discussing auth headers.Changes
(\S{8,})with([^\s"'}\]),;]{16,})in theauth_headerregex — excludes JSON/YAML structural delimiters from the capture group and raises the minimum match length from 8 to 16 characters\Seating past JSON closing quotes regressionTesting
internal/security/passgo vetpassesdefaultStructuralPatternsCloses #6165
Post-script verification
agent/6165-fix-auth-header-pattern)3c7f5d034d3f9ace8efd3608a6322903da907809..HEAD)