Secrets
The patterns classifier detects content that has a recognizable shape, such as API keys, access tokens, and private keys, by matching regular expressions. It runs in-process, with no external service.
Configuration
classifiers:
secrets0:
type: patterns
options:
entropy: 3.0
labels:
secret.aws_key: "AKIA[0-9A-Z]{16}"
secret.github_token:
- "ghp_[A-Za-z0-9]{36}"
- "gho_[A-Za-z0-9]{36}"
secret.private_key: "-----BEGIN [A-Z ]*PRIVATE KEY-----"Each label maps to one regular expression, or a list of them. A label is detected when any of its expressions matches the text. Label names are your own, and are the names a classify model's reject refers to.
Filtering Placeholders
entropy sets the minimum Shannon entropy a match must have to count. It filters out matches that have the right shape but little randomness, such as the placeholder key AKIAXXXXXXXXXXXXXXXX. When it's omitted, every match counts.
Rejecting Secrets in Prompts
north_llm_proxy:
type: llm
kind: proxy
options:
guardrails:
gpt-4o-mini:
request:
- section: user-text
value:
model: classify
reject:
secrets0:
- secret.aws_key
- secret.github_tokenA prompt for gpt-4o-mini whose user text contains an AWS access key or a GitHub token is rejected with 400 before it reaches the provider. See LLM Guardrails.
Next Steps
- Classify: how the
classifymodel uses classifiers. - Personal Data: detect personal data with Presidio.
- patterns: the full
patternsclassifier reference.

