Your API keys are merchandise now. A lesson from the week Railway, LiteLLM and OpenCode went down
In one week of October, environment variables leaked from Railway, the official LiteLLM package shipped a secret stealer, and OpenAI, Anthropic and Google keys walked out of OpenCode. The common denominator is one thing. A key to an AI model has become the most liquid loot on the internet, and the agent you write code with is the first thing that can reach it. What follows from that, and what to do this weekend.
On Wednesday, 21 October, Railway, the hosting this site runs on, paused every build. The next day I pushed seventeen commits to GitHub and nothing happened. In the Railway dashboard I could not even see my own projects. The deploy went out on Monday, five days after the pause.
The reason is in Railway’s disclosure: an unauthorised party may have reached the systems that store customers’ environment variables and, “for some of them, obtained the decrypted contents”. Environment variables are that .env file where you keep the keys to your database, your image registry and your APIs. Railway also wrote that this is part of “a series of attacks recently targeting platform companies”, whose goal is to compromise AI inference providers, meaning the companies that sell access to models through an API: OpenAI, Anthropic, Google.
My Anthropic key, the one the bot on this site runs on, sits in exactly those variables.
The same day The Register described a poisoned release of LiteLLM 1.107.0, a popular gateway to AI models. The attackers hooked into the official release process through a repository whose name differs from the real one by a single hyphen (Berri-AI instead of BerriAI), so the malicious version went out the normal way, to PyPI and to Docker. Inside was a program that runs every time Python starts and collects environment variables, AWS, GCP and Azure credentials, keys to OpenAI, Anthropic and Cohere, SSH and GPG keys, plus the shell history.
Four days earlier OpenCode, an agent-based coding tool, admitted that OpenAI, Anthropic and Google keys connected by users may have leaked from its hosted console. It affected 1.4% of accounts, and some people woke up to a bill above 1,700 dollars for a single night. Anthropic and Google blocked the keys they considered exposed. OpenAI refunded the money.
Three incidents in one week, three different ways in, one kind of loot. Below I write why that loot became so valuable, where it really leaks from, and what you can do about it before you get the same notice from your own provider that I got from Railway.
A model key is money, not a password
A password to a client’s database is valuable to someone who knows what to do with that database. A key to an AI model is valuable to everyone, because it converts straight into cash or into anonymous compute.
The phenomenon has a name: LLMjacking. Someone uses another person’s model key, and the owner pays the bill. Sysdig described it back in 2024 and worked out that one stolen key to Claude 2.x can generate a bill of 46 thousand dollars a day, and to Claude 3 Opus more than a hundred thousand.
Those numbers are from 2024 and today they have a ceiling. Anthropic puts a monthly spend cap on every organisation, depending on the account tier: 500 dollars on Start, a thousand on Build, 200 thousand on Scale, and new accounts begin lower still. Once the cap is reached, the API stops answering until the first day of the next month. A stolen key from a small company will therefore burn at most the rest of the month’s cap, not a hundred thousand a day. A key from a large company on the Scale tier is still worth what Sysdig calculated. Your own limit below the ceiling, and a separate limit for each workspace, you set yourself in the console; OpenAI has the same arrangement, an assigned monthly limit plus your own alerts and hard limits per organisation and per project. And a stolen key has two uses.
First: the key as cash. Since 2024 a market has formed: resellers offer access to Opus at a dollar or two per million tokens, against a list price of fifteen dollars (Unit 42 via Cybernews). The buyer does not know, and does not want to know, whose card is paying.
Second: the key as fuel for the next attacks. Whoever holds someone else’s key holds anonymous compute: they can run their own tooling on it, and the trail leads back to the key’s owner. In the campaign the Cloud Security Alliance named Operation Bizarre Bazaar, stolen credentials were automatically checked against more than thirty model providers and listed on a marketplace. For an attacker it is the ideal merchandise: it reveals no identity, needs no laundering, and the buyer uses it up in minutes.
Where does the merchandise on such a market come from? Some of it from break-ins like Railway’s. But the cheapest source is developers who push their keys into public repositories themselves. GitGuardian, a company that scans public GitHub for leaked secrets, counts them.
| Measure (public GitHub, 2025) | Value |
|---|---|
| New secrets in commits | 28.65 million (+34% YoY) |
| Of which keys to AI services | 1,275,105 (+81% YoY) |
| Secrets in public MCP configuration files | 24,008, of which 2,117 still valid |
| Leak rate in Claude Code-assisted commits vs baseline | 3.2% vs 1.5% |
| Secrets valid in 2022 that are still valid in 2026 | 64% |
The last row matters most to me. Two thirds of the keys that leaked four years ago still work. Nobody revoked them, because nobody knew they had leaked.
A secret does not leak from the vault, it leaks from the process allowed to read it
The variables at Railway were encrypted. It did not help, because the attacker reached the layer that decrypts them. Encryption at rest protects you against a stolen disk. It does not protect you against someone who becomes the process authorised to read. That layer at Railway is the same kind of layer that, a day earlier at Google, took Revolut down for most of a working day. Why one such place brings everything down at once is a subject for a separate post.
The same pattern repeats in every incident this autumn. At Vercel in April, a compromised OAuth application gave access to an employee’s account, and through it to the decrypted variables of some customers. The only ones left untouched were variables marked as sensitive, which the platform by design shows to nobody once saved. One flag in the settings decided who leaked and who did not.
In Poland the strongest case is Fakturownia, an invoicing service with more than 600 thousand customers. The company confirmed unauthorised access from the evening of 28 September to the afternoon of 29 September 2026, and listed, among the data that may have been exposed, API tokens, integration tokens, and the application’s system keys and passwords. The remediation looked the way it always does: key rotation on the company’s side, replacement of customer tokens, old API keys restricted to known IP addresses. The attacker described their route as a SQL injection, from which they pulled the Rails master key, and from the key forged a session. That is the attacker’s account, not the company’s, so treat it as a hypothesis. But if it is true, it is the same scheme again: one secret with the right to everything.
An agent is such a process by definition
Here we reach the part that concerns you if you write code with Claude Code, Cursor, Codex or anything similar. A coding agent is allowed to read .env, because it has to be able to start the application. It has access to ~/.ssh, because it does git push. It runs shell commands, because that is what you have it for. In normal work it steers clear of files with secrets, but that is a decision of the model and a policy of the tool, not a system barrier. Technically it is a process with the right to read all your secrets, and a process that takes instructions as text.
The first big example is s1ngularity in August 2025. Malicious versions of the nx package, once installed on a developer’s machine, looked on disk for locally installed terminal versions of Claude, Gemini and Q and launched them with the flag that switches off permission prompts, with the instruction: find the files with secrets on this computer and list their paths. The victim’s agent was working for the attacker. The result was more than two thousand verified secrets from more than 1,700 people. Some of the instructions the models refused to carry out. Some they did not.
The second example is from a lab, but it shows the mechanism. MCP servers are how an agent gets tools from external programs: you connect a server, the agent sees new functions. In August 2026 researchers at ASSET showed a technique called GhostSplice: a malicious server splits a harmful instruction into harmless fragments, some in the tool’s description, some in its output. No fragment looks dangerous on its own. The agent assembles them in its head and sends the attacker .env, the SSH key and the customer file. The same model refused in one client and sent the files in another, because the safeguards around the model decide, not the model itself.
The third example is the most mundane, and therefore the most likely in your case. Claude Code saves the commands you answered “always allow” to into the file .claude/settings.local.json. If the command contained a key typed in plain, the key lands in the file. Check Point went through about 46,500 npm packages and found that file in 428 of them. Roughly one in thirteen contained credentials: npm tokens, GitHub tokens, production tokens for external services. Nobody stole them. People published them themselves, because npm publish does not warn about the .claude/ directory.
To complete the set, a hole in the tool itself: in Claude Code before version 2.0.65 (CVE-2026-21852) it was enough to clone a repository whose configuration pointed the API address at the attacker’s server. The key went there with the first request, before the tool asked whether you trust that folder.
Minutes, not days
If a key leaks, how fast does someone use it? Studies with honeytokens, keys planted on purpose that do nothing but raise an alarm, give a consistent answer.
| Where the key was planted | Time to first use |
|---|---|
| public repository on GitHub (AWS key) | 6.6 min on average, 1 min at the fastest |
| public image on Docker Hub | 1–3 min |
RDS database credentials in a .env on GitHub |
database login after 5 min |
Source: a round-up of studies by Clutch, Orca and Permiso. For contrast, the median time before a secret leaked to GitHub gets removed is, according to Verizon DBIR 2025, 94 days.
Six minutes against three months. No human wins that race by reading logs. The only alarm that in practice goes off in hours rather than months is a spend limit at the model provider. Some OpenCode users saw the leak first on their bill. And one more thing from that story: a budget set in an intermediary tool does nothing, because a stolen key goes straight to the provider. The limit has to be where the key is.
Poland is no exception
It is easy to read about Railway and Vercel as someone else’s problem. Fakturownia showed it is ours, and the regulator says the same. CSIRT KNF, in its 2026 report, lists API tokens, SSH keys, CI/CD secrets and service accounts explicitly as high-value targets, and rates concentration risk in cloud and SaaS as high.
There is also a thread few people remember if they run a small company. When your contractors’ data leaks from your SaaS, the data controller is you, not the provider. Fakturownia reminded its customers that they have their own duty to report to UODO, the Polish data protection authority, within 72 hours. In 2025 the authority logged more than 22 thousand breach reports, half as many again as the year before.
What to do this weekend
I will not tell you to build your own vault for secrets. The list below is one afternoon’s work, in order from the item that hurts most when it is missing.
- A spend limit and an alert at every model provider. OpenAI, Anthropic, Google, each one separately, in the provider’s console, not in an intermediary tool. It is the only alarm that works in hours.
- A separate key per project and a separate one for the agent. The key Claude Code works with on your machine must not be the one that serves production. Revoking one then does not stop the other, and the bill tells you which one leaked.
- Rotation rehearsed before the incident. At Railway a changed variable takes effect with a new deploy. Builds were paused, so for several days you could not do what Railway was asking for. Write down where every key lives and what has to be restarted after a change, before you do it under stress.
- Variables marked as sensitive, where the platform allows it. At Vercel that was the only set that did not leak in April.
- A secret scanner before commit. gitleaks or TruffleHog; the Shai-Hulud worm ran the latter on the other side, on victims’ machines, to look for loot. Better that you use it first.
- The
.claude/directory in.gitignoreand.npmignore. The filesettings.local.jsonhas no business in a package or a repository. - MCP servers reviewed like npm dependencies. Every connected server is code that tells the agent what to do. If you do not know who wrote it, do not connect it.
- Tool updates. Claude Code above 2.0.65. LiteLLM not at 1.107.0; if you had it, check whether
/tmpholds files named.pc_once_*, because that is the sign the exfiltration already happened. - For a small company: your own 72-hour duty. A leak at a provider is also your report to UODO, if it touched your customers’ data.
Caveats. As of 26 October Railway has not published a post-incident analysis, so it is not known how the attackers got in or how many customers the leak touched. The course of the Fakturownia attack is known from the attacker’s account, which the company has not confirmed. GhostSplice is lab testing on planted keys, not a reported production case. The GitGuardian numbers I read from write-ups, not from the full report. The sums rumoured to have been drained after the Railway incident I leave out, because nobody has confirmed them.
What comes next
One number is missing from this text, because it does not exist. I have not found a published study of how many minutes it takes for someone to use an OpenAI or Anthropic key planted in a public repository. For AWS keys it is six minutes. For model keys, which by everything above are worth more today, nobody knows. Such an experiment can be done for a dollar: a key with a spend limit, an alert, a test repo and a stopwatch.
Do you have production keys in a .env and no idea which process reads them? Write to me.
In November I got two emails about a security incident, one from Autopay about card data and one from bunny.net about TLS certificates. Both carry the same sentence, "we cannot rule it out", and in both the break-in happened at a company the customer never sees. How to read such an email, what to do about your card, and what follows if you hold other people's data yourself.