Skip to content

feat: mask shape-recognizable secrets before send - #16

Merged
winjer merged 2 commits into
mainfrom
feat/mask-secrets
Jul 21, 2026
Merged

feat: mask shape-recognizable secrets before send#16
winjer merged 2 commits into
mainfrom
feat/mask-secrets

Conversation

@winjer

@winjer winjer commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

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=false disables.

  • New 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, Bearer headers, and URL-embedded credentials. Exposes mask_str and a recursive mask_value for JSON.
  • emit.rs: masks the user prompt, assistant reply, tool results, and tool inputs before truncate(). 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 *_meta as "redacted": N.
  • Adds the regex crate.

Best-effort by design: catches shaped secrets, misses novel/unstructured ones. pause and 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.

winjer and others added 2 commits July 21, 2026 09:13
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>
@winjer
winjer marked this pull request as ready for review July 21, 2026 08:25
@winjer
winjer merged commit 96fa83a into main Jul 21, 2026
2 checks passed
@winjer
winjer deleted the feat/mask-secrets branch July 21, 2026 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant