# Lack of Resources and Rate Limiting

{% hint style="danger" %}
**At a Glance**: 🛡️ **Resource Limit Vulnerability** occurs when an attacker causes an API to consume excessive resources, such as CPU, memory, or network bandwidth, beyond its intended capacity. This can lead to **Denial of Service (DoS)** attacks, where the API becomes unavailable or unresponsive due to resource exhaustion. Proper rate limiting and resource management are essential to prevent such attacks and ensure the stability of the API.
{% endhint %}

***

## What are the common mistakes made by developers?

Resource-limiting vulnerabilities in APIs can happen due to various reasons. Here are some common causes:

1. Lack of access controls: APIs may not have proper access controls in place to limit the number of requests per user or per IP address. This can allow attackers to send a large number of requests to the API and cause it to consume excessive resources.
2. Insufficient input validation: APIs may not properly validate input data from users, allowing attackers to send maliciously crafted data that can cause the API to consume excessive resources. For example, an attacker could send a request with a very large search query that causes the API to perform an extensive search operation.
3. Lack of resource allocation controls: APIs may not have controls in place to limit the amount of resources that can be consumed by each request. For example, an API endpoint may allow users to download large files without any restrictions on the file size or download speed.

## How can I fix lack of resources limiting issues?

&#x20;API designers should implement appropriate access controls, input validation, resource allocation controls, and optimize the code to reduce resource consumption. Additionally, they should monitor the API usage patterns and implement measures to handle unexpected traffic spikes and usage patterns.

## Test cases in this category:

This test case queries excessive number of elements

<table><thead><tr><th>Test case</th><th width="231.33333333333331">OWASP</th><th>CWE</th><th data-hidden></th></tr></thead><tbody><tr><td><strong>[RES001]</strong> Resources limiting</td><td><a href="https://github.com/OWASP/API-Security/blob/master/2019/en/src/0xa4-lack-of-resources-and-rate-limiting.md">API4 OWASP API Top 10</a></td><td><a href="https://cwe.mitre.org/data/definitions/770.html">CWE-770</a></td><td></td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.pynt.io/documentation/api-security-testing/pynt-security-tests-coverage/lack-of-resources-and-rate-limiting.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
