Secret Detection
How AgentShield keeps secrets out of storage with redaction and flags secrets leaving in tool arguments with deterministic detection rules.
Secrets reach an agent system from two directions: operators put credentials in places they should not, and steered agents put secrets into outgoing requests. AgentShield handles both: redaction keeps secrets out of what it stores, and detection flags secrets in tool arguments.
Redaction before storage
Before arguments, results, or event payloads are stored or logged, the gateway replaces the value of every key that looks like a credential with "[REDACTED]". The match is case-insensitive on the key name:
password passwd secret token credential authorization
api_key / api-key / apikey private_key / private-key access_key / access-key{ "query": { "q": "status" }, "headers": { "Accept": "application/json" }, "api_key": "sk_live_…" }{ "api_key": "[REDACTED]", "headers": { "Accept": "application/json" }, "query": { "q": "status" } }The matcher is deliberately aggressive. A key such as token_count is redacted even though its value is not a credential; that is the preferred failure direction. Redaction applies recursively to nested objects and arrays. Invalid JSON is an error, and the error message does not include the input.
Redaction is for records. Signatures and approvals bind the raw body; the argument hash binds the canonical unredacted arguments.
Secrets in values are not redacted
Redaction looks at key names. A secret placed in a field named note is stored as written. Detection (below) is what flags it, and credential injection is what keeps tool secrets away from agents in the first place.
Detection in outgoing arguments
When content analysis is enabled, the intelligence engine checks every string in a successful call's arguments with three rules:
| Rule | Severity | Detects |
|---|---|---|
| EX001 | high | Private keys (PEM and similar key material) |
| EX002 | high | Cloud and platform tokens: AWS, GitHub, Slack, OpenAI, Anthropic, Google, Stripe |
| EX003 | medium | JSON Web Tokens |
Findings name the rule, severity, and the JSON path where the secret appeared, for example $.body.note. Secret findings never quote the matched text, so the alert itself does not become a second leak.
A finding:
- opens one
anomaly_alertsrow per rule, with the agent, tool, resource, and path; - appends
content.flaggedto the audit chain; - triggers an evidence bundle from the relay;
- is returned to the agent in
analysis.
It does not block the call. By the time analysis runs, the call has already executed. Detection exists so an operator learns that an agent sent a secret, and can rotate it.
Preventing secret exposure
Detection is the last line. The first lines are architectural:
- Inject tool credentials in the gateway. With
http.request, API tokens come from the gateway's environment through the tools file. Agents never hold them and cannot setAuthorization. - Keep secrets out of prompts. An agent that never sees a secret cannot leak it.
- Restrict destinations. SSRF controls and policy limit where an agent can send data.
- Hold outbound writes for approval.
http.postto external systems inapproval_requiredputs a person in front of data leaving.
Responding to a secret finding
- Open the alert in the console's Alerts section and review the evidence bundle.
- Rotate the leaked credential at its issuer.
- Review the agent's recent events for other outbound calls.
- Suspend the agent if its behavior is unexplained.
- Acknowledge, then resolve the alert. Each change is audited.
Implementation references
Was this page helpful?
SSRF Protection
How the http.request adapter and the network layer prevent agents from reaching internal services, cloud metadata endpoints, and unintended hosts.
Prompt Injection Analysis
How AgentShield detects indirect prompt injection in tool results, warns the model, alerts operators, and why detection is advisory by design.