Zenaique

Identify what a secrets scanner blocks in user input

Fill in blank·Easy·4.0 · 0·~1 min·Asked atCoinbaseJasperMeesho
Attempt it
An input secrets scanner uses regular expressions and entropy heuristics to detect strings that look like , for example AWS access keys, GitHub tokens, JWT secrets, and database connection strings, and either redacts them or blocks the request before the model ever sees the value.
TL;DR

Secrets-scanners detect API keys, tokens, and credentials in user input via regex and entropy heuristics, then redact or block before the prompt reaches the model.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

Imagine you have a smart helper who reads every message you send, then forwards it to a stranger across town to get an answer. One day you accidentally paste your house key, your bank PIN, and your safe combination into the message. The stranger now has all of them. A secrets-scanner is a friend standing at the door who recognises what house keys and PINs look like (the shape, the length, the weird mix of characters), and either covers them with a black marker or refuses to send the letter at all. The friend cannot prevent you from pasting them in, but they can stop the leak before it reaches the stranger.

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

Every LLM-powered application has a chokepoint problem with secrets. Users paste API keys, tokens, database connection strings, and private keys into prompts as part of their work, sometimes deliberately ("help me debug this auth error") and sometimes by accident (a copy-paste from a config file). Once those secrets enter the prompt, they propagate: to the third-party LLM API, to the request log, to the observability platform, to the conversation history.

An input secrets-scanner is the deterministic input rail that exists to break that propagation. This deep dive walks through what categories it detects, how regex plus entropy detection works, where it has to run in the request path, and what failure modes are worth pre-empting.

What counts as a secret

The category covers anything that grants authentication or access:

  • Provider API keys. AWS (AKIA-prefix access keys, ASIA-prefix temporary credentials), GCP service-account JSON, Azure shared keys, OpenAI (sk-prefix), Anthropic (sk ant prefix), Stripe (sk_live_, sk_test_), Twilio, SendGrid, Slack tokens.
  • Source-control tokens. GitHub PATs (ghp_, ghs_, github_pat_), GitLab tokens (glpat-), Bitbucket app passwords.
  • Authentication tokens. JWTs (three base64 segments dot-separated), OAuth bearer tokens, session cookies with high-entropy values.
  • Database credentials. Connection strings with embedded passwords (postgres://user:pass@host), MongoDB URIs (mongodb+srv://), Redis URLs with auth.
  • Cryptographic material. SSH private keys (-----BEGIN OPENSSH PRIVATE KEY-----), PGP keys, TLS private keys.
  • Custom internal credentials. Tenant-specific tokens, internal-API keys, system of record account references.

Good scanners ship 200-400 provider-specific patterns out of the box and let teams add tenant-specific regexes for internal formats.

The two-pass detection model
Where in the request path the scanner runs
Redact vs block, and the tuning failure modes
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.

Real products, models, and research that use this idea.

  • GitHub push-protection uses the same regex library to detect secrets in commits before they reach the remote repository
  • AWS Bedrock Guardrails sensitive-information filter includes regex patterns for AWS credentials, AKIA-prefix keys, and IAM tokens
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QHow would you tune a secrets-scanner to minimise false positives without missing critical credentials in a multi-tenant SaaS?
A

Layer the patterns: ship the provider-default library at high precision (AKIA-prefix, ghp_, sk_live_), add per-tenant regexes for internal formats with tenant-specific tests, and put the entropy fallback at a higher threshold with a redact-only action. Maintain a synthetic-secrets test corpus in CI that exercises both classes.

1 more follow-up an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Relying only on the model's RLHF to refuse to repeat secrets, rather than scanning the input before it reaches the model and a third-party API.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • What categories of strings a secrets-scanner detects

  • The two detection techniques (regex patterns and entropy heuristics) and what each catches

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
Pick the strongest reason…
MCQ·Medium