Skip to Content
AgentShield
Security

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
Arguments sent
{ "query": { "q": "status" }, "headers": { "Accept": "application/json" }, "api_key": "sk_live_…" }
Arguments stored
{ "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:

RuleSeverityDetects
EX001highPrivate keys (PEM and similar key material)
EX002highCloud and platform tokens: AWS, GitHub, Slack, OpenAI, Anthropic, Google, Stripe
EX003mediumJSON 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_alerts row per rule, with the agent, tool, resource, and path;
  • appends content.flagged to 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:

  1. 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 set Authorization.
  2. Keep secrets out of prompts. An agent that never sees a secret cannot leak it.
  3. Restrict destinations. SSRF controls and policy limit where an agent can send data.
  4. Hold outbound writes for approval. http.post to external systems in approval_required puts a person in front of data leaving.

Responding to a secret finding

  1. Open the alert in the console's Alerts section and review the evidence bundle.
  2. Rotate the leaked credential at its issuer.
  3. Review the agent's recent events for other outbound calls.
  4. Suspend the agent if its behavior is unexplained.
  5. Acknowledge, then resolve the alert. Each change is audited.

Was this page helpful?

On this page