Repository navigation
fix(redaction): scrub secrets assigned to prefixed names - #432
Merged
Merged
Conversation
The command scrubber's key=value pattern needed a word boundary right before the keyword, and `_` is a word character. So with command logging or full-argument capture on, HF_TOKEN=..., export HF_TOKEN="...", AWS_SECRET_ACCESS_KEY=..., DJANGO_SECRET_KEY=... and ?access_token=... in a URL were stored as typed. A quoted value slipped through even without a prefix, and a bare Hugging Face token had no pattern at all. The name may now carry a prefix, a quoted value is covered, SECRET_KEY and PRIVATE_KEY names are recognised, and hf_ tokens are masked anywhere. The name is kept; only the value goes. The hook's inline copy gets the same change and the existing drift test covers the new cases. max_tokens=, HF_TOKEN_PATH= and secret_name= are left alone, and an 8 KiB adversarial command still scrubs in milliseconds. Found while answering a Hugging Face forum question about the HF token rule. Both options are off by default. Collected count 2462 -> 2491. Ruleset fingerprint unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
With command logging or full-argument capture on (both off by default), the scrubber's
key=valuepattern required a word boundary right before the keyword._is a word character, so a prefixed name never matched and its value was stored as typed:HF_TOKEN=<value> hf upload ...export HF_TOKEN="<value>"AWS_SECRET_ACCESS_KEY=<value> aws s3 lsDJANGO_SECRET_KEY=<value> ...curl '...?access_token=<value>&page=2'hf_...token--token <value>,user:pass@hostChange
In
core/audit/redaction.pyand the hook's inline copy inhooks/ingest.py:[A-Za-z0-9_]*before the keyword); the name is kept, the value maskedsecret_keyandprivate_keynames are recognisedhf_tokens are masked anywhere, like the existing AWS, OpenAI, GitHub and Slack shapesTests
29 new cases in
tests/test_redaction.py: every input above against both the server and hook scrubbers, their agreement, names that only contain a keyword left alone (max_tokens=,HF_TOKEN_PATH=,secret_name=), and 8 KiB adversarial commands scrubbing well under a second (about 3 ms locally). Ruff passes. Collected count 2462 -> 2491.Existing trails
Trails written with either option on may already hold such values. The trail is hash-chained, so they cannot be removed without breaking verification; the remedy is rotating any credential that appears in one. The CHANGELOG says so.
Not a detection change; the ruleset fingerprint is unchanged.
🤖 Generated with Claude Code