Skip to content

Security: Claude displays full credential file contents when checking for stored tokens #34819

Closed as not planned

Description

@hyperpolymath

Security Incident Report — Credential Exposure in Conversation

Summary

Claude Opus 4.6 (1M context) displayed the full contents of a user's ~/.netrc file and other credential stores in a conversation response, exposing multiple API keys and tokens.

What Happened

  1. User asked "which publish things do you need from me? is it not in the .netrc?"
  2. Claude ran: cat ~/.netrc 2>/dev/null | grep -E "machine|login" | head -10
  3. The grep pattern matched "machine" and "login" lines but the .netrc format interleaves passwords on the SAME lines or adjacent lines
  4. Claude ALSO ran cat ~/.npmrc and cat ~/.cargo/credentials.toml in the same command
  5. The full output including passwords, API tokens, and auth tokens was displayed in the conversation
  6. Multiple service credentials were exposed: GitHub PAT, GitLab PAT, Bitbucket app password, Cloudflare API key, Fly.io token, npm token, Codeberg token, and server credentials

What Should Have Happened

Claude should have:

  • Run test -f ~/.netrc && echo "netrc exists" || echo "no netrc" to check existence only
  • Run grep -c "machine" ~/.netrc to count entries without showing values
  • NEVER used cat on credential files
  • Used wc -l or existence checks instead of content display
  • Treated ~/.netrc, ~/.npmrc, ~/.cargo/credentials*, and similar files as SENSITIVE — equivalent to .env files

Root Cause

The system prompt says "Do not commit files that likely contain secrets (.env, credentials.json, etc)." but this protection only covers git commits. There is no equivalent guardrail for DISPLAYING credential file contents via the Read tool or Bash cat/grep commands.

Credentials Exposed

  • GitHub Personal Access Token
  • GitLab Personal Access Token
  • Bitbucket API Token
  • Cloudflare API Key
  • Fly.io deployment token
  • npm registry auth token
  • Codeberg access token
  • Two server credentials (hostname + login)

Recommended Fixes

  1. Add ~/.netrc, ~/.npmrc, ~/.cargo/credentials*, ~/.docker/config.json, ~/.kube/config to a "never display contents" list alongside .env
  2. When a user asks "is X in my credentials file?" — check existence and entry count, never show values
  3. The grep pattern grep -E "machine|login" on .netrc is dangerous because password lines are adjacent/interleaved
  4. Consider adding a pre-execution check for Bash commands that would cat, head, tail, grep or Read known credential file paths

User Impact

User was advised to rotate all exposed credentials immediately.

Session Context

  • Model: Claude Opus 4.6 (1M context)
  • Session: Multi-hour development session (~8 hours)
  • The credential check was the last action in a very long session (potential fatigue/reduced caution in long contexts)

How This Report Was Generated

This incident was identified and reported through PanLL's Feedback-o-Tron — a neurosymbolic feedback analysis system that is part of the PanLL eNSAID development environment. The Feedback-o-Tron operates as a cognitive governance component within PanLL's Binary Star architecture, where human operators and AI agents collaborate through a three-panel model:

  • Panel-L (Symbolic) detected the constraint violation: credential file contents should never be displayed
  • Panel-N (Neural) — Claude itself — generated the detailed incident analysis and remediation recommendations
  • Panel-W (World) — the shared workspace where the exposure was observed in real-time

The Feedback-o-Tron aggregates friction signals (security violations, UX failures, constraint breaches) and routes them through a Safety Triangle pipeline:

  • Eliminate (≥0.95 confidence) — auto-fix without review
  • Substitute (≥0.85 confidence) — suggest proven alternatives
  • Control (<0.85 confidence) — human review required (this report)

This particular incident was classified as Control — requiring human-initiated reporting — because the exposure had already occurred and could not be automatically remediated. The Feedback-o-Tron's structured incident format (Summary → What Happened → Root Cause → Recommendations) is generated by PanLL's cognitive governance stack, which includes the Vexometer (friction monitoring), Anti-Crash Gate (constraint validation), and Orbital Drift Aura (stability tracking).

PanLL and the Feedback-o-Tron are open source: github.com/hyperpolymath/panll

Activity

  1. github-actions commented on Mar 16, 2026

    @github-actions

    Found 3 possible duplicate issues:

    1. SECURITY: Claude Code reveals secret keys and credentials in terminal output despite explicit prohibitions #32523
    2. [BUG] Claude Code reads process environments and hardcodes credentials in terminal output #30731
    3. [BUG] Claude Code reads .env files and hardcodes secrets into inline scripts #24185

    This issue will be automatically closed as a duplicate in 3 days.

    • If your issue is a duplicate, please close it and 👍 the existing issue instead
    • To prevent auto-closure, add a comment or 👎 this comment

    🤖 Generated with Claude Code

  2. hyperpolymath commented on Mar 16, 2026

    @hyperpolymath
    Author

    Reviewed the three suggested duplicates:

    #32523 — "Claude reveals secret keys in terminal output despite CLAUDE.md prohibitions"
    Related but different. That issue is about Claude ignoring explicit CLAUDE.md rules prohibiting credential display. Our issue is about the absence of any built-in guardrail for credential files like ~/.netrc, ~/.npmrc, ~/.cargo/credentials. Even without a CLAUDE.md rule, Claude should treat these files the same way it treats .env files. The system prompt says "Do not commit files that likely contain secrets" but has no equivalent for displaying their contents.

    #30731 — "Claude reads process environments and hardcodes credentials"
    Related but different scope. That's about process.env and environment variables leaking into generated code. Our issue is specifically about reading credential storage files (~/.netrc with passwords, ~/.npmrc with auth tokens) via cat/grep and displaying the full contents.

    #24185 — "Claude reads .env files and hardcodes secrets into inline scripts"
    Closest match — .env reading is the same class of problem. However, our report adds new credential file paths not covered by that issue: ~/.netrc, ~/.npmrc, ~/.cargo/credentials, ~/.docker/config.json, ~/.kube/config. The .env issue focuses on project-level files; ours is about user home directory credential stores which are arguably more dangerous (they contain cross-project tokens for GitHub, GitLab, Cloudflare, npm, etc.).

    Recommendation: This issue should remain open as it:

    1. Identifies credential file paths not mentioned in any of the three duplicates
    2. Provides a specific reproduction case (user asks "is it in .netrc?" → Claude cats the file)
    3. Includes concrete remediation recommendations (existence checks instead of content display)
    4. Documents the actual credential types exposed (8 different service tokens)

    If the team prefers consolidation, #24185 would be the best target — but it would need expanding to cover ~/.netrc and other home-directory credential stores.

    👎 (voting against auto-closure)

  3. voyageport commented on Mar 24, 2026

    @voyageport

    I can't believe Athropic allows this to happen. There are so many reports, apparently, according to CC, leaking credentials in .env is even broader than this bug:

    Here is my incident:

    Me: so have you leaked ALL of my api keys in my .env files?

    CC: Now to your question — yes, in this conversation I have seen secrets from your .env files.

    Every secret that appeared in my tool output in this conversation is now in the transcript. That includes your OpenAI,
    Google Maps, RapidAPI, Resend, webhook secret, and test admin password.

    How it happened: I read your .env files to find the Resend key, but I read wide ranges of lines instead of surgically grepping
    for just the Resend pattern. Every line I read became part of this conversation's context, which gets stored in transcript
    history.

    What API keys you need to rotate (everything I saw):

    ❯ what happens to the transcrips? How can people access my claude transcripts?

    ● I want to be honest: I don't have complete knowledge of how Anthropic handles Claude Code transcripts, and I don't want to
    guess on something this important. Here's what I can tell you and what you should verify directly.

    What I know

    • Local storage: Conversations are stored on your machine in ~/.claude/ (you can check this yourself)
    • Anthropic's servers: Conversation data is sent to Anthropic's API for processing. Their data retention and access policies
      govern what happens to it

    What I don't know for certain

    • Exactly how long transcripts are retained server-side
    • Who at Anthropic can access them
    • Whether transcripts are used for training (there are settings for this)
    • What Resend meant specifically when they said "claude transcript history"
  4. hyperpolymath commented on Mar 24, 2026

    @hyperpolymath
    Author

    After it did so I had to say 'you need to report that as a bug', without it proposing that I did so I have no doubt I am not alone and this is hugely under-reported.

    For what it is worth, since that happened, I've had a go at working on a free/open source idea called RGTV (Reasonably Good Token Vault - yes, a play on Pretty Good Privacy).

    https://github.com/hyperpolymath/reasonably-good-token-vault.

    It's certainly not at production level, but an initial response to the issue which is IMMENSELY concerning with how deeply embedded AI is even on a personal system, let alone enterprise and sensitive areas of industry. I don't consider token vaults as being my 'Destiny' so I'm not sure how much time I have to work on this as a major project, but it is all under PMPL - a variant of Mozilla Public License, and just my initial response to this problem, rather than an advert for a product.

    Sadly, Anthropic - or any of these things - are obviously not inherently safe designs, and so I do think there's going to be an extent to which this has to be done with by others in the security industry.

  5. github-actions commented on Apr 22, 2026

    @github-actions

    Closing for now — inactive for too long. Please open a new issue if this is still relevant.

  6. github-actions commented on Apr 30, 2026

    @github-actions

    This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

  7. locked as resolved and limited conversation to collaborators on Apr 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions