Railway, the cloud hosting platform, published its final incident report on November 10. Attackers broke out of its build system, worked their way to the key that decrypts customer environment variables, and went looking for one thing above all: AI provider keys. The stolen keys then ran up roughly $740,000 in model usage that customers never asked for.
That's LLMjacking in one sentence: someone else uses your AI account and you get the bill. If your product stores an OpenAI, Anthropic or Gemini key in an environment variable on a hosting platform (and most do), this incident is a free lesson in how to limit the damage before it's your turn.
TL;DR#
- Attackers queried Railway's secrets database for variable names that looked like AI keys, decrypted them for up to about 100,000 workspaces, and resold or reused the access.
- Refunds depend on the provider. Some refunded under fraud policies, one refused, and Railway says it is covering the gap.
- The fix is architectural: keep provider keys out of app environments, put a gateway with hard budgets in front of them, and make rotation a routine you can run in minutes.
What happened in the Railway breach#
On October 20 an attacker exploited an unknown flaw in Railway's shared build infrastructure to partially escape filesystem isolation. That exposed a build credential, which an internal job system accepted as trusted. Through it, the attacker pulled stored build histories (353 of them, secrets included) and a copy of Railway's internal monorepo.
With the source code in hand, they found a misconfigured OIDC trust binding, got short-lived cloud credentials, and reached a machine holding a longer-lived credential that could decrypt customer variables. Database logs show they filtered rows with regular expressions matching AI provider key names and targeted customers with lots of variables.
According to eSecurity Planet's summary, the exposure covers at most 1.85% of workspaces, linked-account tokens for 1,852 users, and about $740,000 in fraudulent AI usage. Railway says the observed misuse ranged from coding agents to AI training pipelines, consistent with keys being resold through relay services.
Railway wasn't alone. Its report lists OpenCode, Warp and Fireworks AI among platforms that disclosed similar thefts in October, and Wiz has documented the pattern as "Black October".
Why LLMjacking is now the default payoff#
Five years ago a leaked database password was the prize. Today an AI key is easier to cash out. It needs no lateral movement, works from anywhere, and converts straight into compute that can be resold. Google's threat intelligence team describes LLMjacking as the monetization of foundation model access through things like token proxying.
Three properties make it painful for a business:
- Usage is billed to you, not the attacker. Pay-per-token pricing means a stolen key is a blank cheque until someone notices.
- It doesn't look like an attack. The requests are valid API calls. Your app keeps working, so nothing pages anyone.
- Refunds are not guaranteed. Railway's report shows AWS Bedrock and Google Gemini refunding under fraud policies, OpenAI reviewing case by case, and OpenRouter holding to a no-refund policy. You were lucky if your host offered to pay.
The technical breakdown: where the blast radius comes from#
Look at how most small and mid-size teams wire AI into a product:
Typical setup Safer setup
------------- -----------
App env: OPENAI_API_KEY=sk-... App env: GATEWAY_TOKEN=gw_...
| |
v v
Provider (no spend cap per app) AI gateway (per-token budget, logs, alerts)
|
v
Provider (key never leaves the gateway)
In the typical setup, the raw provider key sits in every environment that calls a model: production, staging, a preview branch, maybe a contractor's laptop. Any one of those leaking gives the attacker your whole provider account.
The trade-offs of a gateway#
| Approach | Blast radius if leaked | Effort | Main downside |
|---|---|---|---|
| Raw provider key in app env | Whole provider account | None | No per-app limits, slow detection |
| Provider project keys with spend limits | One project's budget | Low | Limits vary by provider and can lag |
| Self-hosted or managed AI gateway | One internal token's budget | Medium | Another service to run and secure |
| Gateway plus short-lived tokens | Minutes of capped spend | Higher | More moving parts in auth |
A gateway is not free security. It becomes a high-value target, so it needs its own secrets handling, logging and patching. But it turns "attacker has our key" into "attacker has a token capped at $50 a day that we can kill with one click."
What it means for your business#
If you're a scaling company with AI features in production, the question isn't whether a vendor in your stack will be breached. It's how much a breach costs you when it happens.
A few practical implications:
- Your hosting provider is part of your AI key security. Environment variables encrypted at rest still get decrypted somewhere. Railway's design used per-environment envelope encryption and an attacker still reached the decryption path.
- Finance needs a line of sight. A sudden jump in model spend is often the first visible signal of a leaked API key. If nobody watches that number daily, you'll find out from the invoice.
- Rotation has to be cheap. Railway customers who revoked keys during the incident couldn't redeploy while builds were paused, and some services went down. If rotating a key requires a deploy, you'll hesitate to do it.
LLMjacking defense checklist: what to do this week#
Here's the order we'd tackle it in for most teams:
- Inventory every AI key. List each provider, project, environment and service that holds one. Delete anything unused.
- Rotate anything that lived on an affected platform. Railway advises rotating credentials stored before October 21. Revoke at the provider, not just in your config.
- Split keys by workload. One key per service and environment, so a leak from staging can't spend production budget.
- Set hard spend limits and alerts. Use the provider's project budgets where available, and alert on daily spend above a normal baseline.
- Put a gateway in front of production traffic. Apps get internal tokens; only the gateway holds provider keys. Log tokens, models and cost per request.
- Make rotation a runbook. Pull keys from a secrets manager at runtime so you can rotate without a redeploy, and practice it once a quarter.
- Watch for odd usage patterns. Models you don't use, requests at strange hours, or traffic from unfamiliar regions are all worth an alert.
None of this needs a security team. It needs one engineer, a few days and a decision to treat AI keys like payment credentials.
How MagicMakers Lab approaches this#
When we add AI to an existing stack through our AI integration and automation work, the provider keys never ship inside the client's app. We route model calls through a small gateway with per-service budgets, request logs and a kill switch, then hand over the runbook for rotating keys. The same habit of scoping access and logging every action shows up in systems like Framico, where order automation touches payments and fulfilment with no manual steps. If you're adding agents, our agentic development work applies the same idea to tools: scoped access, approval gates and a record of every call.
Key takeaways#
- LLMjacking turns a leaked API key into direct cost, and attackers now hunt for AI keys first.
- Railway's breach exposed environment variables for up to about 100,000 workspaces and led to roughly $740,000 in fraudulent usage.
- Provider refund policies differ, so don't assume you'll get the money back.
- A gateway with per-token budgets shrinks the blast radius from your whole account to one capped token.
- Fast, routine API key rotation is the control that matters most on the day of an incident.
FAQ#
What is LLMjacking?#
LLMjacking is when attackers steal credentials for an AI model provider and use them to run their own workloads on your account. You pay for the tokens. Stolen keys are often resold through relay services or used for model distillation. It usually starts with a leaked API key in code, a build log, or a breached hosting platform.
How do I know if my AI API key was leaked?#
Check your provider's usage dashboard for models, volumes or times you don't recognise, and compare daily spend against your normal baseline. Look for requests from unfamiliar IP ranges if your provider logs them. If the key was stored on a platform that disclosed a breach, treat it as leaked and rotate it regardless of what the logs show.
Will AI providers refund fraudulent API charges?#
It depends on the provider and the case. In Railway's incident, AWS Bedrock and Google Gemini refunded under existing fraud policies, OpenAI reviewed claims case by case, and OpenRouter kept its no-refund policy. Report unauthorized charges quickly, keep billing evidence, and don't plan your risk around getting refunded.
What are API key security best practices for AI apps?#
Keep provider keys out of application environments, use a separate key per service and environment, set hard spend limits with alerts, and route production traffic through a gateway that logs every request. Store keys in a secrets manager so you can rotate them without a redeploy, and rehearse rotation before you need it.
If you're not sure how exposed your AI keys are, or how fast you could rotate them tonight, we'll walk through your setup with you and point out the biggest gaps. Book a free audit.
Sources#
- Incident Report: October 21st Security Attack (Railway)
- Railway Breach Leads to $740,000 in Fraudulent AI Charges (eSecurity Planet)
- Railway breach leads to $740,000 in fraudulent AI charges (BleepingComputer)
- Black October for AI developer platforms (Wiz)
- The Rise of LLMJacking (Google Cloud Threat Intelligence)