Unrestricted resource consumption: the limits an API has to set itself

Unrestricted resource consumption is what happens when an API lets one request, or one client, use more memory, CPU, bandwidth, storage or paid third-party calls than the service planned for. It is API4 in the OWASP API Security Top 10 2023. The usual result is a slow or dead service, or a bill nobody expected. A WAF can cap how often a client calls, but only the application knows what one call costs. This guide belongs to API security.

Section API security Updated Category OWASP API4:2023

Quick facts

OWASP category
API4:2023 Unrestricted Resource Consumption. OWASP rates its exploitability as average, prevalence widespread and detectability easy
Resources named
Network bandwidth, CPU, memory and storage, plus services billed per request
Weakness classes
CWE-770, allocation of resources without limits or throttling; CWE-400, uncontrolled resource consumption
Test for it
OWASP calls an API vulnerable if at least one limit is missing or set inappropriately, too low or too high
Typical outcome
Denial of service, or higher spend with a provider
Can a WAF fix it?
Only in part. It can limit request frequency per client. It cannot know how much memory, CPU or money one request will cost

Sources: the OWASP API4:2023 page for the category, limits and scenarios, and the MITRE entries for CWE-770 and CWE-400.

What gets consumed

OWASP opens the category with a plain observation: satisfying an API request takes network bandwidth, CPU, memory and storage. Some requests also trigger work at a provider, such as sending an SMS, a push notification, an email or a cloud call, and those are billed to the API owner for every use. Nothing in that needs a bug or an exploit. A request that is valid in every field can still be expensive.

That is why the category sits apart from classic injection. The payload is often ordinary. What is wrong is the absence of a ceiling, which MITRE describes in CWE-770 as a product that sets no intended limits on how many resources can be allocated or how large they can be. CWE-400 is the parent idea, a limited resource that is not controlled properly during allocation and upkeep.

Three shapes show up in the OWASP scenarios:

  • Many cheap calls with a costly side effect. A password-recovery endpoint that sends an SMS each time. OWASP gives a price of $0.05 per message in its example and notes that losses can reach thousands of dollars within minutes.
  • One request that carries a lot of work. The OWASP example is a GraphQL request that batches many image uploads, so the per-request limit is never reached while server memory runs out.
  • Plain growth of data served. A file that grows, pulled by many clients with no cost controls, and a cloud bill that rises with it.

The limits an API needs

OWASP lists the limits whose absence makes an API vulnerable. The table keeps its wording and adds what each one bounds. Pick values from your own measurements; no figure here is a recommendation.

Limits listed in OWASP API4:2023 and what each one bounds
LimitWhat it stops
Execution timeoutsA slow query or handler holding a worker for as long as the caller likes
Maximum allocable memoryOne process taking the memory the others need
Maximum number of file descriptors and processesConnections or child processes piling up until the host cannot open more
Maximum upload file sizeStorage and memory spent on a single oversized body
Operations per client requestBatching, such as many GraphQL operations in one call
Records per pageA list endpoint returning the whole table because the caller asked for it
Third-party spending limitProvider charges that grow with request volume

Size and shape of input

The prevention advice adds maximum sizes for all incoming parameters and payloads: string length, number of array elements and upload size. Depth of nesting belongs in the same family, because a document can be small on the wire and large once parsed. The extreme case is an XML bomb, where entity expansion multiplies a short input, and for query languages see the depth and batching limits on GraphQL security.

Pagination

OWASP asks for server-side validation of the parameters that control how many records come back. The word server matters: a client-supplied limit is a request, not a rule. Apply a default when it is missing and a ceiling when it is too high.

Containers and workers

OWASP also suggests running workloads in containers or serverless functions that cap memory, CPU, restarts, file descriptors and processes. This does not stop the expensive request. It keeps one expensive request from taking the neighbours with it.

The newest part of the category is financial. The 2023 edition lists third-party spending limits as a limit in its own right, and its advice is to set a spending limit with every provider the API calls, or at least a billing alert when the provider has no limit.

Frequency rules for sensitive operations belong here too. OWASP names one-time-password checks and password recovery as examples of operations to restrict per client or user, not only per address. The reasoning is in per-IP vs per-user limits: a bot spreading calls over many addresses stays under a per-address cap, while a quota on the account, phone number or key does not care where the call came from.

A quota differs from a rate limit in what it measures. A rate limit counts requests in a short window. A quota counts a budget, such as messages per phone number per day or export jobs per key per month, and it can be consumed slowly. Both are application decisions about cost; the application also has to say what happens at the end of the budget, ideally with a clear error and a header telling the client when to retry (see Retry-After).

Who enforces which limit

The same list reads differently depending on who can see the quantity. This split is a working division, drawn from the OWASP advice above, not a vendor claim.

Where each control usually lives
ControlApplicationEdge filter
Requests per client per windowYes, with account contextYes, by address or per domain
Body sizeYesNot a documented Bridge WAF control
Array length, nesting depthYes, after parsingNo
Page sizeYesNo
Execution time, memoryYes, runtime and containerNo
Spend per providerYes, with the providerNo

For the other layers of the same design see endpoint security, whose frequency-and-cost step is this page in short, and API abuse, which covers calls that are legitimate one by one and harmful in sum.

Where a WAF helps and where it does not

A WAF sees requests, not the work behind them. It cannot tell that one GraphQL body will take two seconds of CPU, that a recovery call sends a billed SMS, or that a huge page size reads half a table. Those costs exist inside the application and its providers, so quotas, timeouts, pagination ceilings and spending limits belong there, and nothing at the edge replaces them.

What the edge does well is frequency. Bridge WAF applies rate limiting per domain, so a client that calls too often can be refused with a 429 response before it reaches the origin. That covers the repeated-call shape from the OWASP scenarios, and it is the first layer of defence against a flood of otherwise valid calls. It is a blunt one: a limit set per domain does not know that one endpoint is far dearer than another. Read the options on rate limiting and the counting methods on rate limiting algorithms before choosing numbers.

Start in monitor mode. Matches are logged while every request is still served, and the monitor-mode log shows which clients would have been refused. Look for a heavy endpoint hit by a few clients; that is the call to protect in the application first. Move to block once the log shows only traffic you meant to stop. The three modes are in the box below.

Questions

What is unrestricted resource consumption?

It is API4 in the OWASP API Security Top 10 2023. An API is vulnerable when it lets requests use bandwidth, CPU, memory, storage or paid third-party services without limits. The harm is a degraded or unavailable service, or a larger bill.

Is it the same as a DDoS attack?

No. A flood overwhelms capacity with volume. This category is about missing limits: one valid request, or a few, can cost a lot. The result can look like an outage, but the cause is the lack of a ceiling in the application.

Which limits should an API set?

OWASP lists execution timeouts, memory, file descriptors, processes, upload size, operations per request, records per page and third-party spending. Add maximum sizes for string lengths and array elements, and quotas on sensitive operations such as password recovery.

How is a quota different from a rate limit?

A rate limit counts requests in a short window. A quota counts a budget over a longer period, such as messages per phone number per day. The quota keeps working against a client that sends slowly and spreads calls across many addresses.

Can a WAF prevent it?

Only the frequency part. A WAF can rate-limit clients and log heavy use, but it cannot see the cost of an operation inside the application. Size limits, pagination ceilings, timeouts and provider spending limits stay in the API.