feat: mask shape-recognizable secrets before send - #16
Merged
Conversation
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Redact API keys, tokens, and private keys from trace content before it leaves the machine. On by default; CODE_TRACE_MASK_SECRETS=false disables. - src/mask.rs: curated high-precision regex ruleset, ordered so specific rules (sk-ant-) run before generic ones (sk-); mask_str + recursive mask_value over JSON - emit.rs: mask user text, assistant text, tool inputs (incl. structured JSON, previously passed through raw) and tool outputs before truncate; fold redaction counts into *_meta - adds the regex crate - best-effort limitation documented in README Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Redacts shape-recognizable secrets (API keys, tokens, private keys) from trace content before it is sent to Langfuse. On by default;
CODE_TRACE_MASK_SECRETS=falsedisables.src/mask.rs: curated high-precision regex ruleset (near-zero false positives), ordered so specific rules (sk-ant-) run before generic ones (sk-). Covers PEM private keys, AWS key ids, GitHub/Slack/Google/Stripe/Anthropic/OpenAI tokens, JWTs,Bearerheaders, and URL-embedded credentials. Exposesmask_strand a recursivemask_valuefor JSON.emit.rs: masks the user prompt, assistant reply, tool results, and tool inputs beforetruncate(). This closes a gap where structured JSON tool inputs (e.g.{"command": ...},Write's{"content": ...}) were emitted raw. Per-field redaction counts fold into the existing*_metaas"redacted": N.regexcrate.Best-effort by design: catches shaped secrets, misses novel/unstructured ones.
pauseand the git-repo gate remain the airtight privacy controls. Documented in the README.Design doc:
docs/superpowers/specs/2026-07-21-mask-secrets-design.md.