Field Notes / AI Security
Claude Code security risks: one week, two leaks. Stealers take the login, GitHub keeps the passwords.
On 30 October SpyCloud showed two infostealers lifting Claude Code and Codex tokens from developer machines, access that outlives a password reset. On 5 November Apiiro found real secrets in 1,122 public copies of .claude/settings.local.json, the file where “don’t ask again” stores approved commands. Neither needed a bug in Claude Code. Here is what each finding means for a company whose developers use AI coding agents, and the fixes to make this week.
01 Infostealers now take the agent’s login
nfostealers are cheap malware that empty a machine of passwords, cookies and crypto wallets, then upload the lot. SpyCloud reads the logs they leave behind. In its 30 October report, SpyCloud Labs described two Windows families that now go further and collect the files AI coding agents keep on disk SpyCloud .
SpyCloud Labs, 30 Oct 2026
WardenStealer is written in Rust and sold as a service to whoever pays. Aoki, written in Go, first showed up in SpyCloud’s data on 4 October and files its AI loot in a category of its own. SpyCloud saw data from ChatGPT, Claude Code, Claude Desktop, Codex, GitHub Copilot and Cursor Cyber Security News, 4 Nov .
From Claude Code, SpyCloud recovered the OAuth credentials file with the
account’s access and refresh tokens, plus tokens for every connected MCP
server. The stealers also took the account configuration file, with user
and machine identifiers, and CLAUDE.md, the instruction file
that often describes how a team’s systems fit together. From Codex they
took the authentication file: an OpenAI API key with access and refresh
tokens SpyCloud .
Anthropic’s own documentation explains why this works on Windows. There,
Claude Code keeps its login in %USERPROFILE%\.claude\.credentials.json,
protected only by the user account’s file permissions. Linux uses
~/.claude/.credentials.json. On macOS the login goes into the
Keychain Anthropic docs . Malware
running as the developer reads what the developer reads.
SpyCloud also found a market waiting for the output. Storefronts sold AI access at 40% to 91% below official prices. One listed a month of Codex API access with $100 of credit for $8.94. SpyCloud is careful to add that it cannot prove every advertised credential came from malware Cyber Security News .
02 Why a password reset does not end it
The usual response to a stolen password is to reset it and move on. Tokens break that habit. A refresh token exists so the agent can stay logged in without asking for a password again. Whoever holds it gets the same courtesy.
SpyCloud puts it plainly: with stolen AI tokens and session cookies, “much of that access survives both the password reset and the multi-factor prompt that would stop a reused credential” SpyCloud . How long the access lasts depends on the provider, the token type and the account’s controls. The safe assumption is that it lasts until someone revokes it.
For an MSP the stakes multiply. One technician’s machine can hold agent sessions and MCP connections for several client environments at once. Rotating the technician’s password protects none of them.
03 The file “don’t ask again” writes
Claude Code asks before it runs a shell command. Choose “Yes, and don’t
ask again” and it saves the approval as an allow rule in
.claude/settings.local.json at the root of the repository
Anthropic docs . The rule is the
exact command string. If the developer approved
PGPASSWORD=… psql -h db.example.com, the password now sits
in a JSON file in plain text.
Between 1 and 3 November, Apiiro searched public GitHub for that file. It
found 104,185 copies in 103,617 repositories. 1,122 of them, about 1.1%,
held at least one real secret Apiiro .
Counting file history, the shared .claude/settings.json and
committed agent transcripts, the total rose to 2,539 distinct secrets
across 1,994 repositories GBHackers, 7 Nov .
| What Apiiro found in the exposed files | Count |
|---|---|
| Database passwords | 379 |
| Supabase service-role keys | 122 |
SSH logins, including root logins in sshpass commands | 43 |
| AWS keys | 23 |
| Secrets in older versions of the file, absent from current copies | 734 |
One caveat matters. Apiiro did not test any credential or contact any host. “Real” means the value matches a provider’s key format or points at a public host. One affected company did confirm its exposed key had been live Developers Digest .
Claude Code does try to keep the file out of git. On first write it adds
**/.claude/settings.local.json to the developer’s global git
excludes Anthropic docs . That
setting lives on one laptop. Apiiro points out that it does not follow
the project to a fresh clone on another machine, a file created by hand,
or a file already committed. Deleting the file later does not help
either: the 734 secrets in the table survive only in history and forks
Apiiro .
This is the second time this year. In April, Check Point researchers found the same file inside 428 of about 46,500 npm packages they monitored, with credentials in 33 of them SecurityBrief, Apr 2026 .
04 Claude Code security best practices for this week
Split the work in two. The first list cleans up what is already out. The second stops it happening again. An IT lead can get through both in a week, without banning the tools your developers rely on.
- Add AI agent credentials to every infostealer and endpoint incident on a developer machine. After the machine is clean, revoke and reissue API keys at Anthropic and OpenAI, end active sessions, log in again and re-authorise each MCP connection
- In every repository, run git log --all -- .claude/settings.local.json. If the file was ever committed, read its allow rules (jq .permissions.allow) and list every password, token and connection string in them
- Rotate every credential you find before you clean up. Then run git rm --cached .claude/settings.local.json and commit. Removing it from history does not un-leak a public secret
- Search the shared .claude/settings.json, committed agent transcripts and forks of your public repositories for the same strings
- Add .claude/settings.local.json to each repository’s own .gitignore, so the rule travels with the project to every clone
- Turn on secret scanning and push protection on GitHub or GitLab, including history, and add a pre-commit check for inline passwords such as PGPASSWORD= and sshpass -p
- Keep secrets in a secret manager and reference them as environment variables, so an approved command never contains the secret itself
- Approve command patterns such as Bash(npm run test *) instead of literal commands, and deny reads of .env files in settings
- Give each developer and each agent its own key with a spend limit and only the scopes it needs. Push these rules out through Claude Code’s managed settings so they do not depend on each laptop
SpyCloud and Apiiro published within a week of each other, and they describe one problem from two ends. AI coding agents gather credentials in places your existing controls were never told about: a token file on the laptop, a JSON file in the repository. Our AI security testing maps those places the way an attacker would. If you build agents of your own, we find out what they can be talked into, through an AI penetration test for LLM agents or full AI red teaming. Start with a free audit of one developer machine and find out what a stolen agent login opens before someone else does. Your red team. Within reach.
Questions readers ask
What are the main Claude Code security risks?
Two were documented in the same week of November 2026. First, infostealer malware: SpyCloud found that the WardenStealer and Aoki families collect the Claude Code OAuth credentials file, with access and refresh tokens and tokens for connected MCP servers, plus the Codex authentication file with its OpenAI API key. Second, secrets in settings files: Apiiro found real-looking secrets in 1,122 of 104,185 public copies of .claude/settings.local.json, the file where Claude Code stores Bash commands approved with “Yes, and don’t ask again”. Neither depends on a flaw in Claude Code itself. Both depend on where credentials end up on a developer’s machine and in its repositories.
Does a password reset revoke stolen Claude Code or Codex tokens?
Not reliably. SpyCloud says that for stolen AI tokens and session cookies, “much of that access survives both the password reset and the multi-factor prompt that would stop a reused credential.” Treat an infected developer machine as a revocation job: clean or rebuild the machine first, then revoke and reissue API keys at the provider, end active sessions, log in again, and re-authorise every MCP connection the agent used.
Should .claude/settings.local.json be committed to git?
No. It is a personal file. Anthropic’s documentation says Claude Code adds **/.claude/settings.local.json to your global git excludes the first time it writes the file, but that protection lives on one machine. Apiiro notes it does not cover a fresh clone elsewhere, a file created by hand, or a file already committed. Add .claude/settings.local.json to each repository’s own .gitignore, and if it was ever committed, rotate every credential it held before you remove it with git rm --cached.
How do I check whether my repositories leaked secrets through Claude Code?
Run git log --all -- .claude/settings.local.json in each repository to see if the file was ever committed, then read its approved commands (for example with jq .permissions.allow) and look for passwords, tokens and connection strings. Check the shared .claude/settings.json and any committed agent transcripts too. Run a secret scanner across the full history, and add a manual review for inline passwords: Apiiro found 215 secret-bearing files that neither gitleaks nor TruffleHog flagged.
Is Claude Code safe to use in a company?
It can be, with the same controls you apply to any tool that holds credentials and runs commands. Give each developer their own keys with spend limits, keep secrets in a secret manager and reference them as environment variables, approve command patterns rather than literal commands, deny reads of .env files in settings, enforce policy through managed settings, and include AI agent credentials in every endpoint incident response.
References
Sources
- SpyCloud Labs (Trevor Hilligoss). “IntelStealers: the infostealers going after AI tokens and AI configuration data.” 30 October 2026. spycloud.com
- Cyber Security News. “Hackers use new infostealer malware” (WardenStealer and Aoki AI-token theft). 4 November 2026. cybersecuritynews.com
- Apiiro. “Coding Agents Copy Your Secrets to a Hidden File. Thousands Are on GitHub.” 5 November 2026. apiiro.com
- GBHackers. “Claude Code’s ‘Don’t Ask Again’ Feature Exposes 2,539 Secrets Across 1,994 GitHub Repositories.” 7 November 2026. gbhackers.com
- Developers Digest. “Claude Code settings.local.json Secrets: Check Your Repos.” November 2026. developersdigest.tech
- Anthropic. Claude Code documentation: Settings files and precedence. code.claude.com
- Anthropic. Claude Code documentation: Authentication and credential management. code.claude.com
- SecurityBrief. “Claude Code can leak secrets in public npm packages” (Check Point research). 22 April 2026. securitybrief.news
Close the gap this note describes
- AI red teaming Our operators attack your AI system the way an adversary would and hand you the paths that worked.
- AI penetration testing Your LLM application tested against the OWASP LLM Top 10, with a fix for every finding.
- AI security You learn what your models, agents and AI tools let an attacker reach, and how to shut it.