Skip to content

Commit ae3a60c

Browse files
author
Dmitry Sotnikov
committed
Add various prevention tips
1 parent 93e8971 commit ae3a60c

9 files changed

+18
-5
lines changed

2019/en/src/0xa3-excessive-data-exposure.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ the site.
4242
* Never rely on the client side to perform sensitive data filtering.
4343
* Review the responses from the API to make sure they contain only legitimate
4444
data.
45+
* Explicitly define and enforce data returned by all API methods including errors: give all JSON objects schemas, all string objects patterns, use clear field names.
46+
* Define all sensitive and personally identifiable information (PII) that your application stores and works with and review all API calls returning such information to see if these responses can be a security issue.
4547

4648
## References
4749

2019/en/src/0xa4-lack-of-resources-and-rate-limiting.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,14 @@ errors.
4949
[file descriptors, and processes][4].
5050
* Implement a limit on how often a client can call the API within a defined
5151
timeframe.
52+
* For sensitive operations such as login or password reset, consider rate limits by API method (for example, authentication), client (for example, IP address), property (for example, username).
5253
* Notify the client when the limit is exceeded by providing the limit number and
5354
the time at which the limit will be reset.
5455
* Add proper server-side validation for query string and request body
5556
parameters, specifically the one that controls the number of records to be
5657
returned in the response.
58+
* Define and enforce maximum size of data on all incoming parameters and payloads such as maximum length for strings and maximum number of elements in arrays.
59+
* If your API accepts zip files check compression ratios before expanding the files to protect yourself against "zip bombs".
5760

5861
## References
5962

2019/en/src/0xa5-broken-function-level-authorization.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ A5:2019 Broken Function Level Authorization
44
| Threat agents/Attack vectors | Security Weakness | Impacts |
55
| - | - | - |
66
| API Specific : Exploitability **3** | Prevalence **2** : Detectability **1** | Technical **2** : Business Specific |
7-
| Exploitation requires the attacker to send legitimate API calls to the API endpoint that they should not have access to. These endpoints might be exposed to anonymous users or regular, non-privileged users. It’s easier to discover these flaws in APIs since APIs are more structured, and the way to access certain functions is more predictable (e.g., replacing the HTTP method from GET to PUT, or changing the “users” string in the URL to "admins"). | Authorization checks for a function or resource are usually managed via configuration, and sometimes at the code level. Implementing proper checks can be a confusing task, since modern applications can contain many types of roles or groups and complex user hierarchy (e.g., sub-users, users with more than one role). | Such flaws allow attackers to access unauthorized functionality. Administrative functions are key targets for this type of attack. |
7+
| Exploitation requires the attacker to send legitimate API calls to the API endpoint that they should not have access to. These endpoints might be exposed to anonymous users or regular, non-privileged users. It’s easier to discover these flaws in APIs since APIs are more structured, and the way to access certain functions is more predictable (e.g., replacing the HTTP method from GET to PUT, or changing the “users” string in the URL to "admins", or changing the value of a parameter like "is_admin" from "false" to "true"). | Authorization checks for a function or resource are usually managed via configuration, and sometimes at the code level. Implementing proper checks can be a confusing task, since modern applications can contain many types of roles or groups and complex user hierarchy (e.g., sub-users, users with more than one role). | Such flaws allow attackers to access unauthorized functionality. Administrative functions are key targets for this type of attack. |
88

99
## Is the API Vulnerable?
1010

2019/en/src/0xa6-mass-assignment.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ shell command injection once the attacker downloads the video as MP4.
7575
* Whitelist only the properties that should be updated by the client.
7676
* Use built-in features to blacklist properties that should not be accessed by
7777
clients.
78+
* In API contracts, explicitly define and enforce schemas for all JSON payloads.
7879

7980
## References
8081

2019/en/src/0xa7-security-misconfiguration.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ A7:2019 Security Misconfiguration
44
| Threat agents/Attack vectors | Security Weakness | Impacts |
55
| - | - | - |
66
| API Specific : Exploitability **3** | Prevalence **3** : Detectability **3** | Technical **2** : Business Specific |
7-
| Attackers will often attempt to find unpatched flaws, common endpoints, or unprotected files and directories to gain unauthorized access or knowledge of the system. | Security misconfiguration can happen at any level of the API stack, from the network level to the application level. Automated tools are available to detect and exploit misconfigurations such as unnecessary services or legacy options. | Security misconfigurations can no only expose sensitive user data, but also system details that may lead to full server compromise. |
7+
| Attackers will often attempt to find unpatched flaws, common endpoints, or unprotected files and directories to gain unauthorized access or knowledge of the system. | Security misconfiguration can happen at any level of the API stack, from the network level to the application level. Automated tools are available to detect and exploit misconfigurations such as unnecessary services or legacy options. | Security misconfigurations can not only expose sensitive user data, but also system details that may lead to full server compromise. |
88

99
## Is the API Vulnerable?
1010

@@ -65,6 +65,7 @@ The API life cycle should include:
6565
assets (e.g., images).
6666
* An automated process to continuously assess the effectiveness of the
6767
configuration and settings in all environments.
68+
* To prevent exception traces and other valuable information from being sent back to attackers, define and enforce all API response payload schemas including error responses.
6869

6970
## References
7071

2019/en/src/0xa8-injection.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ The attacker replays the request with a different payload
3333

3434
```
3535
POST /api/account/recovery
36-
{"email": "[email protected]';WAITFOR DELAY '0:0:5'--"}
36+
{"username": "[email protected]';WAITFOR DELAY '0:0:5'--"}
3737
```
3838

3939
This time, the response took ~5 seconds confirming the API is vulnerable to SQL
@@ -103,6 +103,8 @@ Preventing injection requires keeping data separate from commands and queries.
103103
of injection.
104104
* Validate incoming data using sufficient filters to only allow valid values for
105105
each input parameter.
106+
* To prevent data leaks, define and enforce schemas for all API responses.
107+
* Define data types and strict patterns for all string parameters.
106108

107109
## References
108110

2019/en/src/0xa9-improper-assets-management.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ user by using a simple brute-force to guess the 6 digits token.
6161
* Generate documentation automatically by adopting open standards. Include the
6262
documentation build in your CI/CD pipeline.
6363
* Make API documentation available to those authorized to use the API.
64+
* Use external protection measures such as API security firewalls for all exposed versions of your APIs, not just for the current production version.
65+
* Avoid using production data with non-production API deployments. If this is unavoidable, these endpoints should get the same security treatment as the production ones.
66+
* When newer versions of APIs include security improvements, perform risk analysis to make the decision of the mitigation actions required for the older version: for example, whether it is possible to backport the improvements without breaking API compatibility or you need to take the older version out quickly and force all clients to move to the latest version.
6467

6568
## References
6669

2019/en/src/0xb0-next-devs.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ comprehensive list of available projects.
1515

1616
| | |
1717
|-|-|
18-
| **Education** | You can start reading [OWASP Education Project materials][2] according to your profession and interest. For hands-on learning, we added **crAPI** - **C**ompletely **R**idiculous **API** on [our roadmap][3]. Meanwhile, you can practice WebAppSec using the [OWASP DevSlop Pixi Module][4], a vulnerable WebApp and API service intent to teach users how to test modern web applications and API's for security issues, and how to write more secure API's in the future. You can also attend [OWASP AppSec Conference][5] training sessions, or [join your local chapter][6]. |
18+
| **Education** | You can start reading [OWASP Education Project materials][2] according to your profession and interest. For hands-on learning, we added **crAPI** - **C**ompletely **R**idiculous **API** on [our roadmap][3]. Meanwhile, you can practice WebAppSec using the [OWASP DevSlop Pixi Module][4], a vulnerable WebApp and API service intent to teach users how to test modern web applications and API's for security issues, and how to write more secure API's in the future. You can also attend [OWASP AppSec Conference][5] training sessions, or [join your local chapter][6]. Read about the latest API vulnerabilities and breaches at [APIsecurity.io][15]|
1919
| **Security Requirements** | Security should be part of every project from the beginning. When doing requirements elicitation, it is important to define what "secure" means for that project. OWASP recommends you use the [OWASP Application Security Verification Standard (ASVS)][7] as a guide for setting the security requirements. If you're outsourcing, consider the [OWASP Secure Software Contract Annex][8], which should be adapted according to local law and regulations. |
2020
| **Security Architecture** | Security should remain a concern during all the project stages. The [OWASP Prevention Cheat Sheets][9] are a good starting point for guidance on how to design security in during the architecture phase. Among many others, you'll find the [REST Security Cheat Sheet][10] and the [REST Assessment Cheat Sheet][11]. |
2121
| **Standard Security Controls** | Adopting Standard Security Controls reduces the risk of introducing security weaknesses while writing your own logic. Despite the fact that many modern frameworks now come with built-in standard effective controls, [OWASP Proactive Controls][12] gives you a good overview of what security controls you should look to include in your project. OWASP also provides some libraries and tools you may find valuable, such as validation controls. |
@@ -35,3 +35,4 @@ comprehensive list of available projects.
3535
[12]: https://www.owasp.org/index.php/OWASP_Proactive_Controls#tab=OWASP_Proactive_Controls_2018
3636
[13]: https://www.owasp.org/index.php/OWASP_SAMM_Project
3737
[14]: https://www.owasp.org/index.php/Category:OWASP_Code_Review_Project
38+
[15]: https://APIsecurity.io

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ follow the steps below:
2424
1. Fork this repository to your account
2525
2. Clone your copy of this repository, locally
2626
```
27-
git clone git@github.com:YOU/API-Security-Top-10.git
27+
git clone https://github.com/YOU/API-Security.git
2828
```
2929
3. Create a new branch based on `develop` (e.g. `fix/foreword-section`)
3030
```

0 commit comments

Comments
 (0)