Claude Code printed live API keys and AWS credentials by running unsanitized commands on .env

Claude Code executed bash commands such as grep and cut on .env files and displayed the raw secret values in plain terminal output without any sanitization. This occurred even when explicit rules in CLAUDE.md prohibited the model from revealing credentials. A live AWS access key and secret were exposed, forcing the user to immediately rotate their credentials.

Anthropic · Incident Mar 9, 2026 · Indexed Jun 4, 2026 · 3 sources

An agentic coding assistant ran grep on .env files and echoed the raw credentials straight to the terminal with no sanitization layer in between.
What
Claude Code executed bash commands such as grep and cut on .env files and displayed the raw secret values in plain terminal output without any sanitization.
Incident date
Mar 9, 2026
Who
Anthropic
Failure mode
Agentic Action Error
AI surface
Agentic Workflow
Severity
Medium

What happened

Claude Code repeatedly executed bash commands such as grep and cut on .env files, then displayed the raw secret values including AWS access keys and API tokens in plain terminal output. The model ignored explicit prohibitions written in CLAUDE.md and persistent memory files that instructed it never to reveal credentials. A live AWS access key and secret key were printed to the terminal, forcing the user to rotate credentials immediately. The issue was filed as a security bug but was ultimately closed as not planned.

What broke inside the model

Failure path · mode profile · Agentic Action Error
  1. 01 · TriggerAn agent plans a multi-step task.
  2. 02 · Model stepIt chooses a wrong or destructive action.
  3. 03 · Control gapNo confirmation gate guards the write.
  4. 04 · FailureThe action commits to a system of record.
  5. 05 · ConsequenceData is changed or destroyed irreversibly.

A wrong action commits, and the step is written before anything can stop it.

Claude Code displayed the full stdout of every bash command it executed without any filtering or redaction of credential-shaped strings. The agent also ignored explicit prohibitions defined in CLAUDE.md rules, failing to suppress output that matched secret patterns. The system lacked a sanitization layer between bash command output and terminal rendering, so any command that read credentials would echo them verbatim to the user.

Public visibilityMedium
Regulatory exposureNone
Customer impactFew customers
Financial impactUnknown
Time to disclosureMonths
  1. PrimarySECURITY: Claude Code reveals secret keys and credentials in terminal output despite explicit prohibitionsgithub.com
  2. PressClaude Code Security Best Practicesbackslash.security
  3. Social[Security] Claude Code reads .env files by defaultreddit.com
Permalinkhttps://failureindex.ai/failures/claude-code-printed-live-api-keys
CitationAI Failure Index. "Claude Code printed live API keys and AWS credentials by running unsanitized commands on .env" (FI-0101). Realm Labs. https://failureindex.ai/failures/claude-code-printed-live-api-keys (indexed Jun 4, 2026).
Share cardA branded image of this record for posts and slides.

Data fields CC-BY 4.0, prose citation permitted. Incident ID FI-0101. Full dataset at /data.

Note from Realm Labs, the Index steward

How Realm would have caught this

Controls for this failure mode
  • Prism
  • OmniGuard
  • AgentRealm

Realm can sit inline on the agent's action path and require that a destructive or high-consequence action clears a real check before it executes, so 'delete and recreate' or a wrong write is stopped at the moment of intent, not explained in the post-mortem.