Developer Security5 min read·

Scrubbing API Keys, JWTs & High-Entropy Secrets Before Pasting Logs into AI

Pasting production stack traces or .env files into AI debugging tools routinely leaks database passwords and internal tokens. Prefix-only filters miss custom vendor keys unless entropy checks run too.

Why Prefix-Only Regexes Miss Internal Service Tokens

Standard secret scanners match known prefixes like sk-proj-, AKIA, AIza, or eyJ JWT structures. That catches common cloud vendors, yet proprietary webhook secrets, staging API keys, and custom OAuth tokens often use plain 32-to-64-character base64url strings with no vendor prefix.

Meanwhile, aggressively blocking generic alphanumeric strings wrecks stack traces by masking ordinary CamelCase class names or documentation words.

Dev Logs sanitization output
Before
Authorization: Bearer xK9mP4qR8vT2wZ7nL5jF3hB6cD1gN9yV0aS
DB_URL=postgres://admin:S3cr3tPass!@prod-db.internal:5432/billing
After
Authorization: Bearer [SECRET_1]
DB_URL=[SECRET_2]

Layering Context Patterns + Shannon Entropy (>= 4.25 bits)

Maskry’s Dev Logs preset pairs four complementary detection layers while keeping People & Company names disabled so stack traces stay readable:

  • Structured Credential Blocks: Matches PEM private keys, OpenAI/Anthropic/Stripe/GitHub/AWS prefixes, JWTs, and postgres/mysql/mongodb/redis connection URIs with embedded passwords.
  • Header & Assignment Capture: Isolates secrets following Authorization: Bearer, api_key=, secret_key=, access_token=, or password=.
  • Shannon Entropy Gate: Computes bit entropy per character across long mixed-case alphanumeric tokens (32-128 chars, >= 4.25 bits/char with uppercase, lowercase, and digits) to catch unprefixed proprietary secrets without flagging normal English prose.
  • ReDoS-Safe Custom Regexes: Teams can add internal ID rules while automatic validation blocks catastrophic nested quantifiers like (a+)+ before execution.

Key Takeaways

  • ✓Always scrub connection URIs, Bearer headers, JWTs, and unprefixed high-entropy tokens together.
  • ✓Turn off People & Org heuristics when debugging logs so class names and technical terms remain intact.
  • ✓Verify final output before pasting, and rotate any credential that may already have leaked locally or in CI.
Run It Locally in Your Browser

Load the Dev Logs preset to preserve code context while stripping keys, DB URLs, JWTs & IPs.

Open Dev Logs Masker →

Related Guides

All guides →