Applied AI

How do you keep a stolen AI API key from running up the bill?

Stolen AI provider keys from a hosting breach ran up about $740,000. Cap each key's spend, watch usage like fraud, and rotate without a rebuild.

3 min readDEV GroupApplied AI · Security

Stolen AI keys turn straight into money

Treat every AI provider key like a company card: give it its own spend cap, watch its usage like fraud, and make sure you can rotate it without a rebuild. Railway's incident report, published 10 November 2026, shows why. On 20 and 21 October 2026, an attacker escaped isolation in the hosting platform's build system, chained internal credentials, and decrypted customer environment variables for at most about 100,000 workspaces, 1.85% of the total. The attacker's database queries searched for variable names that looked like AI provider keys. Another query matched cloud, database, and payment service credentials. Railway estimates unauthorized spend on the stolen keys at about $740,000, from coding agents to training pipelines, and says it will cover charges the AI providers decline to refund. It asked GitHub, GitLab, Anthropic, OpenAI, OpenRouter, Google, Stripe, and others to revoke keys that might have been exposed, and reset linked-account tokens for 1,852 users. The report names OpenCode, Warp, and Fireworks AI among platforms that disclosed similar thefts between 6 and 23 October. An AI key is now a target in its own right, because it turns straight into money.

One key, one cap, set at the provider

Give each app and each environment its own key, never one key shared across them, so a theft has a known owner and a known blast radius. Where the provider offers project budgets, usage limits, or per-key caps, set them at the provider, not only in your own code, because a stolen key never passes through your code. Size the cap to normal use plus headroom, keep development and test keys far lower than production, and alert well before the cap is reached. Better still, keep the raw key off the hosts that do not need it. Route model calls through a gateway or proxy you run, which holds the provider key and gives each app a scoped, short-lived credential, or use the cloud provider's workload identity where it is available. Then a leaked environment variable is worth little outside your network.

Watch usage like fraud, rehearse rotation

Watch usage the way a card issuer watches transactions: spend per hour against the usual baseline, models you do not use, requests from unfamiliar networks, and volume at hours your product is quiet. Log each model call with the key or credential that made it, so you can tell real traffic from misuse. Railway says customers' indicators of compromise, source IP addresses, and examples of unauthorized requests helped it tell the intrusion apart from the later misuse. Practice rotation before you need it. Railway's report notes that customers who revoked a credential could not redeploy with a new one while builds were halted, and some had downtime. Make sure a key can be replaced in a running service without a full rebuild, run the old and new keys side by side during the cutover, and count the rotation as done only when a test call with the old key fails. Keep an inventory of every AI key: where it is stored, which app uses it, its cap, and a named owner. Per-key caps, a gateway that holds the provider key, usage alerts, and a rotation you have rehearsed are software work at the seams, and that is where we fit.

Sources

Was this useful?

Get in touch

Seeing one of these in your system?

Describe what exists today and where it breaks. We will come back with a technical point of view and a scoped first step.