feat: widen the paste rules to cover cloud env vars and PEM keys - #35
Merged
Merged
Conversation
Read Claude Code's own detector to see what it catches. It ships a table of 59 regexes tagged high or low confidence, picks a tier by the direction the data is travelling -- both tiers outbound to telemetry, high only for anything shown to a person -- and has no entropy-based detection at all, which confirms the limit already written down here. Three of its rules were missing on our side: - Cloud environment variables. NOT copied as-is: their rule redacts the value of anything matching AWS_|GOOGLE_|AZURE_, which is free for telemetry but would strip AWS_REGION=us-east-1 and AWS_PROFILE=default out of a paste, and an agent that cannot see your region cannot answer the question. Narrowed to names carrying SECRET, KEY, TOKEN, PASSWORD or CREDENTIAL. - PEM private keys, as a whole block. Previously only caught inside a JSON value, so pasting the file itself went through. The END marker is required so prose mentioning -----BEGIN PRIVATE KEY----- survives. - GOCSPX- client secrets, the A3T access-key prefix, and AWS's base32 alphabet. Their low-confidence tier is deliberately left out: sensitive-assign fires on password, token, cookie and authorization, which would damage the code you paste for review. termit's paste is read for meaning by a person and an agent, so it follows redactForDisplay, not redact. Redaction is now idempotent and the count honest: a value already reading [redacted] is neither re-counted nor re-replaced, so overlapping rules on AWS_ACCESS_KEY_ID=AKIA... report one secret, not two. Co-Authored-By: Claude Opus 5 (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.
Follow-up to #34, after reading Claude Code's own credential detector.
What Claude Code actually does
Inspected the shipped binary (
~/.local/share/claude/versions/2.1.273). It carries a table of 59 regexes, each{id, source, flags, confidence}, and:entropyappears only in Node internals and in the prose of themaskDuplicatesdocs. This confirms the limit already stated in our README — a bare AWS secret key is not detectable, and Anthropic reached the same conclusion.(?P<secret>…)here, and as the sandbox'sextractsetting.Over-redact on the way out; under-redact on the way to a reader. Their value pattern even matches
[REDACTED]itself, so re-running is safe.Worth noting: per the data-usage docs, this detector runs on telemetry,
/feedbackbundles and transcript uploads only — "Source code, file contents, and other conversation content are uploaded as-is." The path to the model is covered by user-declared rules instead (Read(./.env)deny rules, sandboxmask). termit's paste boundary sits in that gap.The three rules taken
1. Cloud environment variables — narrowed, not copied. Theirs redacts the value of anything matching
AWS_|GOOGLE_|GCP_|GCLOUD_|AZURE_. Free for telemetry; wrong here. It would stripAWS_REGION=us-east-1andAWS_PROFILE=defaultout of your paste, and an agent that cannot see your region cannot answer the question you asked. Narrowed to names carrying SECRET, KEY, TOKEN, PASSWORD or CREDENTIAL — there is a test asserting plain cloud settings arrive untouched.2. PEM private keys, whole. Previously only caught inside a JSON value, so pasting the key file itself went straight through. The
-----END …-----marker is required, so prose mentioning-----BEGIN PRIVATE KEY-----is not swallowed to the end of the paste.3.
GOCSPX-client secrets, theA3Taccess-key prefix, and AWS's base32 alphabet[A-Z2-7].Deliberately not taken: the low-confidence tier
sensitive-assignfires onpassword,token,cookie,authorization,session_id,connection_string. That is right for telemetry and wrong for a paste that a person and an agent both read for meaning — it would damage the code you paste for review. termit's paste followsredactForDisplay, notredact.Also fixed
Redaction is now idempotent and the count honest. A span already reading
[redacted]is neither re-counted nor re-replaced, soAWS_ACCESS_KEY_ID=AKIA…— which matches both the prefix rule and the variable-name rule — reports one secret rather than two.Test
231 pass (up from 224), 1 ignored. clippy
-D warningsandfmt --checkclean. Seven new tests: cloud env vars redacted, plain cloud settings byte-for-byte unchanged, a PEM block redacted whole with the surrounding sentences kept, an unterminated PEM left alone,GOCSPX-, no count inflation from overlapping rules, and redacting twice being a no-op. The README's rule list is regenerated from the shipped defaults and pinned to them by the existing test.docs/references/paste.mdrecords the investigation.🤖 Generated with Claude Code