TRUFFLEHOG

COMPANY

RESOURCES

Luke Marshall

AI Agent are Leaking YOUR Secrets

AI Agent are Leaking YOUR Secrets

Luke Marshall

AI Agents are leaking your secrets.

TL;DR: We started with 2,785 chunks associated with historically verified secrets in agent-related files. Looking beyond the scanner finding revealed passwords, refresh tokens, private conversations and business information retained in agent history and project notes.

Coding agents keep working files so they can resume a session, remember project instructions and avoid asking for the same permissions repeatedly. These files are created in different ways. Claude Code saves each message, tool call and result as local JSONL under ~/.claude/projects/ and snapshots files it edits. Its /init command can generate a CLAUDE.md for persistent project guidance. 


Codex and OpenCode also use AGENTS.md for project guidance; it can be written by a developer or generated during setup. Session history, memory and settings serve different purposes, but each can retain information the agent saw while working including secrets.

To see where secrets were showing up, we matched verified findings from our Public Monitoring against paths used by coding agents for conversations, memory, instructions and configurations. This produced a list of 2,785 distinct files for closer review. 

For example, one Docker-sourced finding came from a file under /home/kdy/.claude/projects/-threat-detection-automation/<session-id>.jsonl. That path is Claude Code session history that included a valid Jira Token, Crowdstrike Falcon key and Microsoft teams login credentials, including a OTP seed for 2FA generation.

Another example showed a user pasting secrets into an agent task and, about a minute later, asking the agent to use placeholders. The earlier values remained in the append-only prompt log.


How we looked

We searched our data lake for verified secrets that were found in an agent-related path. In total we found 2,785 chunks of data that had both a verified secret in it and was also found in an agent-related path.

Our methodology involved re-scanning these chunks with TruffleHog to determine if the secret was still valid. We paired this with an agent who was explicitly instructed to discover generic or sensitive information inside these chunks. To protect any valid secrets in these chunks we redacted their values before sending the chunks to the agents.

We also discovered 236 embedded images, most of which were not sensitive (application and login screens, terminal output, charts, diagrams) but one caught our attention. A screenshot of a Microsoft team chat that spoke about an ongoing incident response.

Where we looked

We looked across a wide range of AI tools and services to figure out where agents were storing these transcripts. Here is what we found:


These are counts of distinct chunk hashes associated with each source-path category. Categories overlap when the same chunk appears at multiple paths.

794 chunks had a source path ending in settings.local.json, 647 in CLAUDE.md, 185 in AGENTS.md and 77 in auth.json. We also saw MCP configuration, session JSONL and SQLite history.

Here is the spread across our current public monitoring sources:


How the copies were made

We identified four main paths to leaking secrets in these files.

  1. Conversation and tool history. A user pasted a value, or the agent read it from a file. The prompt, command output, screenshot or edit preimage then remained in the session record.

  2. Project memory and instructions. Agent guidance files accumulated account details, passwords, internal workflows and business rules so a future session could pick up where the last one stopped. Some files explicitly told the agent to keep credential copies. 

  3. Configuration and saved commands. Permission files, authentication state, MCP settings and command histories retained credential assignments or complete connection strings.

  4. Packaging and publication. Agent working files traveled into source artifacts and Docker image layers.

These paths were often connected, the same value would appear in a prompt and an agent not or even in an image layer. 

Public Docker image leaking secrets and chat logs

Our Public Monitoring found a valid Jira and GitHub secret inside a public Docker image. We attributed these secrets to a global automotive manufacturer, but when we looked deeper into the image we found a more critical issue.




The same chunk that contained the verified secrets TruffleHog had found also contained a set of Microsoft teams credentials including the seed for generating valid TOTP codes; we also discovered an entire Microsoft team's transcript around an incident that was ongoing.

The agent also tried to warn the user that the Jira secret was in plaintext and recommended rotating it.


Our hypothesis is that a Docker image was being used for incident response, we also found the malware on this image and during this incident response the engineer was using Claude to help investigate. This meant giving Claude access to Jira and Microsoft Teams as part of the investigation. Unfortunately, the image was accidentally published to Docker hub as a public image and that's how we discovered it. 

What to check in your own projects

Inventory the agent directories and files your team uses, including their histories, project instructions, permission files and authentication state. Decide what needs to persist between sessions, and keep the rest out of repositories and build contexts. Check image layers, not only the final container filesystem. If a secret was removed after being pasted into a session, look for earlier copies and rotate it if it may have been exposed.

infra