Secret detection
Flag, redact or block credentials in coding-agent traffic before they reach the model provider.
Coding agents read .env files, dump environment variables and paste tokens into prompts. Secret detection scans every request on the gateway and flags, redacts or blocks credentials before they reach the model provider. No agent or CLI change is needed.
Available on the Team plan and above. Open Security in the console sidebar.
| Tab | Who | Purpose |
|---|---|---|
| Secrets | Members with access to detections; admins mark false positives | Review and filter detections |
| Secret detection | Members who can view organization settings; admins edit | Enable scanning, choose the mode and actions, add custom rules and allowlists |
What is scanned
The gateway scans each request right after it authenticates the key, before routing, compression, debug-log capture or the provider call. Nothing downstream sees a redacted value: not the routing classifier, not debug logs, not the provider.
Scanned surfaces:
| Surface | Includes |
|---|---|
| User message | Text the developer or agent sends |
| System prompt | System prompt and instructions |
| Tool result | tool_result / function_call_output, e.g. a file read or a shell output |
| Tool call | tool_use / function_call arguments |
Not scanned or never modified:
- Model responses.
- Images, documents and other media blocks.
- Signed
thinking/redacted_thinkingblocks. Editing them would break the upstream call, so a hit there is reported as Flag with the reason Signed block.
Scanning is inline and fast: a 200 kB transcript scans in a few milliseconds, and history resent on the next turn is served from a cache.
Actions
Each hit gets one action:
| Action | Effect |
|---|---|
| Flag | Forward unchanged and report the hit. |
| Redact | Replace the value before it reaches the provider. |
| Block | Reject the request with HTTP 422. |
A redacted value keeps its known prefix and the last four characters, e.g. sk_live_[REDACTED:stripe-live:a91f]. The replacement is deterministic: the same content yields the same output on every turn, so the provider prompt cache stays warm.
A blocked request returns:
{
"error": {
"type": "secret_detected",
"rule_id": "aws-access-key",
"message": "..."
}
}
Defaults
When no action is set for a severity, the gateway uses:
| Severity | Default action |
|---|---|
| Critical | Redact |
| High | Flag |
| Medium | Flag |
| Low | Flag |
A per-rule action overrides the severity action. A severity-level Block is downgraded to Flag for High-entropy string unless you set Block on that rule explicitly.
Modes
| Mode | Behavior |
|---|---|
| Enforce | Default when enabled. Apply configured actions immediately on save; no grace period. |
| Monitor | Report every hit as flagged. Nothing is redacted or blocked. Never switches to Enforce automatically. |
Start with Monitor to measure volume and false positives on real traffic, then switch to Enforce. Events recorded in Monitor show the reason Monitor mode.
Set up secret detection
Enable scanning
Open Security → Secret detection. Turn on Scan agent traffic, choose Monitor for a first rollout, then Save.
Review detections
Let agents run, then open Security → Secrets. Check which rules fire, on which surface and for which members.
Tune rules and allowlists
Disable noisy rules, add allowlist patterns or mark individual values as false positives. Add custom rules for internal credential formats.
Enforce
Set Actions by severity and any per-rule overrides, select Enforce and Save. Actions apply to the next request.
Each section of the settings page saves on its own. A policy change applies to the full conversation history on the next request, which causes one prompt-cache miss for active sessions.
Built-in rules
Rules fall into three classes:
- Known formats: fixed prefixes such as
AKIAorghp_. Near-zero false positives. - Keyword assignments:
password=,api_key:and similar, with an entropy check on the value. - High-entropy strings: random-looking values. Flag-only by default; the threshold scales with length.
| Rule | ID | Default severity |
|---|---|---|
| AWS access key | aws-access-key | Critical |
| AWS secret key | aws-secret-key | Critical |
| GitHub token | github-token | Critical |
| GitHub fine-grained PAT | github-fine-grained-pat | Critical |
| GitLab token | gitlab-token | Critical |
| Stripe live key | stripe-live | Critical |
| Stripe webhook secret | stripe-webhook-secret | High |
| Anthropic API key | anthropic-key | Critical |
| OpenAI API key | openai-key | Critical |
| Google API key | google-api-key | High |
| Hugging Face token | huggingface-token | High |
| Groq API key | groq-key | Critical |
| xAI API key | xai-key | Critical |
| Edgee API key | edgee-key | Critical |
| Slack token | slack-token | High |
| Private key | private-key | Critical |
| Database URL with password | db-url-with-password | High |
| JSON Web Token | jwt | Medium |
| Bearer token | bearer-token | High |
| Keyword assignment | keyword-assignment | High |
| High-entropy string | generic-entropy | Low |
Context rules
Context rules detect risky agent behavior rather than a value. They always Flag, whatever action is configured, and they are not file-access controls.
| Rule | ID | Default severity |
|---|---|---|
| Sensitive file read | ctx-sensitive-file-read | High |
| Environment dump | ctx-env-dump | High |
| Dotenv-shaped output | ctx-dotenv-shape | Medium |
When enabled, a context rule also marks the linked tool result as sensitive, which lowers the keyword and entropy thresholds for values inside it. Disabling the rule removes both effects.
Custom rules
Add patterns for internal credential formats under Security → Secret detection → Custom rules. Custom rules run next to the built-in ones and accept the same per-rule actions, disabling and allowlists.
| Field | Constraint |
|---|---|
| Name | Up to 80 characters. Shown in the console only. |
| Rule ID | Generated from the name: custom- + up to 48 of a-z, 0-9, -. Unique. |
| Pattern | Rust regex syntax, up to 512 characters, unanchored. No lookaround or backreferences. |
| Severity | Critical, High, Medium or Low. Defaults to High. |
The redacted value is capture group 1 when the pattern has one, the whole match otherwise. Example:
\b(acme_[a-z0-9]{32})\b
Use Test against a sample to paste text and see what each rule would catch. Nothing is sent or saved.
Limits: 50 custom rules per organization. When matches overlap, precedence is known formats → custom rules → keyword assignment → high-entropy string. The gateway skips an invalid rule; it never fails a request because of one.
Allowlists and false positives
Three ways to silence a hit:
| Method | Where | Scope |
|---|---|---|
| Value patterns | Secret detection → Allowlist | Regex matched against the whole value, e.g. sk_test_.*. Same syntax as custom rules. One per line. |
| File paths | Secret detection → Allowlist | Glob (*, **) on the source path of a tool result, e.g. fixtures/**. Hits from those files are ignored. |
| False positives | Secrets → row actions | One exact value, across all rules in the organization. Admins only. |
Marked false positives are listed under Secret detection → False positives, where admins can remove them.
Review detections
Security → Secrets shows summary counts (Detected, Critical, Redacted, Blocked) and the detection list with Time, Rule, Severity, Action, Surface, Value, Source, User and Session. Filter by period, severity, rule and action.
A session page also shows the secrets detected in that session.
Event semantics:
- One event per distinct value and rule in a request, with the strongest action applied (Block > Redact > Flag).
- Within a session, a value already reported is not reported again. Blocked requests always produce an event, including retries.
- Reason explains a downgraded action: Monitor mode, Signed block or Allowlisted path.
Limits
- Model responses are not scanned.
count_tokensrequests are redacted with the same policy but never blocked and produce no events.- Cursor relay traffic and structured decision endpoints are not scanned.
- Secret detection reduces credential exposure; it does not replace secret scanning in your repositories or rotating a leaked credential.
Troubleshooting
| Symptom | Check |
|---|---|
| Security missing from the sidebar | Organization uses the Agent Gateway |
| Settings read-only | Admin role required to edit |
| Upgrade prompt shown | Team plan or above |
| No detections | Scan agent traffic is on and saved; agents run through Edgee |
| Hits flagged, not redacted | Mode is Monitor, the hit is in a signed thinking block, or it comes from a context rule |
| Agent receives HTTP 422 | A Block rule matched the latest message. Remove the secret and resend |
| Custom rule never matches | Test it with Test against a sample; check for unsupported syntax such as lookaround |
Related: organization, sessions, debug logs.