[BUG] Claude displayed sensitive .env credentials (API keys, secrets) in output when it should have redacted them.

Resolved 💬 4 comments Opened Jan 14, 2026 by alexbachlej Closed Mar 3, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Description:

When asked to read or verify environment configuration, Claude Code displays full contents of .env files including sensitive API keys and secrets in its output, without any redaction.

Steps to reproduce:

  1. Have a project with .env or .env.local containing API keys (e.g., STRIPE_SECRET_KEY, CLERK_SECRET_KEY)
  2. Ask Claude to check environment configuration or restart a service
  3. Claude runs commands like cat .env or grep on config files and displays full key values in response

Expected behavior:

  • Sensitive values should be redacted (e.g., sk_live_****)
  • Or Claude should use quiet checks (grep -q) without displaying values
  • Warning before displaying any .env content

Actual behavior:

  • Full credentials displayed in chat output
  • Keys saved to ~/.claude/projects//tool-results/.txt log files
  • No warning or redaction

Security impact:

  • Credentials exposed in terminal history
  • Credentials persisted in Claude's local cache files
  • Potential exposure if screen shared or logs accessed

Affected: Claude Code CLI (Opus 4.5)

What Should Happen?

Keys Should not be displayed or logged

Error Messages/Logs

```shell, bas


### Steps to Reproduce

  Description:

Steps to reproduce:
eg.
  1. Create a project with a .env file containing secrets:
  STRIPE_SECRET_KEY=sk_live_abc123xyz
  CLERK_SECRET_KEY=sk_live_def456
  2. Start Claude Code in that directory:
  claude
  3. Ask Claude to check the environment:
  "show me what's in .env"
  3. or
  "verify the stripe key is configured"
  3. or
  "restart the docker service and check env vars"
  4. Observe: Claude runs cat .env or grep and displays full key values in output without redaction
  5. Check Claude's cache:
  grep -r "sk_live_" ~/.claude/projects/
  5. Keys are persisted in tool-results files




### Claude Model

None

### Is this a regression?

I've noticed this before, so this is ongoing bug

### Last Working Version

_No response_

### Claude Code Version

 2.1.7 (Claude Code)

### Platform

Anthropic API

### Operating System

Ubuntu/Debian Linux

### Terminal/Shell

Other

### Additional Information

Description:

  Workaround:
  User must manually delete cached files:
  grep -r -l "sk_live_\|pk_live_\|whsec_" ~/.claude | xargs rm -f

  Related concerns:
  - No prompt asking user before displaying .env contents
  - No .claudeignore or similar mechanism to protect sensitive files
  - Secrets remain in cache even after session ends
  - Screen sharing / pair programming risk

  Suggested fix:
  - Auto-detect common secret patterns (sk_live_, pk_test_, whsec_, API_KEY=, SECRET=)
  - Redact values or require explicit confirmation before display
  - Add .env* to a default "sensitive files" list

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗