The Debrief

Your Coding Agent Is Writing a Secrets Log

9 min read

The Short Version

The dangerous part of an AI coding agent is not always the command it runs.

Sometimes it is the command it remembers.

Security company Apiiro scanned public GitHub repositories and found 2,539 distinct credentials across 1,994 repositories in coding-agent settings, Git history, transcripts, memory files, and handoff notes.

The clearest path runs through Claude Code.

When Claude Code asks to run a Bash command, the user can choose “Yes, and don’t ask again.” Anthropic’s documentation says that standing approval is written to .claude/settings.local.json as an allow rule.

If the command contains a database password, API token, connection string, or authorization header, the saved rule can contain the secret too.

Apiiro found 104,185 public copies of that local settings file. It classified 1,122 of them as containing at least one real secret, for 1,379 distinct credentials in current files. Earlier Git history, shared settings, and other agent artifacts raised the total to 2,539.

Those numbers need a caveat.

Apiiro classified provider-shaped keys and passwords or tokens next to public hosts as real. It did not prove that every credential was still active. The company says one affected organization confirmed that its key had been live.

That is still enough to establish the engineering problem.

A permission prompt that looks temporary can create durable state. That state can outlive the session, enter a commit, survive in Git history, and spread through forks and clones.

The practical lesson is larger than one Claude Code file:

Every file an agent writes about its work should be treated as potentially secret-bearing.

“Don’t ask again” is a write operation

The interface presents standing approval as a reduction in friction.

The user sees the same command several times, decides it is safe, and asks the agent to stop interrupting. That feels like changing a preference.

Underneath, the product has to remember what was approved. Claude Code does that by writing a permission rule to a project-local settings file.

The distinction matters because a command is not only a verb.

It can also be a container for data:

  • a database URL with an embedded password
  • a curl request with a bearer token
  • an environment variable assigned inline
  • an SSH command with a password
  • a package-manager command with a registry token

Saving the exact command saves both the authorization pattern and whatever data happened to be inside it.

This behavior was reported in Anthropic’s public issue tracker in August 2025. The issue includes reproduction steps showing credentials written verbatim to the permission allow list. It was later closed automatically after inactivity, not through a documented security fix.

The important question is not whether the model decided to leak a secret.

It did not.

This is product behavior around the model: the permission system persisted a command, and a developer later committed the resulting file.

That separation prevents a bad diagnosis. Better model alignment would not solve a storage design that preserves sensitive command arguments.

A global ignore is protection for one machine

Anthropic does try to keep .claude/settings.local.json out of Git.

Its current documentation says Claude Code adds the path to the developer’s global Git excludes file the first time it writes the local settings file. That covers the ordinary case on that machine.

But a global exclude is local state.

It does not travel with the repository.

A fresh laptop, CI worker, container, cloud development environment, or teammate’s clone may not have the same rule. A directory can become a Git repository after the file exists. A file created by hand may never trigger Claude Code’s automatic exclusion. A previously tracked file remains tracked even after an ignore rule appears.

Anthropic’s docs acknowledge part of this boundary: if the user creates the file manually, the user must add it to .gitignore.

Apiiro’s data shows the result of all those edge cases meeting normal developer behavior. Of 1,105 affected repositories it traced, 539 had a commit touching the file that was co-authored by Claude.

That does not mean Claude autonomously published 539 secrets.

It means agent-assisted commits make generated state part of the same broad staging operation as source code. If the repository itself does not declare what must remain local, the person and the agent are both relying on machine-specific configuration that neither may inspect before git add.

Security policy should travel with the project.

Convenience state should not get a weaker boundary merely because a tool generated it.

Secret scanners understand formats better than intent

The scan also exposes a second gap.

Apiiro ran Gitleaks and TruffleHog over the 104,185 public local settings files. Of the 1,122 files it classified as containing a real secret, 215 were flagged by neither scanner.

That is not surprising once the artifact is understood.

Secret scanners are strongest when a credential has a recognizable structure: a provider prefix, a known length, a characteristic alphabet, or surrounding syntax that names a common service.

A password embedded inside an approved shell command can look like an ordinary word.

The file adds semantic context a generic scanner may not have. A string becomes dangerous because it appears after a password flag, inside a connection URL, or next to a public database host. The same pattern can appear in transcripts, memory files, deployment notes, and debugging logs.

GitHub’s push protection remains valuable. It can stop supported secret formats before they reach a repository. GitHub also supports custom patterns for organization-specific credentials.

Neither feature means every password-shaped argument will be recognized.

The right model is layered:

  1. do not put secrets in commands when a safer reference is available
  2. do not store exact sensitive commands as reusable approvals
  3. keep local agent artifacts out of the repository by project policy
  4. scan current files and full history
  5. block recognizable secrets at push time
  6. rotate anything that crossed the boundary

Scanning is the last chance to catch a design failure, not permission to create one.

Agent state is now part of the software supply chain

The most important part of Apiiro’s report is not limited to .claude/settings.local.json.

The researchers also found credentials in shared Claude settings, saved chat transcripts, agent memory files, handoff notes, deployment notes, Cursor exports, Aider logs, and Copilot auto-approval settings.

These files occupy an awkward category.

They are not source code, so developers may not review them carefully.

They are not conventional secret stores, so security tools may not watch them.

They are often plain text, because the agent needs to read them.

And they are increasingly useful, because long-running agents need memory, permissions, resumable state, tool configuration, and records of prior work.

That usefulness is exactly why the category will grow.

An agent that remembers nothing is frustrating. An agent that remembers everything becomes a retention system. The engineering job is to decide which facts may persist, where they may persist, how long they remain, and which process can publish them.

Teams already apply those questions to .env files, CI variables, credential managers, logs, crash dumps, and database backups.

Agent artifacts belong on the same inventory.

They should have owners, retention rules, repository rules, scanning coverage, access controls, and deletion procedures. Products should distinguish executable permission patterns from literal command history. Secrets should be passed by reference through scoped environment variables or credential brokers, not copied into reusable policy strings.

The model is only one participant in that system.

The harness decides what gets written.

What teams should do now

First, inventory the agent files that are already tracked.

For Claude Code, check both .claude/settings.local.json and the shared .claude/settings.json across every repository. Check the full Git history, not only the current branch. Extend the inventory to transcripts, memory files, handoff notes, and other coding-agent directories your team uses.

Do the review locally. Do not paste the suspected contents into another model or ticketing system.

Second, treat any discovered credential as exposed.

Rotate or revoke it before cleaning the repository. Deleting the current file does not remove the secret from old commits, forks, clones, caches, or build artifacts. History rewriting can reduce exposure, but it cannot make a copied credential trustworthy again.

Third, put the repository rule in the repository.

Add local agent settings and other personal state to the project’s .gitignore, organization templates, and policy checks. Keep shared settings minimal and free of literal credentials. Reject sensitive agent artifacts in CI even when a developer’s global ignore failed.

Fourth, change how commands receive secrets.

Prefer short-lived credentials, environment-variable references, secret managers, and brokers that inject a credential only at execution time. A reusable permission should describe the shape of an allowed action, not preserve one fully expanded command with production data inside it.

Finally, scan beyond known key formats.

Look for sensitive argument positions and connection-string structures in agent-specific folders. Enable push protection, define custom patterns for internal credentials, and review bypasses. Treat a large or fast-growing allow list as a risk signal, not as evidence of a productive developer.

The Bottom Line

Claude Code did not upload 2,539 secrets by itself.

Apiiro found a chain of smaller design and workflow decisions:

  • commands carried credentials
  • standing approvals preserved the commands
  • agent state lived beside source code
  • machine-specific ignores did not always hold
  • broad commits included the files
  • scanners missed some unstructured passwords
  • Git history kept what developers later deleted

No step looks dramatic on its own.

Together, they create a new kind of secret sprawl.

Coding agents are becoming durable collaborators. They keep permissions, memories, transcripts, plans, and handoffs because continuity makes them more useful.

Continuity also creates records.

The security boundary can no longer stop at the source tree and the .env file. It has to include every artifact the agent writes while learning how to work.

If an agent can remember a command, assume it can remember the secret inside it.

Then design the system so it never has to.