AI SECURITY
Deep dive: Stolen AI API Keys (LLMjacking) and How to Lock Them Down

If you only read one paragraph: an AI API key is a credit card with no PIN. Anyone who holds it can run models on your account, and you get the bill. In October 2026 a run of breaches at AI developer platforms leaked thousands of customer keys, and one platform alone estimated about $740,000 in unauthorized spending. Give every key one job, cap what it can spend, keep it out of code and build logs, turn on usage logging, and know how you'd rotate it in ten minutes.
Wiz called it "Black October." By their count, at least nine AI developer platforms disclosed security incidents in a single month, from Fireworks AI on October 6 to Northflank on October 30, with more added in early November. These are the hosting and build platforms where people deploy AI apps and agents, which means they're also where people paste their OpenAI, Anthropic and AWS Bedrock keys.
Railway's incident is the one with a number attached. According to its incident report, as covered by The Hacker News, an attacker got into Railway's build infrastructure, moved through internal systems, pulled encrypted environment variables, went looking for names that matched AI provider keys, and decrypted a portion of them. Railway says the stolen keys were used for an estimated $740,000 in unauthorized spending across providers including AWS Bedrock, Google Gemini, OpenAI, Anthropic and OpenRouter. It also said it couldn't refund that spend.
I don't love writing about breaches where the victims did nothing wrong. Most of those customers stored their keys exactly where the platform told them to. But "the platform got hacked" isn't something you can control, while how much damage one stolen key can do is.
What is LLMjacking?
LLMjacking is using someone else's stolen credentials to run large language models on their account. Sysdig's threat research team named it in May 2024, after seeing attackers use stolen cloud credentials to target ten different hosted LLM services. Their read on the business model was simple: sell the model access to other criminals while the account owner pays.
The bills get big fast. Sysdig calculated that a fully abused Bedrock account could cost the victim over $46,000 a day at the time. Later 2024 reporting described some attacks running past $100,000 a day on the most expensive models.
The stolen access gets used for whatever the buyer wants: chatbots for paying customers, content the providers' own terms forbid, or simply reselling cheap model access. None of that is your business, and all of it is on your invoice.
How do AI keys actually get stolen?
The October incidents were platform breaches, but they're one route of several. The usual ones:
- A platform you trust gets breached. Railway, Trigger.dev (environment variables taken from a subset of organizations, disclosed November 1) and the others on Wiz's list.
- Your CI pipeline gets hijacked. In the wfx-loot campaign reported in November, attackers used 4,837 compromised GitHub accounts to plant a secrets stealer that ran in at least 1,806 repositories, according to Aikido Security. It went after GitHub Actions secrets, cloud credentials and AI service keys.
- The key is in the code. Committed in a
.envfile, hardcoded in a front end, or sitting in a public repo's history long after someone "deleted" it. - A developer laptop gets infected. Infostealers grab dotfiles, shell history and browser sessions. Keys in plain environment variables go with them.
Then there's the newer twist. In November, Darktrace published a lab proof of concept in which stolen Claude credentials let an attacker steer a developer's coding agent and move data through Anthropic's own API. It needs a compromised machine first, it isn't a vulnerability in Claude, and Darktrace says it hasn't seen it in the wild. The point that matters for defenders: traffic to a trusted AI provider is traffic most companies already allow, so a stolen key can be more than a billing problem.
What happens in the first hour after a key leaks?
Less than you'd hope, and faster. Wiz looked at two enterprise cases where keys leaked from breached vendors were abused. The first unauthorized call came within 30 minutes of the credentials being accessed. One case ran about 800,000 Bedrock calls over roughly 30 hours, the other about 1.7 million calls in about 13 hours. Wiz estimated one of them likely ran up over $100,000 at list price.
The pattern is consistent across the research: check the key works, check the quotas and limits, then use as much as the account allows. Sysdig also saw attackers query logging settings, to see whether anyone would notice.
So you won't catch this at the end of the month. You catch it by making the key worth less on day one, and by having alerts that fire in hours.
Why don't the usual fixes stop it?
"We keep it in an environment variable, not in code." Good, but environment variables were exactly what got pulled in the platform breaches, and they're exactly what infostealers and CI stealers read.
"We'll rotate it if something happens." You'll only know something happened when the bill or a provider email shows up. And as Railway pointed out to its customers, reporting fraudulent charges doesn't revoke a key. You still have to revoke it at the provider.
"It's encrypted at rest." So were Railway's variables. Encryption at rest protects a stolen disk. It does very little once an attacker has the access the system itself uses to decrypt.
"Our provider will refund it." Maybe. Railway's report noted that refund terms differ by provider. Don't build your plan around goodwill.
How do I lock down my AI API keys?
Assume a key will leak someday, and set things up so that day is boring.
- One key per app and environment. No shared "company key." If your support bot's key leaks, you rotate one key and nothing else breaks.
- Scope every key. In the OpenAI platform, API keys have a Permissions setting: All (the default), Restricted, or Read Only. Restricted lets you set None, Read or Write per endpoint. In the Claude Console, API keys can be scoped to a single workspace, and then they can only touch that workspace's resources.
- Cap the spend where you can. Anthropic lets you set a monthly spend limit and rate limits per workspace. You can't set a spend limit on the Default Workspace, so put production apps in their own workspaces. On OpenAI, look at the usage limits and alerts in your organization and project settings, and check whether each one actually stops spending or only sends an email.
- Keep keys out of code. Use a secrets manager, not a committed
.env. Never put a provider key in front-end code. If your browser app calls a model, it should go through your own backend. - Prefer short-lived credentials. On AWS, use IAM roles for Bedrock instead of long-lived access keys. Elsewhere, use OAuth or federation where the tool supports it, as Darktrace recommends.
- Write down the rotation steps. Who can revoke each key, where, and what needs the new value. Test it once so it's a ten-minute job, not an afternoon.
Catch keys before they reach GitHub
GitHub push protection is on by default for personal accounts pushing to public repositories, but it's disabled by default at the repository level. Turn it on for your organization's repos. GitHub's list of supported secret scanning patterns includes Anthropic API keys.
Scan your history too, because "deleted" keys are still in old commits. With gitleaks:
# scan the current repo, including history
gitleaks git -v
# write a report you can review
gitleaks git --report-path gitleaks-report.json
And block new leaks on developer machines with a pre-commit hook in .pre-commit-config.yaml:
repos:
- repo: https://github.com/gitleaks/gitleaks
rev: v8.24.2
hooks:
- id: gitleaks
Then run pre-commit install. One note: the gitleaks README now says the tool is feature complete and its author is moving to a successor project, so check its status before you standardize on it.
Fence in Bedrock
If you use AWS Bedrock, an IAM or organization policy can stop a stolen credential from using regions you never use. Adjust the region list to yours:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenyBedrockOutsideApprovedRegions",
"Effect": "Deny",
"Action": "bedrock:*",
"Resource": "*",
"Condition": {
"StringNotEquals": {
"aws:RequestedRegion": ["us-east-1", "us-west-2"]
}
}
}
]
}
Test it in a non-production account first, especially if you use cross-region inference profiles. Wiz's research has a nice example of why tight scoping pays off: in one case the key's policy only allowed us.* inference profiles, so the attacker's calls through global.* profiles failed.
How do I check if my keys are already being abused?
Start with the provider dashboards. Look at usage per key and per project or workspace over the last 30 days. You're looking for models you don't use, traffic at hours your app is quiet, or a key that's busy when its app isn't.
On AWS, CloudTrail logs Bedrock runtime calls like InvokeModel and Converse as management events, which CloudTrail records by default. A quick look from the CLI:
aws cloudtrail lookup-events \
--lookup-attributes AttributeKey=EventName,AttributeValue=InvokeModel \
--max-results 50
Run it in each region you use, and repeat with Converse. Streaming calls also write a separate stream-completion record, so filter on event type AwsApiCall when you count.
For token-level detail, turn on Bedrock model invocation logging. It's disabled by default. Each record includes the calling identity (identity.arn), the model and token counts. Sent to CloudWatch Logs, a Logs Insights query like this shows who is using what:
fields identity.arn, modelId, input.inputTokenCount, output.outputTokenCount
| stats count(*) as calls,
sum(input.inputTokenCount) as inputTokens,
sum(output.outputTokenCount) as outputTokens
by identity.arn, modelId
| sort outputTokens desc
Every identity on that list should have a boring explanation. Then set a billing alarm low enough that a bad night wakes someone up.
What should I do if a key was exposed?
- Revoke the key at the provider. Not just in your app, at the provider.
- Create a new, scoped key and deploy it from your secrets manager.
- Check usage for the old key back to the earliest date it could have leaked.
- Rotate everything that sat next to it: same
.envfile, same CI secrets, same platform project. - Report unauthorized charges to the provider, keeping in mind that a charge report doesn't revoke anything.
- If the key leaked from a platform breach, follow that platform's guidance too. Railway, for example, told customers to rotate variables stored before its incident, remove public network access to databases, and review GitHub and container registry audit logs.
Want help sorting out your keys?
Most small teams I talk to have AI keys in more places than they think: a couple of hosting platforms, CI, a few laptops, and that one Zapier step someone set up last year. Finding them all and putting limits around them is a half-day job that saves a very bad week. If you're building with AI and want a second pair of eyes, take a look at my security reviews for AI-built apps or get in touch.
Frequently asked questions
What is LLMjacking?
Using stolen credentials to run AI models on someone else's account. The attacker gets the model access, often to resell, and the account owner gets the bill.
How fast do attackers use a leaked AI key?
Fast. In the cases Wiz studied, the first unauthorized call came within 30 minutes of the credentials being accessed, followed by hundreds of thousands of calls over the next day or so.
Will my AI provider refund fraudulent usage?
Sometimes, but don't count on it. Terms differ by provider, and reporting the charges doesn't revoke the key. Revoke first, then file the report.
Is an environment variable a safe place for an API key?
It's better than source code, but environment variables are exactly what platform breaches, CI stealers and infostealers collect. Use a secrets manager, scope the key, and cap its spend.
Does a spend limit stop LLMjacking?
It doesn't stop the theft, but it limits the damage. Anthropic supports monthly spend limits per workspace (not on the Default Workspace), which is why production apps should have their own workspace and key.
Sources
- Wiz: "Black October" for AI Developer Platforms
- The Hacker News: Railway says stolen customer AI keys led to unauthorized charges
- The Register: Thieves pilfer environment variables from Trigger AI workflow tool
- The Hacker News: 4,837 hijacked GitHub accounts ran CI secrets stealer
- Darktrace: Living off the AI, shared memories as a covert C2 channel
- Help Net Security: Stolen Claude API keys and a remote-controlled implant
- Sysdig: LLMjacking, stolen cloud credentials used in new AI attack
- CyberInsider: LLMjacking attacks escalate
- OpenAI Help: Assign API key permissions
- Claude Platform Docs: Workspaces
- GitHub Docs: About push protection
- GitHub Docs: Supported secret scanning patterns
- AWS: Monitor Amazon Bedrock API calls using CloudTrail
- AWS: Amazon Bedrock model invocation logging
- gitleaks on GitHub
Sara Wolpin is the founder of PinSecurity and a working CISO. She helps small businesses and teams building with AI lock down their apps, keys and cloud accounts before attackers find the gaps.
Want help with this in your business? PinSecurity turns these lessons into a plan.
Talk to Sara
