Agent Transcripts Are the New .env Leak Risk

Agent transcripts leaking credentials, like a .env file

Agent transcripts have become a new place for credentials to leak. In November, Cursor and Notion both disclosed exposed secrets, and in neither case did the leak go through a .env file. It went through records of AI coding agent sessions.

How the Cursor leak unfolded

Cursor’s account of its October incident starts with an access key it had issued to Fireworks, a vendor used for training and inference. With that key, an attacker pulled down a storage bucket of traces from coding agents, mostly dating to 2025, which Cursor had handed to Fireworks for training. Cursor says a handful of them still contained unredacted credentials.

Those credentials opened some of the SaaS tools Cursor relies on, and one of them stored yet another credential. The attacker used that last one to upload a tampered Claude Code extension to the cache that backs Cursor’s extension marketplace. It stayed up for about 11 hours, so as many as 5,000 people could have installed it.

The same Fireworks incident reached Notion. Its advisory says Notion revoked the Notion API keys it spotted in affected users’ AI chats, and told the issuing vendors about any third-party keys that turned up in the same place.

How secrets get into agent transcripts

A transcript captures the whole session: what you wrote, which files the agent opened, every command it ran and what came back. Secrets end up in that record even when nobody pastes them.

  • While debugging a config problem, the agent runs cat .env or printenv, and the values are now in the log as tool output.
  • A failed request may print its headers, an error response may repeat the token it refused, and a stack trace may expose a database URL with the password inside.
  • A developer types a password into a command, such as PGPASSWORD=hunter2 psql, and the agent runs it.

The last case leaves a second copy. Choosing “Yes, and don’t ask again” at a Claude Code permission prompt saves the approved command, password and all, as a rule in .claude/settings.local.json in the repository root. Claude Code lists that file in the global git excludes. That only keeps it out of commits, so a docker build, a zip archive or a synced folder still carries it along. Plaintext credentials in the file have been reported since at least August 2025.

Agents keep these records so they can resume work and remember what worked. The exposure comes with the design.

Where agent transcripts travel

Copies pile up on a laptop and then spread. Home-directory backups, dotfile repositories and session-sync tools copy them whole. Agent folders live inside project folders, so they get committed, zipped, copied into Docker images and published in packages. The traces Cursor lost came from sessions run outside Privacy Mode, which it was allowed to train on.

Each turn also ships the conversation to date, tool output included, to the model provider and any gateway on the way.

The local copy is a target as well. In August 2025, poisoned Nx releases on npm included a prompt that told the victim’s own AI coding tools to hunt the disk for .env and similar config files. A month later, the Shai-Hulud worm scanned developer machines for GitHub tokens and cloud keys.

Why redaction falls short

Scrubbing agent transcripts helps, but secret scanners match formats, such as the ghp_ or AKIA prefixes. A password written after PGPASSWORD=, mysql -p or sshpass -p looks like any other word, so there is nothing for a pattern to latch onto.

Agents also rewrite what they see. They base64-encode a value for a Kubernetes secret, break a connection string into separate fields, or quote part of an error message. Each result is a copy no pattern for the original will catch. Redaction has to be right every time, while an attacker needs one miss. Claude Code deny rules like Read(./.env) also miss indirect reads, such as a Python script that opens the file in a subprocess.

Make what leaks worthless

The better fix is to limit how long a leaked credential works and what it can do. That means keeping long-lived keys out of the agent’s environment, ideally by running the agent in a container, a VM or a separate user. Instead, each task gets freshly minted credentials:

  • A GitHub App installation token expires after an hour and can be limited to chosen repositories and permissions.
  • AWS AssumeRole accepts a session policy, and a session can last anywhere from 15 minutes to the role’s cap.
  • Google Cloud impersonation tokens are short-lived but carry all of a service account’s roles, so give the agent its own service account with only the roles it needs.

The key that mints these credentials should sit where the agent can ask for a credential but can’t read the key. Secrets should be referenced, not typed: write psql “$DATABASE_URL” so the saved rule records a variable name. The record of what the agent did should live somewhere it can’t rewrite, so a leak can be traced through an audit log. Six months on, a one-repository token sitting in an old transcript is useless to a thief.

What to do this week

Treat anything that was ever in a transcript, a settings.local.json or an agent memory file as exposed, and rotate it. Then take these steps:

  • Untrack the settings file with git rm –cached and list it in .gitignore and .dockerignore.
  • Lower Claude Code’s cleanupPeriodDays, set CLAUDE_CODE_SKIP_PROMPT_HISTORY=1 for sensitive sessions, and use claude purge to clear a project’s stored history.
  • Use codex exec –ephemeral for scripted Codex runs so no session files are written.
  • Scan ~/.claude, ~/.codex and project agent folders using a scanner able to find passwords embedded in commands.
  • Check whether your agent tool uses your sessions for training.

Agents will keep writing transcripts, and teams need them. The task for security teams is to make sure what sits in them expires with the job.

Source: kosem

Written by

Saksham Bhargava

Saksham Bhargava runs Alteroid and has been writing about consumer technology for over five years, covering iPhone, Android, Windows, AI tools and gaming. With an MCA and six years of hands-on web development experience, he tests the features he writes about on his own devices and focuses on clear, practical guides that solve real problems. Away from the screen, he enjoys travelling to places most tourists skip.