Get a free audit
Apple credit Apple credits the researcher who runs our AI penetration testing.

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.

Author
Red Team Partners
Read
8 MIN READ
Filed
9 Nov 2026
An engineering team at work, each laptop holding an AI coding agent’s login and a list of commands it is allowed to run unasked.

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 .

130,000+
Unique WardenStealer infections SpyCloud has ingested since it first saw the family on 3 August 2026. Its AI-agent collection arrived in version 1.9, announced on 29 September.

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 filesCount
Database passwords379
Supabase service-role keys122
SSH logins, including root logins in sshpass commands43
AWS keys23
Secrets in older versions of the file, absent from current copies734

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.

Clean up now
  • 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
Lock it down
  • 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

  1. SpyCloud Labs (Trevor Hilligoss). “IntelStealers: the infostealers going after AI tokens and AI configuration data.” 30 October 2026. spycloud.com
  2. Cyber Security News. “Hackers use new infostealer malware” (WardenStealer and Aoki AI-token theft). 4 November 2026. cybersecuritynews.com
  3. Apiiro. “Coding Agents Copy Your Secrets to a Hidden File. Thousands Are on GitHub.” 5 November 2026. apiiro.com
  4. GBHackers. “Claude Code’s ‘Don’t Ask Again’ Feature Exposes 2,539 Secrets Across 1,994 GitHub Repositories.” 7 November 2026. gbhackers.com
  5. Developers Digest. “Claude Code settings.local.json Secrets: Check Your Repos.” November 2026. developersdigest.tech
  6. Anthropic. Claude Code documentation: Settings files and precedence. code.claude.com
  7. Anthropic. Claude Code documentation: Authentication and credential management. code.claude.com
  8. SecurityBrief. “Claude Code can leak secrets in public npm packages” (Check Point research). 22 April 2026. securitybrief.news