Concepts · Level 3 · Note 10

How an AI model is served and billed, and how attackers run up the bill

Inference, batching, API keys, tokens, self-hosted servers and gateways in plain words, then LLMjacking, exposed Ollama servers, denial of wallet and leaked keys.

12 min read

Short answer

Using a trained model is called inference. It runs on GPU servers that batch many users' requests, sits behind an API, and is billed per token to whoever owns the key on the request. So a stolen key is a stolen line of credit: Sysdig described the attack, LLMjacking, in May 2024 and put the worst case at $46,080 a day. Self-hosting moves the risk to you: one study counted 175,108 Ollama hosts reachable from the internet. Keep keys out of code, set your own spend limit, cap output length, and never put a model server on a public address without authentication.

Every chatbot answer is a small computing job that somebody pays for. The job runs on a server, the server sits behind an API, and the API bills whoever owns the key that came with the request.

Most attacks on this chain are about that bill. Someone steals the key, or finds a server that never asked for one, or sends requests built to cost as much as possible.

Inference, in plain words

Think of school and work. Training is the years of school, which are long and expensive and happen once. Inference is the job afterwards, where the graduate answers one question at a time using what they already know.

Answering your question doesn’t teach the model anything. It leaves the conversation exactly as it entered. (Whether a provider keeps your chats to train a later model is a policy choice, separate from inference.) And school is paid for once, while every answer is paid for again.

Training happens once, inference happens on every request

TrainingThe model's numbers are adjusted over a huge amount of text until its predictions are good
done by the model makerchanges the model
The model fileThe finished numbers, called weights, are saved and copied to servers
fixed
InferenceYour text goes in, the weights are used to predict the next piece of text, again and again
every requestmodel unchanged
Our illustration. No numbers in this figure come from a source.

Inference, technically

A trained model is a large file of numbers called weights. Inference runs your input through those weights to score every possible next token, picks one, adds it to the text and repeats. The vLLM paper, written mostly at UC Berkeley, puts it this way: a model “can only sample and generate new tokens one by one”.

Each of those steps is a large amount of matrix arithmetic, and a GPU can do many of those multiplications at the same moment. The same paper says “running these applications is very expensive, requiring a large number of hardware accelerators such as GPUs”, and cites an estimate that “processing an LLM request can be 10× more expensive than a traditional keyword query”. Inference does not update the weights.

The inference server, in plain words

Picture a cook with one big grill. Cooking one order at a time would waste most of the grill, so many orders go on together. When one is done it comes off, and the next waiting order takes the free spot. Nobody waits for the whole grill to clear.

Your order stays your order. But everyone shares the grill, so how busy it is changes how long yours takes.

Animated: requests joining and leaving a shared GPU

Waiting in the queue

more arrive all the time
GPU batchone step writes the next token for every request in it
finished: Afinished: B
Steps request C has held its slot
  1. Requests from many users reach the server at different moments. Three are on the GPU and more wait.
  2. One step: the GPU writes the next token for every request in the batch at once. Each request keeps its own working memory.
  3. A wanted a short answer and is done. It leaves, and waiting request D takes the free slot right away.
  4. Another step. B finishes and E joins. Nobody waits for the whole batch to clear.
  5. C asked for a very long answer. It holds its slot and its memory for the whole run.
  6. The catch: everyone shares the hardware, so batching does not isolate users from each other's load. A request that forces a maximum-length answer holds a slot the longest. That last point is our reasoning. It is not a measurement. Cap output length per request.
Our animation of continuous batching as this note describes it. Bar lengths are for illustration.

The inference server, technically

An inference server loads the weights onto GPUs and takes requests over HTTP. The vLLM paper opens with where its throughput comes from: “High throughput serving of large language models (LLMs) requires batching sufficiently many requests at a time.”

The plain way to batch is to collect a group, run it, and return when the longest answer is done. Continuous batching reschedules at every token step instead: “After each iteration, completed requests are removed from the batch, and new ones are added.” The vLLM documentation lists “Continuous batching of incoming requests” among its features.

Each request in the batch keeps its own working memory, the KV cache, which grows as the answer grows. Batching does not isolate tenants (the different customers on one server) from each other’s load. A request for a very long answer holds its slot and its memory for the whole run, which matters in Attack 3. Shared hardware also leaks through timing. See Prompt caching and the KV cache and, for streamed answers, Temperature 0 is not deterministic.

The API and its meter, in plain words

A company fuel card is the closest everyday thing. The pump is the endpoint, the address your app sends its requests to. The card is the API key. Liters are tokens, and the bill goes to the card’s owner at the end of the month. The pump never looks at the driver, so whoever holds the card can fill up.

The API and its meter, technically

The endpoint is an HTTPS address. vLLM’s server, for example, serves the Chat Completions API at /v1/chat/completions. The API key travels with every request. It’s a bearer secret, which means the server checks the key and has no way to check who is holding it.

Billing is by token. Anthropic’s pricing page says “Tokens are pieces of text that models process”, and prices them per million, input and output separately. On 23 November 2026 it listed Claude Fable 5.2 at $8 per million input tokens and $40 per million output tokens. Output costs five times as much on that row (our arithmetic).

Providers put two kinds of limit on an account. Anthropic’s rate limits page defines them: spend limits “set a maximum monthly cost an organization can incur for API usage”, and rate limits are “measured in requests per minute (RPM), input tokens per minute (ITPM), and output tokens per minute (OTPM)”. The standard monthly spend caps on that page run from $500 on the Start tier to $200,000 on the Scale tier. You can set a lower one yourself.

These limits cap the damage, but they can’t tell your app from a thief with your key. On cloud platforms such as Amazon Bedrock the “key” is often your ordinary cloud credential, and the charge lands on the cloud bill.

Self-hosted model servers, in plain words

Running the model yourself is like owning a generator instead of buying from the grid. There’s no meter per token. You pay for the machine and the power, and the lock on the door is now your job. Some popular servers ship with no lock at all.

Self-hosted model servers, technically

Ollama is a common way to run open models on your own machine. Its FAQ says “Ollama binds 127.0.0.1 port 11434 by default”, so only programs on the same machine can reach it. One setting changes that: “Change the bind address with the OLLAMA_HOST environment variable.”

There is no login in front of that port. Wiz, in its Probllama write-up, states: “Ollama does not support authentication out-of-the-box.” In the Docker image Wiz examined, “the server runs with root privileges and listens on 0.0.0.0 by default”. The API also pulls and manages models, which is how the bug in Attack 2 worked. Ollama’s FAQ points to “a proxy server such as Nginx” for exposing it, and that proxy is where authentication has to go.

The model gateway, in plain words

A gateway works like a company front desk that holds the corporate credit cards. Staff never carry the cards. Each person gets a badge with their own allowance, the desk places the order on the right card, and it writes down who ordered what. Lose a badge and you cancel one badge. The desk drawer, though, still has every card in it.

Animated: a gateway that holds every provider key

App 1
App 2
Gatewaychecks virtual keys, counts the cost, keeps the logs
provider key 1provider key 2provider key 3admin key
Model providerssee only the gateway's keys and bill the account behind them
code running beside the gateway can read every key
  1. Without a gateway, every app carries a real provider key. Each copy is one more place to leak.
  2. A gateway sits in the middle. Each app gets a virtual key that only the gateway accepts, with its own budget.
  3. The gateway checks the virtual key, counts the cost, and forwards the request with the real provider key.
  4. Lose a virtual key and you cancel that one key. Nothing else changes.
  5. But the gateway now holds every real provider key, plus an admin key that can create more.
  6. Any code that runs in the gateway's environment can read all of them. The documented case in this note was a tampered software package with a credential stealer inside, not a break-in at a running gateway. Pin versions and rehearse rotating every key.
Our animation of the gateway design this note describes.

The model gateway, technically

A gateway, or LLM proxy, is a server you put between your apps and the providers. LiteLLM is a widely used open-source one. Its documentation describes it: “The LiteLLM AI Gateway is a self-hosted server.” “It gives your applications one OpenAI-compatible endpoint for 100+ LLM providers, MCP tools, and A2A agents.” You “Give each user, team, and project a virtual key”, and “Each key has its models, budgets, and rate limits.”

That gives you per-team budgets, one place for logs, and keys you can revoke one at a time. It does not reduce what an attacker gains from the gateway itself. The gateway holds the real provider keys, and LiteLLM’s virtual keys page describes a master key as “your Proxy Admin key - you can use this to create other keys”.

Animated: the token meter, and a stolen key

your appa stranger, same key
Provider APIchecks the key. Cannot check who holds it
Tokens counted for your app
Tokens counted for the stranger
Bill sent to the key's owner
your own spend limit caps the damagean alert on spend per hour
  1. Your app calls the model through an API. An API key travels with every request.
  2. The server checks the key. It has no way to check who is holding it.
  3. Every token in and out is counted, and the bill goes to whoever owns the key.
  4. Then the key leaks. A common way: it was pasted into code that became public.
  5. A stranger sends requests with it. To the meter they look the same as yours.
  6. A stolen key is a stolen line of credit. Spend limits cap the damage, but they can't tell your app from a thief. Keep keys out of code, set your own lower limit, and alert on unusual use.
Our animation of per-token billing and key theft as this note describes them. Bar lengths are for illustration.

The serving chain and where each attack lands

1. App or agentHolds a key in code, a config file or an environment variable
leaked keys
2. GatewayHolds the provider keys for everyone
supply chain
3. Provider APIChecks the key, counts tokens, sends the bill
LLMjackingdenial of wallet
4. Inference serverBatches requests onto GPUs, yours or the provider's
open portssponge inputs
Our mapping of the attacks described below onto a typical setup.

Attack 1: LLMjacking, running models on a stolen key

Sysdig’s threat research team described the attack under that name on 6 May 2024. The attackers they watched took cloud credentials from “a system running a vulnerable version of Laravel” and went looking for model access. Their tooling could “check credentials for ten different AI services”, including AWS Bedrock, Azure, OpenAI and GCP Vertex AI.

The test for access cost them nothing. They called the model with the parameter max_tokens_to_sample set to -1, and the error that came back told them the credentials could reach the model without running it. Sysdig found “evidence of a reverse proxy for LLMs being used to provide access to the compromised accounts”, and read the motive this way: “attackers intend to sell LLM access to other cybercriminals while the cloud account owner pays the bill.”

The cost figure is a worst case that Sysdig calculated, with no victim’s invoice behind it. Claude 2.x at the quota limit, around the clock, in four regions, comes to $46,080 a day. In a September 2024 follow-up Sysdig reported “a 10x increase in LLM requests during the month of July” and raised the worst case to “over $100,000/day” for a newer model, Claude 3 Opus.

If you use Bedrock, note one detail from that follow-up. Attackers called the API that turns models on, and Sysdig warns: “Models being disabled in Bedrock and the requirement for activation should not be considered a security measure.” What happens to a leaked cloud key in general is in our note on the first 5 minutes after an AWS key leaks.

What the published research counted

$46,080a day, Sysdig's worst case for one stolen cloud accountcalculated, May 2024
175,108Ollama hosts seen reachable from the internetover 293 days, SentinelLABS and Censys
11,908working keys and passwords in one public web archiveCommon Crawl, Truffle Security 2025
Sources: Sysdig 2024; SentinelLABS and Censys 2026; Truffle Security 2025.

Attack 2: model servers left open to the internet

When a server has no login, the attacker doesn’t need a key at all.

Wiz reported CVE-2024-37032, which it named Probllama, to Ollama on 5 May 2024. A patched version came out on 8 May. The bug was in the endpoint that pulls models: “Due to insufficient input validation, it is possible to exploit a Path Traversal vulnerability to arbitrarily overwrite files on the server”, which Wiz turned into remote code execution (running its own commands on the server) on Docker installs, where the server runs as root. The fix is in version 0.1.34. Wiz’s own scan “revealed over 1,000 exposed instances”.

Later scans found more. Cisco researchers searched Shodan for a study published in September 2025 and identified 1,139 exposed Ollama servers, which they call vulnerable. Of those, 214 (about 18.8%) were hosting models and answered a test prompt with no authentication. The rest were “reachable via unauthenticated interfaces” and had no model loaded.

Animated: a model server that ends up on the internet

Your machine
model serverno login in front of itlocal app
The internet
a stranger runs models on your hardwareand can pull and manage models
fix: a proxy that asks for a loginfix: check the bind address and port mappings
  1. Running the model yourself means no meter per token. A popular self-hosted server listens only on its own machine by default, so only programs on that machine can reach it.
  2. There is no login in front of that port. On one machine, that is fine.
  3. One setting changes the listening address. People change it for a demo, or so another machine can connect.
  4. Now the port answers on a public address. There is still no login.
  5. Internet scans find servers like this. A stranger can run models on your hardware, and the same interface also pulls and manages models.
  6. If the server has no login, there is no key to steal. Never put a model server on a public address without authentication. A proxy in front is where the login has to go.
Our animation of the self-hosting risk this note describes. The measured counts are in the chart below.

Where the 1,139 open Ollama servers in Cisco's study were hosted

United States
36.6%
China
22.5%
Germany
8.9%
Source: Tziakouris and Biasiotto, Cisco, September 2025. Top three countries only.

SentinelLABS and Censys ran a much longer study, published in January 2026: “Over 293 days of scanning, we identified 7.23 million observations” of “175,108 unique Ollama hosts across 130 countries”. The three counts used different methods and time spans, so they don’t form a trend line.

Attack 3: making every request expensive

OWASP lists this as LLM10:2025 Unbounded Consumption. One of its forms is denial of wallet, where “attackers exploit the cost-per-use model of cloud-based AI services”. The attacker needs no stolen key for this. A public chatbot with no limits will spend its owner’s money for them.

The research root is a paper called “Sponge Examples” by Shumailov and five co-authors, accepted at IEEE EuroS&P. They built inputs that soak up compute, “increasing energy consumption by a factor of 10 to 200.” In one test, reported in the first version of the paper, “With a 50-character input to Microsoft Azure translator, we can increase the latency from 1ms up to 6s”. Those were vision and language models of 2020, translation systems among them, so the numbers don’t carry over to today’s chat models.

The mechanism does. The paper shows odd spellings breaking into more tokens, and more tokens mean more work. With per-token billing and continuous batching, a request that forces a maximum-length answer costs the most and holds a GPU slot the longest. That last sentence is our reasoning. It is not a measurement.

Attack 4: keys that leak through code and training data

Many keys get out with no theft involved, because their owners publish them. GitGuardian’s State of Secrets Sprawl 2026 report counts “28.65 million new hardcoded secrets” added to public GitHub commits in 2025, and says “AI service secrets reached 1,275,105, up 81% year over year.” That is a vendor’s count from its own scanning.

Keys also sit in the data models learn from. Truffle Security scanned the December 2024 Common Crawl archive, a public copy of 2.67 billion web pages that its post treats as LLM training data, and found 11,908 secrets that still worked. In their words, “A ‘live’ secret authenticates successfully.” And “63% were repeated across multiple web pages.”

The post doesn’t claim that a model hands out those keys. Its concern is habit: “LLMs can’t distinguish between valid and invalid secrets during training”, so a model trained on pages full of hardcoded keys may suggest hardcoding yours.

Attack 5: the gateway holds every key

The documented case is an attack on the gateway’s software supply chain. It was not a break-in at a running gateway. On 24 March 2026, LiteLLM’s maintainers reported that “The compromised PyPI packages were litellm==1.82.7 and litellm==1.82.8.” The packages were live “for about 40 minutes before being quarantined by PyPI.” Version 1.82.8 carried a file named litellm_init.pth, and the post says the packages “appear to have included a credential stealer” that looked for environment variables, SSH keys and cloud credentials. The maintainers state the cause as a belief: “We believe that the compromise originated from the Trivy dependency used in our CI/CD security scanning workflow.”

The post also says who escaped: “Customers running the official LiteLLM Proxy Docker image were not impacted.” That image pins its dependencies, meaning it installs fixed versions and doesn’t pick up the newest release. The .pth startup trick is the same one we took apart in the agent-framework PyPI compromise.

A poisoned package is a gateway problem because any code that runs in a gateway’s environment can read every provider key it holds.

What to check, with an example

Every scenario below is illustrative. We made them up to show the check.

  1. Where does each key live? Keys in source code get copied. Illustrative: a developer pastes a provider key into a test script and the repo later goes public. Scan for secrets before every push and keep keys in a secret manager.
  2. Does every key have its own ceiling? A tier cap covers a whole class of customers and can sit far above what you can afford. Illustrative: a team has one shared key and no limit of its own, so a stolen key can spend up to the tier cap. Set your own monthly spend limit and give each app its own key with a small budget.
  3. Will anyone notice unusual use? Illustrative: usage jumps at 3 a.m. and the first signal is the invoice. Sysdig’s advice is to monitor for “unexpected LLM usage”. Turn on model invocation logging and alert on spend per hour.
  4. Can one user make one request expensive? OWASP’s fixes are to “Apply rate limiting and user quotas” and to “Set timeouts and throttle processing for resource-intensive operations to prevent prolonged resource consumption.” Illustrative: a public chatbot accepts a pasted book, allows the longest possible answer, and gets called in a loop by a script. Cap input size and output tokens per request.
  5. Is any model server reachable from outside? Illustrative: a container started for a demo publishes port 11434 on a cloud VM with a public address. Check the bind address (the network address the server listens on) and the Docker port mapping on every machine that runs one. Wiz’s advice is “not to expose Ollama to the internet unless it is protected by some sort of authentication mechanism”.
  6. What does the gateway hold, and what runs next to it? Illustrative: a gateway installs the newest package version on every restart, in an environment that holds five provider keys. Pin versions, keep the admin key out of app configs, and rehearse rotating every provider key.

On AWS, give each agent a narrowed credential instead of your full session. Our note on STS GetScopedCredentials shows how.


Sources (all checked 23 November 2026)

  • Kwon et al. (UC Berkeley and others), “Efficient Memory Management for Large Language Model Serving with PagedAttention”, SOSP 2023: arxiv.org/abs/2309.06180
  • vLLM documentation, feature list: docs.vllm.ai, and “Online Serving”: docs.vllm.ai
  • Anthropic, Claude Platform documentation, “Pricing”: platform.claude.com, and “Rate limits”: platform.claude.com
  • Ollama documentation, FAQ: docs.ollama.com/faq
  • LiteLLM documentation, “LiteLLM AI Gateway”: docs.litellm.ai, “Virtual Keys”: docs.litellm.ai, and “Security Update: Suspected Supply Chain Incident”, March 2026: docs.litellm.ai
  • Brucato (Sysdig), “LLMjacking: Stolen Cloud Credentials Used in New AI Attack”, 6 May 2024: sysdig.com
  • Sysdig Threat Research Team, “The Growing Dangers of LLMjacking: Evolving Tactics and Evading Sanctions”, 18 September 2024: sysdig.com
  • Wiz Research, “Probllama: Ollama Remote Code Execution Vulnerability (CVE-2024-37032)”, 24 June 2024: wiz.io
  • Tziakouris, Biasiotto (Cisco), “Detecting Exposed LLM Servers: A Shodan Case Study on Ollama”, 1 September 2025: blogs.cisco.com
  • Bernadett-Shapiro, Cutler (SentinelLABS, with Censys), “Silent Brothers: Ollama Hosts Form Anonymous AI Network Beyond Platform Guardrails”, January 2026: sentinelone.com
  • OWASP GenAI Security Project, “LLM10:2025 Unbounded Consumption”: genai.owasp.org
  • Shumailov, Zhao, Bates, Papernot, Mullins, Anderson, “Sponge Examples: Energy-Latency Attacks on Neural Networks”, IEEE EuroS&P: arxiv.org/abs/2006.03463, full text of the first version: ar5iv.arxiv.org
  • GitGuardian, “The State of Secrets Sprawl 2026”, 17 March 2026: blog.gitguardian.com
  • Leon (Truffle Security), “Research finds 12,000 ‘Live’ API Keys and Passwords in DeepSeek’s Training Data”, 27 February 2025: trufflesecurity.com