Protect AI API Keys From Infostealers: A Founder’s Guide

Direct answer: To protect AI API keys from infostealers, assume a developer laptop will eventually be compromised and make sure a stolen file is worth little. Keep production keys off laptops, issue one scoped key per service with spend caps, store secrets in a secret manager, rotate on a schedule, and monitor usage for anomalies. If a machine is infected, revoke sessions and rotate every exposed credential from a clean device, because a password reset alone may not invalidate stolen tokens.
Last updated: November 2026
Key Takeaways
- Infostealers like WardenStealer and Aoki copy session cookies, OAuth tokens, API keys and config files from AI apps, so no model vulnerability is needed.
- A stolen session token can let an attacker resume access without a password or a fresh MFA challenge, so MFA alone does not protect AI accounts.
- Production API keys should never live on developer laptops; give agents a short-lived internal credential and keep the provider key in a server-side gateway.
- Per-agent scoped keys, provider-side spend caps and usage alerts turn a catastrophic leak into a contained, noticeable incident.
- After an infection, rotate and revoke everything from a clean device, including OAuth credentials and MCP connections, not just the password.
Infostealer malware has moved beyond browser passwords and now goes after AI tools. According to Cyber Press, citing SpyCloud research, two strains called WardenStealer and Aoki collect session cookies, OAuth tokens, API keys and configuration files from AI accounts and developer tools. If you want to protect AI API keys from infostealers, a stronger password will not do it. The goal is to make sure any single stolen file is worth very little.
This matters most for teams shipping agents with shared credentials, because one compromised laptop can expose a key that many systems depend on. If you are weighing automated defenses, see our guide to AI cybersecurity agents for startups and whether to adopt or build. Before agents hold shared credentials, run a small AI agent red teaming test to see whether they misuse them when tempted. Also lock down the APIs those agents can reach with these AI agent API security controls.
What did the new infostealers actually target?
They target files that AI tools already store on disk in predictable places. Per the Cyber Press report, SpyCloud lists Claude Code, OpenAI Codex, Cursor, GitHub Copilot, and the Claude and ChatGPT desktop applications among the targets.
WardenStealer is a Windows infostealer written in Rust and sold through a malware subscription model. SpyCloud first observed it on August 3, 2026, and reports recovering logs from more than 130,000 unique infections since August. Recovered Claude Code files contained OAuth access and refresh tokens, account details, and credentials for connected Model Context Protocol (MCP) servers.
Aoki showed up in SpyCloud’s recovered data on October 4, 2026. It is Go-based Windows malware that organizes stolen material in an “AISessions” folder, with separate directories for ChatGPT, Claude Code, Claude Desktop, Codex, Copilot and Cursor.
The important detail: these attacks do not require a new vulnerability in an AI model. Malware already running on a victim’s computer simply copies valuable files.
Why does a stolen token beat a password and MFA?
Because a token represents a login that already happened. According to the report, a valid stolen cookie may let an attacker resume an authenticated session without entering a password or facing another MFA challenge.
Refresh tokens can sometimes extend that access. How long it lasts depends on token scope, expiration, revocation and provider controls, and the report notes that password resets do not universally invalidate every credential.
The practical lesson: MFA protects the front door, but infostealers walk in with a copy of the key after you have already opened it. Your defense has to assume the endpoint can leak.
What is exposed in a typical AI product?
More than the chat account. In a product that uses LLMs, secrets are spread across laptops, CI, servers and agent tool connections. Here is where each tends to sit and how to limit it.
| Credential | Where it tends to live | What a thief gets | Best control |
|---|---|---|---|
| Chat or coding-assistant session | Browser cookies, desktop app folders | Resumed session, conversation history | Managed devices, short sessions, revoke on incident |
| OAuth access and refresh tokens | Local app config (SpyCloud found these in Claude Code files) | Account access that may outlive a password reset | Revoke grants from a clean device |
| Provider API key | .env files, shell profiles on laptops |
Paid usage on your bill | Keep off laptops, scope, cap spend |
| MCP server credentials | Assistant config files | Access to connected tools and data | Least-privilege, read-only where possible |
| Production agent key | Server environment variables | Same as above, at production scale | Secret manager, per-agent keys, rotation |
Why is this a business problem, not just a security one?
Because stolen AI access has a resale market. SpyCloud’s supplied research describes underground sellers advertising AI subscriptions and API credit at discounts of 40% to 91%, and wholesale services reportedly offering suppliers commissions of up to 35% of billings for uploaded keys.
That market supports LLMjacking, where criminals consume paid AI resources using another organization’s credentials. For scale, Cyber Press notes that Sysdig estimated in May 2024 that one worst-case Claude abuse scenario across multiple regions could exceed $46,000 daily. That was a modeled exposure, not a confirmed victim bill, but it shows why uncapped keys are a financial risk.
There is a data risk too. Stolen configurations can reveal connected services, and prompt histories may expose source code, internal systems or secrets. How far an attacker gets beyond the AI account depends on the permissions and reusable credentials available.
How do you protect AI API keys from infostealers?
Remove the valuable thing from the vulnerable place, then limit what is left. For most teams, these steps in this order give the biggest reduction in risk:
- Keep production keys off laptops. Developers should use separate, low-limit development keys. Production keys belong on servers only.
- Issue one scoped key per service, agent and environment. Use project-level keys where your provider supports them. A leak should identify its source and affect only one workload.
- Set provider-side spend caps and rate limits. This is the cheapest control against LLMjacking. A key that can only spend a small daily amount is a small problem.
- Store secrets in a secret manager. Inject them at runtime. Do not share keys in chat, wikis or committed
.envfiles, and do not paste one key into five tools. - Put a gateway between agents and the provider. Agents hold a short-lived internal token. The gateway, running server-side, holds the real provider key, enforces per-agent limits and logs every call.
- Rotate on a schedule and practise it. Rotation you have never tested will fail during an incident. Aim for a documented, one-command process for every key.
- Give tools and MCP connections least privilege. Prefer read-only access, narrow scopes and separate credentials per connected service, since assistant config files can expose them.
The gateway pattern is the one most teams skip and the one that pays off most. It means a stolen agent credential cannot be used directly against the model provider, and revoking it does not break everything else. We cover the wider design questions in our piece on AI agent security and what happens when you give a model the keys.
How should you secure developer machines running AI tools?
Treat them as part of your production attack surface. The malware in this report runs on the endpoint, so the endpoint is where the loss starts.
- Use managed, patched devices with endpoint detection for anyone who signs in to AI tools or holds credentials.
- Do not sign in to company AI accounts or coding assistants on personal or unmanaged machines.
- Keep a separate OS user or profile for development work, away from general browsing and downloads.
- Review which AI tools are installed and what they store locally. Coding assistants and desktop apps keep tokens on disk by design.
This applies to teams using AI coding tools heavily, including Web3 teams where a leaked key can touch deployment access. If that is you, see our comparison of the best AI coding assistants for Web3 developers with security in mind.
What should you monitor to catch stolen keys early?
Watch usage, not just logins. A stolen token does not trigger a login alert, so abuse shows up as consumption.
- Spend and token volume: alert at fractions of your daily budget, not only at the cap.
- Source IP and region: a server-side key should only be used from your infrastructure.
- Model and endpoint changes: a key that suddenly calls expensive models it never used is suspicious.
- Time patterns: sustained heavy use outside normal hours deserves a look.
- Per-agent baselines: with one key per agent, a spike points straight at the source.
Monitoring and limits belong on your production-readiness checklist for any agent, alongside logging, fallbacks and human approval for risky actions. Most of this logic lives in your service layer, which is where solid backend API development pays off.
What do you do if a developer machine is infected?
Act from a clean device and assume every credential on the infected machine is exposed. The Cyber Press report advises defenders to include AI applications in every developer endpoint investigation. Its recommended response is:
- From a clean device, revoke active sessions for AI accounts and developer tools.
- Rotate exposed API keys and OAuth credentials.
- Review MCP connections and the credentials behind them.
- Investigate unusual consumption on your provider accounts.
Do not stop at a password reset, since it does not universally invalidate every credential. Your security team can also search for the indicators SpyCloud identified for Aoki: temporary working files with the %TEMP%akg_ prefix and communication with neihite[.]cc.
The verdict for most teams: you cannot prevent every infection, but you can decide what an infection costs. Scoped keys, spend caps, a gateway and tested rotation turn a possible five-figure surprise into an alert and a quick rotation.
Frequently Asked Questions
Can infostealers bypass MFA on ChatGPT and Claude accounts?
According to the Cyber Press report on SpyCloud research, a valid stolen session cookie may let an attacker resume an authenticated session without a password or another MFA challenge. MFA still matters at login, but it does not help once a token has been copied from a compromised device.
Does resetting my password revoke stolen AI tokens?
Not necessarily. The report says persistence depends on token scope, expiration, revocation and provider controls, and that password resets do not universally invalidate every credential. Revoke active sessions and rotate API keys and OAuth credentials from a clean device.
How often should I rotate LLM API keys?
Pick a regular schedule your team can actually keep, and rotate immediately after any suspected endpoint compromise. What matters most is that rotation is documented and tested, so it takes minutes rather than a day of searching for where a key is used.
What is LLMjacking?
LLMjacking is when criminals consume paid AI resources using another organization's credentials. The Cyber Press report ties it to an underground market selling AI subscriptions and API credit at discounts of 40% to 91%.
Should developers have access to production AI keys?
For most teams, no. Give developers separate low-limit development keys and keep production keys in a secret manager on servers, so a compromised laptop does not expose production spend or data.
Sources
- New Infostealers Target ChatGPT and Claude Accounts, Stealing Tokens That Can Bypass Login Protections — Cyber Press, November 4, 2026
If your agents share credentials or your keys live in developer environments, the safest fix is to design the credential model before you scale. Our team builds agents with scoped keys, a server-side gateway, spend limits and monitoring from the start, as part of our AI agent development services.
About the author
Ready to start? See our AI Agent Development Services, get in touch, or order on Fiverr.