Skip to content

Commit 0d1b434

Browse files
committed
Merge branch 'section/improper-resources-limiting-throttling' into release/alpha
2 parents 452ac2e + 8206246 commit 0d1b434

File tree

3 files changed

+78
-37
lines changed

3 files changed

+78
-37
lines changed

2019/en/0x00-toc.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Table of Contents
1111
* [A1:2019 Broken Object Level Access Control](0xa1-broken-object-level-access-control.md)
1212
* [A2:2019 Broken Authentication](0xa2-broken-authentication.md)
1313
* [A3:2019 Improper Data Filtering](0xa3-improper-data-filtering.md)
14-
* [A4:2019 Improper Resources Limiting or Throttling](0xa4-improper-resources-limiting-throttling.md)
14+
* [A4:2019 Lack of Resources & Rate Limiting](0xa4-lack-of-resources-and-rate-limiting.md)
1515
* [A5:2019 Sensitive Data Exposure](0xa5-sensitive-data-exposure.md)
1616
* [A6:2019 Missing Function/Resource Level Access Control](0xa6-missing-function-resource-level-access-control.md)
1717
* [A7:2019 Security Misconfiguration](0xa7-security-misconfiguration.md)

2019/en/0xa4-improper-resources-limiting-throttling.md

Lines changed: 0 additions & 36 deletions
This file was deleted.
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
A4:2019 Lack of Resources & Rate Limiting
2+
=========================================
3+
4+
| Threat agents/Attack vectors | Security Weakness | Impacts |
5+
| - | - | - |
6+
| API Specific : Exploitability **2** | Prevalence **3** : Detectability **3** | Technical **2** : Business Specific |
7+
| Exploitation requires simple API requests. No authentication is required. Multiple concurrent requests can be performed from a single local computer or by using cloud computing resources. | It’s common to find APIs that do not implement rate limiting or APIs where limits are not properly set. | Exploitation may lead to DoS, making the API unresponsive or even unavailable. |
8+
9+
## Is the API Vulnerable?
10+
11+
API requests consume resources such as network, CPU, memory and storage and the
12+
amount of resources required to satisfy a request greatly depends on the user
13+
input and endpoint business logic. Also consider that requests from multiple API
14+
clients compete for resources. An API is vulnerable if at least one of the
15+
following limits is missing or set inappropriately (i.e. too low/high)
16+
17+
* Execution timeouts
18+
* Max allocable memory
19+
* Number of file descriptors
20+
* Number of processes
21+
* Request payload size (e.g. uploads)
22+
* Number of requests per client/resource
23+
24+
## Example Attack Scenarios
25+
26+
### Scenario #1
27+
28+
An attacker uploads a large image by issuing a POST request to `/api/v1/images`.
29+
When the upload is complete, the API creates multiple thumbnails with different
30+
sizes. Due to the size of the uploaded image, available memory is exhausted
31+
during the creation of thumbnails and the API becomes unresponsive.
32+
33+
### Scenario #2
34+
35+
An attacker starts the password recovery workflow by issuing a POST request to
36+
`/api/system/verification-codes` and by providing the username in the request
37+
body. Next an SMS token with 6 digits is sent to the victim’s phone. Because the
38+
API does not implement a rate limiting policy the attacker can test all possible
39+
combinations using a multi-thread script, against the
40+
`/api/system/verification-codes/{smsToken}` endpoint to discover the right token
41+
within a few minutes.
42+
43+
## How To Prevent
44+
45+
* Docker makes it easy to limit [memory][1], [CPU][2], [number of restarts][3],
46+
[file descriptors and processes][4].
47+
* Implement a limit on how often a client can call the API within a defined
48+
timeframe.
49+
* Notify the client when the limit is exceeded by providing the limit number and
50+
the time at which the limit will be reset.
51+
52+
## References
53+
54+
### OWASP
55+
56+
* [Blocking Brute Force Attacks][5]
57+
* [Docker Cheat Sheet - Limit resources (memory, CPU, file descriptors,
58+
processes, restarts)][6]
59+
* [REST Assessment Cheat Sheet][7]
60+
61+
### External
62+
63+
* [CWE-307: Improper Restriction of Excessive Authentication Attempts][8]
64+
* [CWE-770: Allocation of Resources Without Limits or Throttling][9]
65+
*_Rate Limiting (Throttling)_” - [Security Strategies for Microservices-based
66+
Application Systems][10], NIST
67+
68+
[1]: https://docs.docker.com/config/containers/resource_constraints/#memory
69+
[2]: https://docs.docker.com/config/containers/resource_constraints/#cpu
70+
[3]: https://docs.docker.com/engine/reference/commandline/run/#restart-policies---restart
71+
[4]: https://docs.docker.com/engine/reference/commandline/run/#set-ulimits-in-container---ulimit
72+
[5]: https://www.owasp.org/index.php/Blocking_Brute_Force_Attacks
73+
[6]: https://github.com/OWASP/CheatSheetSeries/blob/3a8134d792528a775142471b1cb14433b4fda3fb/cheatsheets/Docker_Security_Cheat_Sheet.md#rule-7---limit-resources-memory-cpu-file-descriptors-processes-restarts
74+
[7]: https://github.com/OWASP/CheatSheetSeries/blob/3a8134d792528a775142471b1cb14433b4fda3fb/cheatsheets/REST_Assessment_Cheat_Sheet.md
75+
[8]: https://cwe.mitre.org/data/definitions/307.html
76+
[9]: https://cwe.mitre.org/data/definitions/770.html
77+
[10]: https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-204-draft.pdf

0 commit comments

Comments
 (0)