ByteChef LogoByteChef
AutomationWorkflowsAIAI AgentGuardrails

Secret Keys

Rule-based detection of API keys, tokens, and other credential-shaped strings.

Secret Keys finds API keys, access tokens, and other strings that look like credentials. It runs in the preflight stage and needs no model. Attach it under Check for Violations to block text that contains a secret, or under Sanitize Text to replace each secret with a <SECRET_TYPE> placeholder.

Properties

PropertyTypeDefaultDescription
Validate InputBooleantrueCheck the user input before it is sent to the model.
Validate OutputBooleantrueCheck the model response before it is returned.
PermissivenessStringBALANCEDHow aggressively to scan: Strict (STRICT), Balanced (BALANCED), or Permissive (PERMISSIVE). See Permissiveness levels.
Allowed File ExtensionsArray of stringsNoneLanguage tags of Markdown fenced code blocks to skip, for example py, js, ts. Detection still runs outside those blocks.

What it detects

Secret Keys combines four detectors. Each match is reported with a type:

TypeDetectsLevels
AWS_ACCESS_KEYAKIA followed by 16 charactersAll
AWS_SECRET_KEYA quoted 40-character value shortly after the word awsAll
GITHUB_PATghp_ followed by 36 charactersAll
GITHUB_FINE_GRAINED_PATgithub_pat_ followed by 82 charactersAll
SLACK_TOKENxoxa-, xoxb-, or xoxp- tokensAll
STRIPE_KEYsk_live_, sk_test_, pk_live_, or pk_test_ keysAll
GOOGLE_API_KEYAIza followed by 35 charactersAll
OPENAI_KEYsk- followed by at least 20 charactersAll
JWTThree dot-separated segments starting with eyAll
PREFIXED_SECRETAny token starting with key-, sk-, sk_, pk_, pk-, ghp_, AKIA, xox, SG., hf_, api-, apikey-, token-, or secret-All
HIGH_ENTROPY_TOKENRandom-looking strings. The thresholds depend on the level.All
GENERIC_SECRETAssignments such as api_key=..., secret: ..., token=..., password=... with a value of 16 or more charactersStrict only

Permissiveness levels

The levels differ in how the high-entropy detector judges a random-looking string, and in whether generic assignments are flagged.

LevelMinimum lengthMinimum entropy (bits per character)Minimum character classesGeneric assignments
Strict103.02Yes
Balanced (default)103.83No
Permissive304.02No

Character classes are lowercase letters, uppercase letters, digits, and symbols. In Balanced and Permissive, the high-entropy detector also skips the parts of http:// and https:// URLs and tokens that end in a common file extension, such as report.pdf. Use Permissive when your text legitimately contains long random IDs.

Results

  • Under Check for Violations (secretKeysCheck): one violation listing the matched types in info.providerTypes.
  • Under Sanitize Text (secretKeysSanitize): each match is replaced with <TYPE>, for example <GITHUB_PAT> or <HIGH_ENTROPY_TOKEN>.

Examples

Block known provider keys while tolerating long random IDs:

{ "name": "secretKeys_1", "type": "secretKeys/v1/secretKeysCheck", "parameters": { "permissiveness": "PERMISSIVE" } }

Scan broadly, but skip code blocks that users paste for debugging:

{
  "name": "secretKeys_1",
  "type": "secretKeys/v1/secretKeysCheck",
  "parameters": { "permissiveness": "STRICT", "allowedFileExtensions": ["py", "js", "ts", "json"] }
}

Mask any credential the model repeats in its response:

{
  "name": "secretKeys_1",
  "type": "secretKeys/v1/secretKeysSanitize",
  "parameters": { "permissiveness": "BALANCED", "validateInput": false }
}

Limitations

  • Allowed File Extensions only applies to fenced code blocks whose opening fence carries one of the listed tags, such as ```py. Inline code and code without a fence are scanned.
  • A token is a run of letters, digits, -, _, and .. A secret that contains other characters, such as / or +, is split and may not be detected by the high-entropy detector.
  • Bearer tokens in HTTP headers are not detected as a type of their own. Add a Custom Regex pattern such as Bearer\s+[A-Za-z0-9._\-]{20,}.
  • JWT detection checks the shape only, not the signature. Any three dot-separated segments starting with ey match.

How is this guide?

Last updated on

On this page