Skip to content

fix(redaction): scrub secrets assigned to prefixed names - #432

Merged
blitzcrieg1 merged 1 commit into
masterfrom
fix/scrub-inline-secret-assignments
Nov 15, 2026
Merged

blitzcrieg1 merged 1 commit into
masterfrom
fix/scrub-inline-secret-assignments

Conversation

@blitzcrieg1

Copy link
Copy Markdown
Owner

Problem

With command logging or full-argument capture on (both off by default), the scrubber's key=value pattern 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:

Input Before
HF_TOKEN=<value> hf upload ... stored
export HF_TOKEN="<value>" stored
AWS_SECRET_ACCESS_KEY=<value> aws s3 ls stored
DJANGO_SECRET_KEY=<value> ... stored
curl '...?access_token=<value>&page=2' stored
a bare hf_... token stored
--token <value>, user:pass@host already masked

Change

In core/audit/redaction.py and the hook's inline copy in hooks/ingest.py:

  • the name may carry a prefix ([A-Za-z0-9_]* before the keyword); the name is kept, the value masked
  • an opening quote before the value is allowed
  • secret_key and private_key names are recognised
  • hf_ tokens are masked anywhere, like the existing AWS, OpenAI, GitHub and Slack shapes

Tests

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

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]>
@blitzcrieg1
blitzcrieg1 merged commit 03c47dc into master Nov 15, 2026
11 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 15, 2026
@blitzcrieg1
blitzcrieg1 deleted the fix/scrub-inline-secret-assignments branch November 15, 2026 08:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant