A denial-of-wallet attack doesn't take your AI feature offline — it keeps it running perfectly while quietly inflating your token bill until the invoice, not an outage page, is the incident report. Attackers exploit metered, usage-based pricing by forcing expensive inference paths: long contexts, retries, tool calls. Your dashboards show green uptime the whole time.
Quick Answer: Denial-of-wallet (DoW) targets your AI feature's cost structure instead of its availability — an attacker triggers maximum-cost requests (huge context windows, retry storms, expensive tool invocations) that stay within rate limits but blow through your budget. Defend with per-user token budgets, output caps, real-time cost alerting, and circuit breakers wired to spend, not just error rate.
What Is a Denial-of-Wallet Attack, and How Is It Different From DoS?
A denial-of-wallet attack aims to maximize the cost of serving legitimate-looking requests, not to crash the service. Classic denial-of-service (DoS) floods a system until it falls over; DoW does the opposite — it keeps every request valid and successful, because a successful, expensive request is exactly what generates the charge. Your SRE team sees healthy latency and error-rate graphs; your finance team sees a bill that tripled.
The term predates generative AI — it originated in serverless and cloud-billing contexts, where an attacker could invoke functions or storage operations enough times to run up a victim's cloud bill without ever taking the app down. The Cloud Security Alliance and OWASP's Serverless Top 10 both flagged "denial of wallet" as a distinct risk category well before LLMs made it acutely worse.
Why LLM Pricing Makes This Worse Than Traditional Cloud DoW
Token-metered inference turns cost into a function of content, not just request count. A single API call with a 200,000-token context and a verbose system prompt can cost hundreds of times more than a short one — and both look identical to a rate limiter counting requests per minute.
- Traditional DoW (serverless, storage, bandwidth): cost scales roughly linearly with request volume.
- LLM DoW: cost scales with volume times content size times model tier, and a single crafted request can spike cost without spiking request count at all.
- Rate limiting alone catches the first driver and misses the other two — which is exactly why teams that rely solely on requests-per-minute limits get surprised.
This is a close cousin of prompt injection and jailbreaking, but the objective differs: an attacker running a jailbreak defense strategies bypass usually wants unsafe output; a DoW attacker wants expensive output, and doesn't care what it says. Both deserve a place in your AI safety complete guide threat model, but they need separate controls.
What Are the Main Denial-of-Wallet Attack Vectors?
The three highest-leverage vectors are long-context stuffing, retry-loop amplification, and expensive-tool triggering — each turns a normal-looking user action into a disproportionately costly backend operation. A fourth, lower-effort vector — high-frequency low-cost requests — still matters at scale even when each call is individually cheap.
Long-Context Stuffing
An attacker pastes maximum-length documents, repeated filler text, or deliberately verbose input into any field that gets passed to the model — a chat box, a "summarize this" upload, a support ticket field. Because most LLM APIs price input tokens, a request that pads context to the model's ceiling costs far more than a typical one, even though it's a single, rate-limit-compliant call.
This vector is especially dangerous in retrieval-augmented systems: if user input controls how many chunks get retrieved and stuffed into context, an attacker can indirectly inflate the prompt size without touching the prompt field at all.
Retry-Loop Amplification
A client (malicious or just badly written) that retries aggressively on timeout, rate-limit, or partial-failure responses can multiply cost several times over per original request. This is worse when your own backend has an internal retry policy stacked on top of the client's — two retry layers compound.
- No backoff or jitter on retries turns a transient 429 into a request storm.
- Retries on streaming responses that fail partway through often resend the full prompt, not just the missing tail — doubling cost for a partial failure.
- Retries triggered automatically by frontend polling (a chat UI that resubmits on any non-200) can run unattended for hours.
Expensive-Tool Triggering
In agentic or tool-using systems, some tool calls cost dramatically more than others — a web search, a code-execution sandbox, a call to a second, pricier model, or a multi-step chain that re-invokes the LLM to decide what to do next. An attacker who learns which prompts reliably trigger the expensive path can repeat that trigger cheaply from their side while it's expensive on yours.
This is the vector platform PMs underestimate most, because it requires understanding the agent's decision logic, not just the entry endpoint. A single user message that causes an agent to spin up five sub-calls, each invoking a tool, can cost 10-50x a plain chat turn — and nothing in your entry-point logging shows that multiplier unless you're tracking cost per session, not per request.
High-Frequency, Low-Cost Requests
Individually cheap requests, sent at volume from many accounts or IPs, add up the same way credential-stuffing attacks add up on login endpoints — no single request looks abnormal. This is the vector standard rate limiting is best at catching, which is precisely why sophisticated actors avoid it in favor of the three above.
| Vector | What makes it costly | What typical rate limiting catches |
|---|---|---|
| Long-context stuffing | Input token count, not request count | Rarely — request looks like one normal call |
| Retry-loop amplification | Duplicate work per original request | Sometimes — if retries share a client fingerprint |
| Expensive-tool triggering | Cost multiplier hidden inside agent logic | Almost never — invisible at the entry point |
| High-frequency low-cost | Sheer volume | Usually — this is what rate limiting was built for |
The table's takeaway: rate limiting is necessary but insufficient. It's tuned to catch volume, while three of the four real vectors hide their cost inside content, retries, or internal logic that a per-minute request counter never sees.
How Do You Design Guardrails Against Denial-of-Wallet Attacks?
Effective DoW defense combines four control types working together: per-user token budgets, hard output caps, real-time cost alerting, and circuit breakers tied to spend rather than error rate. No single control catches every vector above — budgets stop stuffing, caps stop runaway generation, alerting catches what slips through, and circuit breakers are the last line that actually stops the bleeding.
Token Budgets per User
Set a maximum token allowance per user per time window (hourly, daily, monthly — pick the granularity that matches your billing cycle and your worst-case blast radius). This should cover both input and output tokens, tracked cumulatively, not reset by a clever attacker splitting a large request into several smaller ones.
- Define budget tiers by user segment — free, trial, and paid tiers should have meaningfully different ceilings, not a single global cap.
- Enforce budgets at the gateway layer, before the request reaches the model provider, so a blocked request never incurs cost at all.
- Decay or reset budgets on a schedule that matches your cost-reporting cadence, so a budget breach maps cleanly to a specific invoice period.
- Log budget-denial events separately from normal errors — a spike in denials is itself a signal worth alerting on.
Output Caps
Cap max_tokens (or your provider's equivalent) on every request, and cap it per feature, not globally — a summarization feature and an open-ended chat feature have very different legitimate output-length needs. An uncapped or generously-capped output parameter is one of the simplest ways an attacker (or a bug) inflates cost, because output tokens are typically priced higher than input tokens across major providers.
- Set the cap to the smallest value that still serves the legitimate use case, then measure real usage and adjust — don't guess high "to be safe."
- Combine output caps with prompt engineering that discourages verbose responses; a tighter system prompt reduces both cost and cap-truncation risk.
- Watch for streaming responses that ignore a stop sequence — some providers apply caps differently for streamed vs. non-streamed calls.
Real-Time Cost Alerting
Alert on spend velocity, not just absolute spend — a threshold alert that fires after you've already spent your monthly budget in six hours is too late to prevent the damage, only useful for the post-mortem. Track cost per minute/hour against a rolling baseline and alert on deviation, the same way you'd alert on a latency or error-rate anomaly.
| Alert type | What it catches | Typical latency to detection |
|---|---|---|
| Absolute monthly threshold | Slow, sustained overspend | Days to weeks |
| Rolling hourly baseline deviation | Sudden spikes, burst attacks | Minutes to an hour |
| Per-user/per-session cost anomaly | Single-account abuse, compromised keys | Near real-time |
The practical implication: absolute thresholds are a safety net, not a defense — by the time they fire, the damage is largely already billed. Baseline-deviation and per-account anomaly alerts are what actually catch an attack in progress.
Circuit Breakers Tied to Spend
A circuit breaker that trips on error rate protects your uptime; a circuit breaker that trips on spend rate protects your budget — and most teams only build the first one. Define an automatic cutoff (pause the feature, downgrade to a cheaper model, or require manual override) when spend velocity crosses a defined threshold, independent of whether the system is technically "healthy."
- Set the threshold below your actual pain point — a circuit breaker that trips at the exact number that would bankrupt you trips too late to matter.
- Prefer graceful degradation (fallback to a smaller model, reduced context window, or cached response) over a hard outage when possible — this keeps the feature usable while cutting cost.
- Require a human-in-the-loop reset for anything beyond a defined severity, so an attack can't be immediately retried the moment the breaker resets automatically.
- Test the breaker like you'd test a failover — a control nobody has fired in staging is a control you don't actually have.
How Do Denial-of-Wallet Attacks Relate to Prompt Injection and Abuse?
Denial-of-wallet often rides alongside other abuse vectors rather than standing alone — a prompt injection payload can be engineered to also be a long-context stuffing payload, and a jailbreak attempt that fails at eliciting unsafe content can still succeed at forcing an expensive retry loop. Treating cost abuse as a separate category from safety abuse misses these overlaps.
Shared surface, different objective is the key mental model. A prompt injection payload hidden in a document your AI summarizes can be crafted to instruct the model to "repeat the following 50,000 times" — that's a safety failure and a cost attack in the same input. Content moderation classifiers, covered in content moderation classifier tradeoffs, are tuned to catch unsafe content, not necessarily unsafe cost profiles — a classifier can pass a request as perfectly benign while it's still financially damaging.
- Design abuse review to ask two questions per input path, not one: "could this produce harmful output?" and "could this be structured to maximize cost?"
- Retry storms often follow failed jailbreak attempts — an attacker probing for a bypass generates many rejected requests, and rejected requests that still consume tokens (because moderation runs after generation) are a cost sink even when the safety system works correctly.
- Abuse patterns worth correlating: a spike in moderation rejections from one account, paired with a spike in token spend from the same account, is a stronger signal than either alone.
How Should Teams Design and Review Cost Guardrails Before Shipping?
Cost guardrails need the same pre-ship scrutiny as safety guardrails, ideally interrogated by someone whose job is to ask "what breaks this" before a feature reaches production, not after the first anomalous invoice. Most teams have a security or safety reviewer who asks that question about jailbreaks and unsafe content; far fewer have anyone asking it about spend.
That same discipline of asking "who can break this and how" before commitment is worth applying broadly — mapping how a feature will actually be used, including by adversarial actors, is closer to a proper customer journey exercise than a security checklist, because attackers are users too, just with different goals than the ones your JTBD research usually surfaces.
A Pre-Ship Checklist for Any New AI Feature
- Does every user-facing entry point have a token budget enforced at the gateway, not just in application code?
- Is
max_tokenscapped per feature, and does the cap match the smallest output that still serves the use case? - Does cost alerting fire on velocity/baseline deviation, not only on an absolute monthly ceiling?
- Is there a circuit breaker tied to spend rate, tested at least once outside of production?
- Have you mapped which tool calls or agent steps carry a cost multiplier, and does anything limit how many times a single session can trigger them?
Key Takeaways
- Denial-of-wallet targets cost, not uptime — a feature can show perfect availability metrics while its bill spirals, so cost needs its own monitoring, not a proxy through error-rate dashboards.
- The riskiest vectors hide from standard rate limiting — long-context stuffing, retry-loop amplification, and expensive-tool triggering all look like normal, rate-limit-compliant requests.
- Token budgets and output caps are the first line of defense, enforced at the gateway before a request ever reaches the model provider so blocked requests cost nothing.
- Alert on spend velocity, not just absolute thresholds — a monthly ceiling alert fires too late to prevent damage; baseline-deviation alerts catch attacks in progress.
- Circuit breakers need a spend trigger, separate from an error-rate trigger, tested like a failover so it's a control you actually have, not one you assume you have.
- Cost abuse and safety abuse often share the same input path — review both risks together, since a single crafted prompt can be a jailbreak attempt and a cost attack at once.
- Pre-ship adversarial review matters as much for cost as for content — asking "what stops someone from driving this bill to the moon" belongs in spec review, not incident response.
Frequently Asked Questions
What is a denial of wallet attack in AI systems?
A denial of wallet attack is when an actor deliberately forces costly, metered operations — long-context requests, retries, or expensive tool calls — to inflate a company's AI infrastructure bill, without ever making the service unavailable. It's a financial attack, not an availability attack, and it can go undetected by uptime monitoring entirely.
How is denial of wallet different from a DDoS attack?
A DDoS attack aims to overwhelm capacity until the service becomes unavailable; a denial of wallet attack keeps every request successful and valid, because a successful request is what generates cost. You can pass every uptime SLA and still take the financial hit.
Can rate limiting alone prevent LLM cost abuse?
No — rate limiting catches high-frequency request volume but misses attacks that hide cost inside content size, retries, or internal agent logic. A single request with a maxed-out context window or one that triggers a multi-step tool chain can cost far more than dozens of ordinary requests combined, and standard per-minute limits won't flag it.
What's a reasonable token budget to set per user?
There's no universal number — it depends on your feature's legitimate use case, pricing tier, and margin tolerance. Start by measuring actual token usage from your best-behaved users, set the budget at a multiple (commonly 2-5x) of that observed ceiling per tier, and tighten it as you gather more usage data rather than guessing a round number upfront.
Do circuit breakers for cost need to be separate from uptime circuit breakers?
Yes — an uptime circuit breaker trips on error rate or latency and protects availability, while a spend-based circuit breaker trips on cost velocity and protects budget; a system can be perfectly healthy by the first measure while failing badly by the second, so they need independent thresholds and independent triggers.