Safety, Security & Responsible AI·Question 12 of 70Basic

What is a denial-of-wallet attack, and how do you defend against it?

Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.

Model answer: the part to lead with

Denial of wallet is the economic form of denial of service: the attacker does not take your system down, they make it expensive. It sits under OWASP LLM06:2026, unbounded consumption (LLM10 in 2025). The core problem is cost asymmetry. A short, cheap prompt from an attacker can trigger a long, expensive generation from you, and with reasoning models the ratio got much worse: a handful of tokens in can produce a large reasoning trace plus an answer, all billed to you. An agent makes it worse again, because one request fans out into many model calls plus retrieval plus tool calls.

Full worked answer

Denial of wallet is the economic form of denial of service: the attacker does not take your system down, they make it expensive. It sits under OWASP LLM06:2026, unbounded consumption (LLM10 in 2025). The core problem is cost asymmetry. A short, cheap prompt from an attacker can trigger a long, expensive generation from you, and with reasoning models the ratio got much worse: a handful of tokens in can produce a large reasoning trace plus an answer, all billed to you. An agent makes it worse again, because one request fans out into many model calls plus retrieval plus tool calls.

The vectors worth naming: oversized inputs stuffed into a long context window; prompts engineered to maximise output length or reasoning effort; recursive or looping agent tasks; RAG fan-out where one query retrieves and summarises dozens of chunks; aggressive retry logic on your side amplifying the attacker's single request; and free-tier or unauthenticated endpoints, which are the usual entry point. Note that the most common cause in practice is not an attacker at all, it is your own agent stuck in a loop, or a customer's runaway script. The controls are the same, which is a nice thing to point out.

Defences, cheapest first: authenticate before you spend anything expensive; per-user and per-key quotas on requests and on tokens, not just requests, because tokens are what you pay for; a hard token budget and step cap per session; caps on input length and on max output tokens; timeouts; a cheap classifier or small model to triage before invoking an expensive one; caching for repeated work. Then the safety net: hard spend limits configured at the provider, plus anomaly alerts on cost per user, cost per session and tokens per request at p99, so you learn about it in minutes rather than on the invoice.

The framing that lands in an interview: for a normal API, rate limiting is about availability. For an LLM API, rate limiting is a financial control, and the budget alert is a security alert.

What a good answer covers

  • Denial of wallet is the economic form of denial of service
  • It sits under OWASP LLM06:2026, unbounded consumption (LLM10 in 2025)
  • The core problem is cost asymmetry
  • A short, cheap prompt from an attacker can trigger a long, expensive generation from you, and with…
  • An agent makes it worse again, because one request fans out into many model calls plus retrieval plus…

Interviewer follow-ups to expect

  1. How would you set the quota if legitimate power users are 50x heavier than the median user?

  2. Where does per-tenant cost attribution have to live so that you can even detect this?

Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep