# What is secret detection for LLMs?

Secret detection finds API keys, passwords, tokens and private keys in prompts, responses and tool calls, and stops them before they are stored, shown or sent somewhere they should not go.

## Where secrets show up

- **In prompts.** A developer pastes a config file or a stack trace with a key in it.
- **In context.** An agent reads `.env`, a credentials file or a CI log.
- **In responses.** The model repeats a key it saw earlier, sometimes to another user.
- **In tool calls.** A key goes out in a URL, a header, a commit or a message.

The last one is the dangerous one: see [data exfiltration](/glossary/data-exfiltration).

## How it is detected

- **Patterns.** Many keys have a known shape, such as a fixed prefix and length.
- **Entropy.** Long random strings where none is expected.
- **Context.** A value next to `password=` or inside an `Authorization` header.
- **Meaning.** A model that reads the surrounding text tells a real key from an example in documentation.

Patterns alone miss custom secrets and flag every sample key in a tutorial.

## What to do with a match

Redact it and carry on, block the request, or hold the tool call. Redacting keeps the conversation working, as with [PII redaction](/glossary/pii-redaction). Then rotate the key: a secret that reached a log should be treated as leaked.

## With White Circle

[Control](/products/control) checks prompts, responses and tool calls against your policies. A policy such as "the agent does not send credentials to an outside server" is enforced before the call runs.

