What Is LLM Jacking? How to Cap Your AI API Keys
LLM jacking uses stolen AI API keys to run up huge bills. Learn how keys leak through agent history and config files, and how spend limits cap the damage.
For Engineering, IT and Security

What is LLM jacking?
LLM jacking is the theft and abuse of API keys for large language models (LLMs). An API key is a secret password that lets software use an AI service and bill your account. If an attacker finds your key, they can run their own AI workloads on your tab. Reported cases include single-day fraudulent charges above $100,000, and in the most severe cases cumulative abuse reached $1 million before the victim stopped it.
TL;DR
- LLM jacking is key theft for free AI compute. Attackers scan for exposed AI keys and burn through your balance as fast as the key allows.
- Your coding agent keeps secrets in plain text. Any password you paste into a conversation is stored locally in the agent's history file, unencrypted.
- A settings file can leak the same secret a second time. One security company found 1,122 public copies of Claude Code's
settings.local.jsonholding at least one secret. - You cannot guarantee a key never leaks. The practical defense is a spending limit on every key, including test keys.
- A short audit takes only minutes. Check hooks, connected tools, committed config files and git history.
- This is not only an engineer's problem. Anyone who has pasted an AI key into a script, spreadsheet macro or no-code tool is exposed.
Why are AI API keys such a target?
Because they turn directly into money and capability. A stolen AI key gives an attacker compute they did not pay for, and AI models now sit behind a large share of what attackers do, including scanning for more targets and writing exploits. More stolen keys means more funding for more scanning.
The scale of the hunt is large. Amazon set up decoy cloud instances to watch what hit them and saw thousands of scanners and agents constantly probing for exposed ports and other ways in. Many of these tools are automated, and some are likely built with AI themselves, so they find a mistake within minutes of it going public. Once a key is found, the goal is to use it up as quickly as possible.
Even large companies slip. One of Cursor's access keys, which it had given to Fireworks, was reported exposed. If it happens there, it can happen to a small team with a shared spreadsheet of credentials.
How do API keys actually leak?
Most leaks are not dramatic hacks. They are ordinary habits. Two of them involve AI coding agents (tools like Claude Code that read and edit your project and run commands for you).
Plain-text conversation history
Coding agents store your conversation history on your computer, usually in a JSONL file (a simple text file with one record per line). If you ever paste a key or password into the chat, it sits in that file in plain text. If your machine is compromised, an attacker does not need to break anything. They read the file.
Approved commands saved in a settings file
The second route is less obvious. Say you give the agent a database password and it uses that password inside a command. When you approve the command, the agent can add it to an allow list in its configuration file. In Claude Code, that file is settings.local.json. Now the password is stored in a second place, and that place is usually inside your project folder.
If your project is a git repository and you push it to a public site like GitHub, that file can go with it. The credential now lives on the internet.
Is that a real problem or a theoretical one?
It is real. Claude Code's creator has said that settings.local.json should never be pushed to source control and belongs in the ignore list (the .gitignore file that tells git which files to skip). The ".local" in the name is a hint. But a software security company scanning thousands of GitHub repositories found 1,122 public copies of that file holding at least one secret. Nobody intends to publish a password. It happens by accident, and attackers can run the same scans the security researchers did.
How much damage can one leaked key do?
It depends on what the key can spend. A key with no limit can spend your entire balance, or if your account bills in arrears, run up a bill you only see at month end. That is how single-day charges above $100,000 happen. The attacker does not need to be clever after the key is found. They only need to be fast.
This is why the question to ask about any key is not "could this leak?" but "what is the most this key could cost me if it did?"
How do spend limits protect you?
A spend limit caps the cost of a leak. If the key is capped at $50, the worst case is $50 plus the annoyance of replacing it. Without a cap, the worst case is whatever your account allows.
OpenRouter, a service that gives access to many AI models through one key, supports this directly. A creator who builds with AI agents showed using it this way: a separate key for each project, a weekly limit on every key, and on some keys a permanent limit, for example a key that can only ever use $50 of tokens.
Three habits make limits work:
- One key per project or tool. If one leaks, you revoke one key and nothing else breaks.
- A limit on every key. This includes keys for dev testing. Test keys leak just as often as production keys, because test code is where people get casual.
- A limit sized to real use. Look at what the tool actually spends in a normal week, then set the cap slightly above that.
Not every provider offers the same controls. Check whether yours lets you set limits per key, per project or only per account. If it only offers account-wide limits, set the lowest one you can live with and consider routing your usage through a service that supports per-key caps.
What should you do today?
Here is a short checklist. Most of it takes minutes.
- List your AI keys. Check your provider dashboards (OpenAI, Anthropic, Google, OpenRouter, anything else) and write down every key and what it is used for.
- Cap each one. Set a spending limit. Delete keys you no longer use.
- Stop pasting secrets into agent chats. Put keys in environment variables or a secrets manager, and let the agent reference them by name.
- Check your ignore file. Confirm that
settings.local.jsonand any file with credentials is listed in.gitignore. - Search for keys already committed. Look in your current files and in your git history, since deleting a secret from the latest version does not remove it from old commits. If you find one, revoke it. Do not just delete it.
- Review what your agent can run. In Claude Code,
/hooksshows the hooks running and what triggers them, and/mcpshows the connected MCP servers (outside tools the agent can use). Other coding assistants have similar commands for skills, extensions and tools. Do this once in a while, because things get added without you noticing.
Claude Code also warns you when a configured hook will run a command without asking. That is useful, because attackers have gone after agent configuration directly. Google Threat Intelligence reported attackers modifying a coding agent's settings so that starting the tool triggered a malware download. Treat your agent's config like you treat your passwords.
If you want a more thorough check, the creator behind the source material built an audit skill (a reusable instruction file for a coding agent) that scans a repository for startup-running config, poisoned dependencies, secrets in local config and in conversation history, fake editor extensions, hidden instructions in rules files and exposed AI keys. Whether you use it or do the checks by hand, run it on each repository you care about.
Who does this change things for?
Engineers and builders using coding agents have the most exposure. Agents handle credentials, install packages and run commands, so one careless approval can copy a secret into a file you did not think about.
Analysts, marketers and operations staff who write small scripts or automations are in the same position. A key pasted into a shared notebook, a macro or a no-code tool is still a key. The same rules apply: one key per tool, a cap on each, never in a shared document.
Managers and team leads should ask a simple question: do we know every AI key our team uses, and what is each one allowed to spend? If nobody can answer, that is the first task.
The attack methods are getting cheaper to run, so the sensible response is to make a leak cheap to survive. Perfect secrecy is a harder goal than a small cap.
Can you build AI tools without handling keys yourself?
Fewer keys in circulation means fewer chances to leak one. If you want an internal tool that uses AI, such as a request form that summarizes submissions or a tracker that drafts replies, one option is a platform that supplies model access itself. Remy builds and deploys full-stack business apps from a plain-English description, and its apps can call AI models without you managing separate provider keys. AI usage is billed at cost from a funded balance, or you can use your own Anthropic, OpenAI or Google keys if you prefer. That means one controlled balance instead of keys scattered across scripts. You still need to protect your account login and any keys you do choose to bring.
Frequently Asked Questions
What does LLM jacking stand for?
It is a play on "hijacking." Attackers take over someone else's access to large language models by stealing an API key, then use the victim's account to pay for their own AI usage. The name is used by security researchers for this specific kind of abuse.
How do I know if my API key has leaked?
Watch your usage and billing dashboards for spikes you cannot explain, and set alerts if your provider offers them. Also search your repositories and git history for key strings. If you suspect a leak, revoke the key right away and create a new one with a spending limit.
Is deleting the key from my code enough?
No. If the key was ever committed to git, it remains in the history, and anyone who copied the repository has it. Assume it is compromised, revoke it at the provider, and issue a replacement.
Should I set limits on test keys too?
Yes. Test keys are often the least protected and the most likely to end up in a public repository. A low cap on a test key costs you nothing in normal use and limits the damage if it leaks.
Do spend limits stop an attacker from using my key?
No. A limit does not prevent misuse, it caps the cost. Until you revoke the key, an attacker can use it up to the limit. That is why limits work best alongside good habits: no secrets in chats, ignored config files and regular audits.
How we source, write, and correct our articles. Editorial standards
Related articles

How to Run Long Unattended Tasks With Gemini 4 Carbon

How to Deploy an AI-Built App to a VPS Securely

What Guardrails Does an AI Agent Need Before Production?
