AI Agents

AI agent credentials: what the Claude Code leak teaches

A Claude Code setting saved passwords and API keys into 1,122 public GitHub files. Here's where AI agent credentials should live and how to check yours.

S

SelfAgentic Team

7 min read
A red padlock resting on a laptop keyboard lit in green.

On November 6, security firm Apiiro reported that 1,122 public GitHub files created by Claude Code contained passwords, tokens and API keys. The cause was a convenience button: when a developer picked "Yes, and don't ask again" for a command with a secret typed into it, the whole command, secret included, could be saved to a settings file that often got committed to the repository. If you run AI agents for your business, the lesson applies to AI agent credentials in general. Approvals you click and keys you paste can end up stored somewhere, and you should know where.

You don't need to write code for this to matter. No-code agent tools have the same pressure points, and a small team can check its own setup in an afternoon.

What happened with Claude Code's "don't ask again" file

Claude Code is Anthropic's coding agent. By default it asks before running most shell commands. According to The Hacker News' write-up of the Apiiro research, choosing "don't ask again" can save the exact approved command as a rule in a project file called .claude/settings.local.json. If that command included a database password or a token, the secret was stored in plain text.

Apiiro looked at 104,185 copies of that file on public GitHub. 1,122 of them held at least one secret, 1,379 distinct credentials in all, including 379 database passwords, 43 SSH logins for public servers and 23 AWS keys. Counting older versions, forks and a second shared settings file, the total reached 2,539 secrets across 1,994 repositories. Apiiro didn't test whether the secrets still worked, though one company it notified confirmed its key was live.

The agent often published the leak itself. In 539 of the 1,105 repositories Apiiro traced, a commit listing Claude as co-author changed the file. Standard secret scanners struggled too: gitleaks and TruffleHog both missed 215 of the files, mostly because the passwords sat inside commands and didn't match a known key format. The files also stayed put: in half the affected repositories, the file had been on the main branch for at least 217 days.

The same article notes that a bug report describing this behaviour was filed in August 2025 and later closed by an automated bot as "not planned." The Cloud Security Alliance's research note on the settings file leak summarises the findings and adds that CSA hasn't independently replicated the numbers.

Why AI agent credentials leak in new ways

An AI agent credential is any password, API key, token or login an agent uses to act in another system, such as your CRM, your ad account or your database. Security teams call these non-human identities. The OWASP Non-Human Identities Top 10 puts "Secret Leakage" at number two and "Long-Lived Secrets", credentials that never expire or expire far in the future, at number seven.

Agents add two problems that people working by hand didn't have. The first is that approvals turn into storage. A password a person types into a terminal is gone when the session ends. When you tell an agent to do something again without asking, the tool has to remember what "something" was, and in Claude Code's case that record included the password. Any product that saves standing approvals faces the same design choice.

The second is that agents write and publish things on their own. A person might pause before committing a config file to a public repository. An agent asked to "commit everything" usually won't.

Security vendors see a market here. Palo Alto Networks is reportedly in advanced talks to buy Clutch Security, a startup that finds AI agents across company networks and puts guardrails on the credentials they use, for roughly $500 million in cash, according to Security Boulevard's report on the Clutch talks. No binding agreement has been signed.

Where should an AI agent's keys live?

In an encrypted store that the agent platform manages, kept out of the agent's instructions, chat history and memory.

In no-code tools the risky version looks harmless. You paste an API key into an agent's instructions so it can post to a channel, or drop a login into a chat so the agent can test something. That text can then live on in prompts, memory, logs and exported documents, and none of those were built to hold secrets.

The safer pattern is to connect each tool once, usually through OAuth (the "Sign in with Google" style flow where you approve access without handing over a password). The platform stores the resulting token encrypted, and agents get permission to use the connection. That's how SelfAgentic handles it: integration tokens are encrypted with AES-256-GCM before they're stored, and the encryption keys sit in Azure Key Vault, as our security page describes.

How to audit AI agent secrets in an afternoon

This list works whether your agents write code or write LinkedIn posts.

  1. List every tool, account and API key your agents can use, including anything someone pasted into a prompt "just for now."
  2. Search the places agents write for secrets: instructions, saved chats, memory, shared docs and, if you use coding agents, folders such as .claude/ and .cursor/. The CSA note recommends treating these folders like .env files, the files developers already know to keep private.
  3. Rotate before you clean up. If a credential ever sat somewhere it shouldn't, issue a new one first and delete the old copies after. Apiiro's advice, as quoted by The Hacker News, was "rotate first."
  4. Replace pasted keys with proper connections through OAuth or the platform's integration settings.
  5. Scope access per agent. A research agent that reads public web pages has no reason to touch your ad account.
  6. Keep standing approvals narrow. CSA suggests tightly scoped pattern rules over single fully specified commands, and warns against broad patterns on tools like curl, ssh or database clients.

Step 5 is easier when connecting a tool and authorising an agent are separate actions. In SelfAgentic, each agent needs its own grant per integration, and revoking a connection removes every grant that depended on it.

Example: a three-person agency cleans up its agent keys

Say a three-person marketing agency runs four agents. One drafts LinkedIn posts, one pulls weekly Meta Ads numbers into a Google Sheet, one summarises client calls and one does web research. Over a few months, a founder pasted an analytics API key into the reporting agent's instructions to get it working quickly, and a contractor shared a Google service-account file in a chat for testing.

They start by listing the four agents and the six accounts those agents touch. The search turns up the pasted key in the instructions and in two old chat threads, and the service-account file in a shared Drive folder. They issue new credentials for both before deleting anything, then connect the analytics tool and Google through the platform's integration settings. Last, they review grants and find the research agent was given Meta Ads access during setup and never used it, so that grant goes.

Afterwards no secret appears in any prompt or chat, each agent reaches only the tools it uses, and the old key is dead even if a copy turns up later. What this doesn't cover is a vendor that mishandles tokens inside its own systems. You're still trusting each platform's storage, so read its security page before you connect anything.

FAQ about AI agent credentials

What counts as an AI agent credential?

Anything an agent uses to prove it may act in another system: API keys, OAuth tokens, passwords, service accounts and SSH logins. If someone holding it could act as your agent, treat it as a credential.

Is it safe to paste an API key into an AI agent's prompt?

It's best avoided. Prompt text can be copied into memory, logs, chat history and documents the agent creates, and you lose track of where it went. Use the platform's integration or connection settings so the key is stored encrypted and kept out of the conversation.

What should I do if an agent's key has leaked?

Issue a new key and revoke the old one first, then remove the copies. Deleting the file without rotating leaves the old key usable by anyone who already copied it, including from git history or forks.

Do secret scanners catch leaks from AI agents?

Some, not all. In Apiiro's study, gitleaks and TruffleHog both missed 215 files, mostly passwords typed inside commands. Add agent folders and memory files to your scanning, and check that your scanner catches passwords inside command text.

If you do one thing this week, search your agents' instructions and chat history for anything that looks like a key, and rotate whatever you find.

If you'd like agents that act in your tools through encrypted connections and per-agent grants instead of keys pasted into prompts, take a look at SelfAgentic.

Keep reading

Ready to build your AI team?

See how a team of agents handles real work, and checks with you before anything goes out.

Free to start. No credit card required.