In three October days, OpenAI and Anthropic keys were stolen two ways: through a poisoned LiteLLM release and through a breach at Railway. What happened, how to check your product in 15 minutes, and how to make the next leak cheap.
- Published
- Reading
- 12 min
- Author
- Yaroslav Tsarenko

Between October 20 and 23, 2026, keys for OpenAI, Anthropic and other model providers were stolen in two unrelated ways. The first was a poisoned release of LiteLLM, the popular Python library and proxy for calling many AI providers through one interface. The second was a breach at Railway, a cloud hosting platform, where an attacker decrypted part of its customers' environment variables.
This piece is for founders and teams who have at least one model call in their product. I'll cover what actually happened, why attackers now go after AI keys in particular, how to check in 15 minutes whether you were exposed, and how to set up your keys so the next leak costs pocket change instead of a month's budget.
What happened this month
Two incidents that overlapped in time but have nothing to do with each other. Both companies published reports, so what follows is their account, not rumor.
| LiteLLM | Railway | |
|---|---|---|
| What it is | Python library and proxy for 100+ models | Cloud hosting for apps and databases |
| What happened | Malicious version 1.107.0 published to PyPI and Docker | Attacker reached encrypted environment variables and decrypted a subset |
| When | Oct 21, ~11:40–13:23 UTC (PyPI) | Oct 20, 13:58 UTC to Oct 22, 03:32 UTC |
| Scale | ~49,000 downloads, per Wiz | up to 1.85% of workspaces, about 100,000 |
| Target | cloud credentials, AI provider keys, browser cookies | AI provider keys for distillation |
| Primary source | LiteLLM postmortem | Railway preliminary report |
The common thread: nobody broke into OpenAI or Anthropic. The attacker collected working keys where customers kept them — on developer machines, in CI and in a hosting provider's environment variables.
Why AI keys are the new target
A year ago, the most valuable lines in a .env file were the cloud and database credentials. Today the same file holds a key that unlocks paid access to some of the most expensive compute in the world. And there is a market for it.
A stolen key gets used in at least three ways:
- Distillation. Query a model at scale and train your own model on its answers. In February, Anthropic described campaigns by three AI labs that used roughly 24,000 fraudulent accounts. Railway's report says outright that the attacker was most likely after AI keys for distillation.
- Resale. Keys end up behind "proxy" services that resell cheap model access.
- Further attacks. Anthropic's September 2026 threat report describes a single stolen key being used for about three weeks to run secondary attacks. The same report notes several groups compromising AI wrapper services' LiteLLM setups and pulling production keys out with prompt injection.
For the key owner the outcome is the same either way: a bill that grows without a single new customer, an account suspended by the provider for suspicious activity, and a question from your lawyer if anything was extracted from your data through that key.
LiteLLM: how one forgotten key reached 49,000 installs
The most instructive part of this story is how it started. On May 27, 2026, a config file containing a master key for an internal tool was accidentally pushed to a public LiteLLM repository. The commit was removed. The key was not revoked.
- May 27Key pushed to a public repocommit removed, key never revoked
- Oct 10Forgotten key reusedorg owner's GitHub CLI token
- Oct 10–12Secrets pulled from CImalicious workflows, runs deleted
- Oct 21, 11:40 UTCRelease 1.107.0PyPI and Docker, built from a lookalike fork
- Oct 21, 13:23 UTCQuarantine~49,000 downloads in under two hours
On October 10, the attacker used that key to obtain the GitHub CLI token of the organization owner and from then on acted as real engineers: running malicious workflows that exfiltrated CI secrets, then deleting the run records. On October 21, they published version 1.107.0, built from a fork under a lookalike organization name, Berri-AI. The release was approved with a stolen maintainer token, so the publishing pipeline saw nothing unusual.
What the package did is documented in detail by Wiz. On install it dropped cook.pth into site-packages. Python executes .pth files on every interpreter start, so the code ran even on machines that never imported LiteLLM. It collected:
- saved passwords and cookies from Chrome, Firefox, Edge and Safari;
- AWS credentials (including instance metadata), GCP service account keys and Azure tokens;
- keys for OpenAI, Anthropic, Cohere and other providers;
- SSH and GPG keys and shell history;
- upstream provider credentials from the LiteLLM Proxy database.
Everything was encrypted and posted to a domain that looked like the official one. According to Wiz, within hours the attacker was already testing stolen AWS credentials, including listing which Bedrock models were available.
One more thing worth knowing: this is the second time in 2026. In March, versions 1.82.7 and 1.82.8 were published by the TeamPCP group after it compromised Trivy, a security scanner used in the project's CI (Datadog's analysis). A popular library that every AI key passes through is a natural target.
The lesson for your team: deleting a secret from Git history does not remove it. If a key was ever public, even briefly, revoking it is the only fix.
Railway: when keys are stolen from your platform, not from you
The second incident hurts more because Railway's customers did nothing wrong. According to the company's report, the attacker started with a privilege escalation attempt in the build infrastructure, then obtained CI credentials and used them to decrypt part of the customers' environment variables.
Key facts from the report:
- up to 1.85% of workspaces (about 100,000) had variables that were potentially compromised. Because of envelope encryption, Railway can't say exactly which keys were decrypted;
- the attacker was specifically searching for AI provider keys and favored environments with many variables;
- Railway worked with GitHub, GitLab, Anthropic, OpenAI, OpenRouter, Stripe and others to revoke potentially exposed keys, revoked all of its own API tokens and paused builds during the investigation;
- it recommends that everyone who signed up before October 21 rotate keys stored in environment variables, remove public network access to databases and review GitHub and container registry audit logs.
One practical detail people miss: your app reads environment variables when it starts. If you change a key in the dashboard but don't redeploy, the service keeps running with the old one. And if the old one is already revoked, the service simply goes down.
The lesson differs from LiteLLM's: you don't control how your host stores secrets. You do control how much each individual key can do. More on that below.
What one infected machine gives away
Founders tend to picture a leak as "we lost the OpenAI key." In reality, an infostealer on a developer laptop or a CI runner takes everything that machine can reach — and each layer opens the next one.
The AI key at the center is "only" money. Cloud credentials reach your servers and backups. A GitHub token reaches your code and CI, which means the ability to ship a malicious version of your product. Browser cookies reach email, payment dashboards and admin panels, often bypassing two-factor authentication because the session is already open. That is exactly how the LiteLLM attack unfolded: one key → a GitHub token → CI secrets → a release.
So rotating "just the OpenAI key" after an incident like this is not enough. You have to work through every ring.
Were you exposed? A 15-minute check
Start with three questions: did you install LiteLLM on October 21, do you host on Railway, and could any key sit where a browser can read it?
LiteLLM. Check the version everywhere it might be: laptops, CI, servers, Docker images.
pip show litellm | grep -i '^version'
python -c "import site; print(site.getsitepackages())"
ls "$(python -c 'import site; print(site.getsitepackages()[0])')" | grep -E 'cook\.(pth|py)|sitecustomize\.py'
docker images --format '{{.Repository}}:{{.Tag}} {{.CreatedAt}}' | grep -i litellmIf you see 1.107.0, a cook.pth or cook.py file, or a LiteLLM image pulled on October 21 with the tags v1.107.0, latest, main-latest or main-stable, treat every credential on that machine as compromised. Wiz names 1.106.2 as the last safe version; pin it explicitly instead of relying on latest.
Railway. If your project lives there and was created before October 21, rotate everything in its environment variables: AI keys, Stripe, databases, email, third-party APIs. Railway has published separate guides for PostgreSQL, MySQL, MongoDB and Redis, and for checking key usage in OpenAI, Anthropic, Stripe, AWS and GitHub.
Keys in the browser. Not related to the October incidents, but the most common leak in vibe-coded apps, as I covered in 10 signs your MVP needs a developer. A small script can search the files that ship to the browser. Node.js 22.18+, 24 and 26 LTS run TypeScript directly:
import { readdir, readFile } from "node:fs/promises";
import path from "node:path";
const PATTERNS: [string, RegExp][] = [
["OpenAI", /sk-(?:proj|svcacct|admin)-[A-Za-z0-9_-]{20,}/g],
["Anthropic", /sk-ant-[A-Za-z0-9_-]{20,}/g],
["Stripe live", /[sr]k_live_[A-Za-z0-9]{20,}/g],
["AWS access key", /AKIA[0-9A-Z]{16}/g],
];
async function* files(dir: string): AsyncGenerator<string> {
for (const entry of await readdir(dir, { withFileTypes: true })) {
const full = path.join(dir, entry.name);
if (entry.isDirectory()) yield* files(full);
else if (/\.(js|mjs|html|json|map)$/.test(entry.name)) yield full;
}
}
const root = process.argv[2] ?? ".next/static";
let found = 0;
for await (const file of files(root)) {
const text = await readFile(file, "utf8");
for (const [name, re] of PATTERNS) {
for (const m of text.matchAll(re)) {
found++;
console.log(`${name.padEnd(15)} ${file} ${m[0].slice(0, 12)}…`);
}
}
}
console.log(found ? `\n${found} secret(s) in client files. Rotate them, then move the calls to the server.` : "No secrets found in client files.");
process.exit(found ? 1 : 0);Run it after a build: node scan-bundle.ts .next/static for Next.js or node scan-bundle.ts dist for Vite. If a key made it into client code, you'll see:
OpenAI .next/static/chunks/app-page-4f2a.js sk-proj-AbCd…
1 secret(s) in client files. Rotate them, then move the calls to the server.On a clean project it prints No secrets found in client files. and exits with 0. Add it to CI right after the build step: the non-zero exit code stops the deploy before a key reaches production.
The first 24 hours: rotating without downtime
The most common mistake during an incident is revoking the old key first and then hunting for every place it was used. The product goes down and support fills up. The right order is the reverse.
- Make an inventory. Every secret on the affected machine or host: AI keys, cloud, database, Stripe, email, GitHub, container registry, third-party APIs. A table of "key — where it's used — who owns it" takes half an hour and saves the rest of the day.
- Start with what opens other doors. GitHub, cloud and database first, then money (Stripe), then AI keys.
- New key → deploy → revoke the old one. Create the new key, update it in every environment, redeploy, confirm everything works, and only then revoke the old key.
- Review usage. In the OpenAI, Anthropic, cloud and Stripe dashboards, look at the last few weeks: unfamiliar models, night-time spikes, new regions, keys or members you didn't add.
- Review audit logs. GitHub (new tokens, workflows, deploy keys, OAuth apps), your container registry, your cloud logs.
- Set hard limits. If you missed something, a spend cap limits the damage.
- Write down what you did. A short note with timestamps and the list of rotated keys will help with customers, investors and the next incident.
For a small product with one or two services, the whole plan usually fits into a few hours. The slow part is not rotation; it's finding every place a key lives. That's why step one matters most.
Making the next leak cheap
You can't rule out a leak entirely: you don't control your host, your dependencies or your contractors' laptops. You can make sure each individual key buys an attacker as little as possible. Both major providers already give you the tools.
Never
- Code the browser can seeanyone with DevTools will find it
- A public repositorynot for a minute, not in a deleted commit
- One key for everythingdev, staging, prod and a laptop
Yes
- Server environment variablesa separate key per environment
- Restricted keyonly the models and endpoints you use
- Spend limita hard monthly cap per project
One key per environment and service. The key on a developer's laptop should not work in production. OpenAI scopes keys to projects; Anthropic scopes them to workspaces. Create separate ones for dev, staging and prod. A leak from CI then doesn't touch live customers, and revoking one key doesn't take down the whole product.
Least privilege. OpenAI lets you create keys with Restricted permissions and limit which models a project can use through an allowlist in the project's admin settings. If your product uses one inexpensive model, a stolen key shouldn't unlock the most expensive one.
A hard spend limit. In OpenAI, limits are set per project: with the hard limit enforced, requests past the cap fail with a 429 error. In Anthropic, the limit is set per workspace and must be below the organization's limit. Both providers note that enforcement isn't instantaneous, so actual spend can slightly exceed the cap. The gap between "slightly over" and "unlimited" is the gap between an annoyance and a disaster.
Keys only on the server. The browser or mobile app talks to your API, and your API talks to the model. That's where you add authentication, per-user rate limits and caching.
In AllShip AI, the assistant answers from the user's own loads and bids, and every call goes through the server, which builds the context from the database. The key never reaches the browser, and the server decides which data the model is allowed to see.
Pinned dependencies. Both LiteLLM incidents in 2026 hit people who installed "the latest" version automatically. Lockfiles (package-lock.json, uv.lock, poetry.lock), npm ci instead of npm install in CI, and Docker images pinned by digest rather than latest buy you time: malicious releases are usually spotted and pulled within hours, and you upgrade on purpose.
The flip side: a lockfile holds a vulnerable version just as firmly, until you upgrade it on purpose. A fresh example is the November Next.js security release, where use cache could serve one customer's data to another; I covered how to check your version and code in the use cache leaks guide.
Block commits that contain secrets. GitHub can reject a push that contains a known key format (push protection). It's on by default for pushes to public repositories; turn it on for private ones too. It targets exactly the mistake that started the LiteLLM story.
Scheduled rotation. Rotate production keys on a calendar — say, quarterly — even without an incident. A key that lives for years ends up in old backups, chat threads and former contractors' laptops. And a team that has rotated calmly a few times doesn't panic when it has to do it for real.
What this means for your business
If you're a founder rather than an engineer, take away three things.
First: an AI key is money, not configuration. Treat it like access to your bank dashboard. Who has it, where it lives and what its limit is should all have clear answers.
Second: questions for your team or contractor. Ask for written answers:
| Question | A good answer |
|---|---|
| Where do our AI keys live? | Only in server environment variables, separate per environment |
| What spend limit is set? | A hard monthly cap on the production project, alerts at 50% and 80% |
| What happens if a key leaks? | A documented rotation, done in an hour or two without downtime |
| How do we update dependencies? | Through a lockfile and reviewed changes, not auto-upgrading to "latest" |
| Do we scan for secrets in code? | Yes: push protection and a build check in CI |
Third: vendor incidents are normal; being unprepared for them is not. Railway and LiteLLM published detailed reports within days, which is the right behavior. Your job is to respond to their "rotate your keys" within an hour, not a week.
What to do today
The October incidents are not a story about LiteLLM or Railway being bad. They show that AI keys have become a valuable commodity, and attackers hunt for them wherever they're stored: laptops, CI, hosting platforms and browsers.
Start small. Check that you're not running LiteLLM 1.107.0, that you aren't on Railway with old keys, and that no key ships in your client code. Then split keys by environment, set hard limits and pin your dependencies. If AI is only now coming into your product, build it this way from day one: keys on the server, limits, separate environments. That's how I approach AI integration in client products.
Was this useful?
– likes · – views
Questions people ask
What should I do if my OpenAI or Anthropic API key leaked?
Create a new key, put it into production and restart the services that use it, then revoke the old one. After that, review usage and spend in the provider dashboard for the past few weeks and set a hard monthly spend limit on the project or workspace.
How do I know if the LiteLLM attack affected me?
Check whether you installed litellm 1.107.0 from PyPI, or pulled Docker images tagged v1.107.0, latest, main-latest or main-stable on October 21, 2026. Signs of infection are cook.pth, cook.py and sitecustomize.py in site-packages. According to Wiz, 1.106.2 is the last safe version.
Do I need to rotate keys if my app runs on Railway?
Railway recommends that every customer who signed up before October 21, 2026 rotate the secrets stored in environment variables, remove public network access to databases and review GitHub and container registry audit logs. Services must be redeployed after variables change.
Why do attackers want AI API keys specifically?
An AI key is paid access to expensive compute. Stolen keys are resold, used to run further attacks, or used for distillation: harvesting a model's answers at scale to train another model. The key owner pays the bill.
Can I avoid having an AI API key in my product at all?
You will need a key, but it should live only on the server, be separate for each environment, carry restricted permissions and a model allowlist, and sit under a hard monthly spend limit. Then a stolen key buys an attacker very little, for a short time.