Skip to content

Commit 0bf4b62

Browse files
committed
fix(2023): Proofreading
1 parent 36a2e23 commit 0bf4b62

9 files changed

+122
-63
lines changed

2023/en/src/0xa1-broken-object-level-authorization.md

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@ disclosure, modification, or destruction of all data.
2222

2323
Comparing the user ID of the current session (e.g. by extracting it from the
2424
JWT token) with the vulnerable ID parameter isn't a sufficient solution to
25-
solve BOLA. This approach could address only a small subset of cases.
25+
solve Broken Object Level Authorization (BOLA). This approach could address
26+
only a small subset of cases.
2627

2728
In the case of BOLA, it's by design that the user will have access to the
2829
vulnerable API endpoint/function. The violation happens at the object level,
2930
by manipulating the ID. If an attacker manages to access an API
30-
endpoint/function they should not have access to - this is a case of BFLA
31-
rather than BOLA.
31+
endpoint/function they should not have access to - this is a case of [Broken
32+
Function Level Authorization][5] (BFLA) rather than BOLA.
3233

3334
## Example Attack Scenarios
3435

@@ -37,7 +38,7 @@ rather than BOLA.
3738
An e-commerce platform for online stores (shops) provides a listing page with
3839
the revenue charts for their hosted shops. Inspecting the browser requests, an
3940
attacker can identify the API endpoints used as a data source for those charts
40-
and their pattern `/shops/{shopName}/revenue_data.json`. Using another API
41+
and their pattern: `/shops/{shopName}/revenue_data.json`. Using another API
4142
endpoint, the attacker can get the list of all hosted shop names. With a
4243
simple script to manipulate the names in the list, replacing `{shopName}` in
4344
the URL, the attacker gains access to the sales data of thousands of e-commerce
@@ -52,7 +53,7 @@ As part of this flow, the user sends the Vehicle Identification Number (VIN) to
5253
the API.
5354
The API fails to validate that the VIN represents a vehicle that belongs to the
5455
logged in user, which leads to a BOLA vulnerability. An attacker can access
55-
vehicles that don't belong to them.
56+
vehicles that don't belong to him.
5657

5758
### Scenario #3
5859

@@ -75,8 +76,8 @@ POST /graphql
7576
}
7677
```
7778

78-
Since a document ID is deleted without any further permission checks, a user
79-
may be able to delete another user's document.
79+
Since the document with the given ID is deleted without any further permission
80+
checks, a user may be able to delete another user's document.
8081

8182
## How To Prevent
8283

@@ -89,7 +90,6 @@ may be able to delete another user's document.
8990
* Write tests to evaluate the vulnerability of the authorization mechanism. Do
9091
not deploy changes that make the tests fail.
9192

92-
9393
## References
9494

9595
### OWASP
@@ -106,3 +106,4 @@ may be able to delete another user's document.
106106
[2]: https://cheatsheetseries.owasp.org/cheatsheets/Authorization_Testing_Automation_Cheat_Sheet.html
107107
[3]: https://cwe.mitre.org/data/definitions/285.html
108108
[4]: https://cwe.mitre.org/data/definitions/639.html
109+
[5]: ./0xa5-broken-function-level-authorization.md

2023/en/src/0xa2-broken-authentication.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ API2:2023 Broken Authentication
88

99
## Is the API Vulnerable?
1010

11-
Authentication endpoints and flows are assets that need to be protected. Additionally, "Forgot password / reset password" should be treated the same way
11+
Authentication endpoints and flows are assets that need to be protected.
12+
Additionally, "Forgot password / reset password" should be treated the same way
1213
as authentication mechanisms.
1314

1415
An API is vulnerable if it:
@@ -82,11 +83,11 @@ Authorization: Bearer <token>
8283
{ "email": "<new_email_address>" }
8384
```
8485

85-
Because the API does not require the user to confirm their identity by
86-
providing their current password, bad actors are able to put themselves in a
87-
position to steal the auth token.They also might be able to take over the
88-
victim's account by starting the reset password workflow after updating the
89-
email address of the victim's account.
86+
Because the API does not require users to confirm their identity by providing
87+
their current password, bad actors able to put themselves in a position to
88+
steal the auth token might be able to take over the victim's account by starting
89+
the reset password workflow after updating the email address of the victim's
90+
account.
9091

9192
## How To Prevent
9293

2023/en/src/0xa3-broken-object-property-level-authorization.md

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,48 +65,61 @@ As part of this flow, an API call is sent by the host to
6565
`POST /api/host/approve_booking` with the following legitimate payload:
6666

6767
```
68-
{"approved":true,"comment":"Check-in is after 3pm"}
68+
{
69+
"approved": true,
70+
"comment": "Check-in is after 3pm"
71+
}
6972
```
7073

7174
The host replays the legitimate request, and adds the following malicious
7275
payload:
7376

7477
```
75-
{"approved":true,"comment":"Check-in is after 3pm","total_stay_price":"$1,000,000"}
78+
{
79+
"approved": true,
80+
"comment": "Check-in is after 3pm",
81+
"total_stay_price": "$1,000,000"
82+
}
7683
```
7784

7885
The API endpoint is vulnerable because there is no validation that the host
79-
should have access to the internal object property - "total_stay_price", and
86+
should have access to the internal object property - `total_stay_price`, and
8087
the guest will be charged more than she was supposed to be.
8188

8289
### Scenario #3
8390

8491
A social network that is based on short videos, enforces restrictive content
8592
filtering and censorship. Even if an uploaded video is blocked, the user can
86-
change the description of the video using the following API request
93+
change the description of the video using the following API request:
8794

8895
```
8996
PUT /api/video/update_video
9097
91-
{"description":"a funny video about cats"}
98+
{
99+
"description": "a funny video about cats"
100+
}
92101
```
93102

94103
A frustrated user can replay the legitimate request, and add the following
95104
malicious payload:
96105

97106
```
98-
{"description":"a funny video about cats","blocked":false}
107+
{
108+
"description": "a funny video about cats",
109+
"blocked": false
110+
}
99111
```
100112

101113
The API endpoint is vulnerable because there is no validation if the user
102-
should have access to the internal object property - "blocked", and the user
103-
can change the value from "true" to "false" and unlock their own blocked content.
114+
should have access to the internal object property - `blocked`, and the user
115+
can change the value from `true` to `false` and unlock their own blocked
116+
content.
104117

105118
## How To Prevent
106119

107120
* When exposing an object using an API endpoint, always make sure that the user
108121
should have access to the object's properties you expose.
109-
* Avoid using generic methods such as to_json() and to_string(). Instead,
122+
* Avoid using generic methods such as `to_json()` and `to_string()`. Instead,
110123
cherry-pick specific object properties you specifically want to return.
111124
* If possible, avoid using functions that automatically bind a client's input
112125
into code variables, internal objects, or object properties

2023/en/src/0xa4-unrestricted-resource-consumption.md

Lines changed: 57 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,45 +30,84 @@ inappropriately (e.g. too low/high):
3030

3131
### Scenario #1
3232

33-
An attacker uploads a large image by issuing a POST request to /api/v1/images.
34-
When the upload is complete, the API creates multiple thumbnails with different
35-
sizes. Due to the size of the uploaded image, available memory is exhausted
36-
during the creation of thumbnails and the API becomes unresponsive.
33+
A social network implemented a “forgot password” flow using SMS verification,
34+
enabling the user to receive a one time token via SMS in order to reset their
35+
password.
36+
37+
Once a user clicks on "forgot password" an API call is sent from the user's
38+
browser to the back-end API:
39+
40+
```
41+
POST /initiate_forgot_password
42+
43+
{
44+
"step": 1,
45+
"user_number": "6501113434"
46+
}
47+
```
48+
49+
Then, behind the scenes, an API call is sent from the back-end to a 3rd party
50+
API that takes care of the SMS delivering:
51+
52+
```
53+
POST /sms/send_reset_pass_code
54+
55+
Host: willyo.net
56+
57+
{
58+
"phone_number": "6501113434"
59+
}
60+
```
61+
62+
The 3rd party provider, Willyo, charges $0.05 per this type of call.
63+
64+
An attacker writes a script that sends the first API call tens of thousands of
65+
times. The back-end follows and requests Willyo to send tens of thousands of
66+
text messages, leading the company to lose thousands of dollars in a matter of
67+
minutes.
3768

3869
### Scenario #2
3970

40-
In order to activate a credit card the following API request should be issued
41-
providing the last four digits printed on it (only users with physical access
42-
to the card should be able to perform such operation):
71+
A GraphQL API Endpoint allows the user to upload a profile picture.
4372

4473
```
4574
POST /graphql
4675
4776
{
4877
"query": "mutation {
49-
validateOTP(token: \"abcdef\", card: \"123456\") {
50-
authToken
78+
uploadPic(name: \"pic1\", base64_pic: \"R0FOIEFOR0xJVA…\") {
79+
url
5180
}
5281
}"
5382
}
5483
```
5584

56-
Bad actors will be able to perform the credit card activation without physical
57-
access to it, crafting a request like the one below:
85+
Once the upload is complete, the API generates multiple thumbnails with
86+
different sizes based on the uploaded picture. This graphical operation takes a
87+
lot of memory from the server.
88+
89+
The API implements a traditional rate limiting protection - a user can't access
90+
the GraphQL endpoint too many times in a short period of time. The API also
91+
checks for the uploaded picture's size before generating thumbnails to avoid
92+
processing pictures that are too large.
93+
94+
An attacker can easily bypass those mechanisms, by leveraging the flexible
95+
nature of GraphQL:
5896

5997
```
6098
POST /graphql
6199
62100
[
63-
{"query": "mutation {activateCard(token: \"abcdef\", card: \"0000\") {authToken}}"},
64-
{"query": "mutation {activateCard(token: \"abcdef\", card: \"0001\") {authToken}}"},
101+
{"query": "mutation {uploadPic(name: \"pic1\", base64_pic: \"R0FOIEFOR0xJVA…\") {url}}"},
102+
{"query": "mutation {uploadPic(name: \"pic2\", base64_pic: \"R0FOIEFOR0xJVA…\") {url}}"},
65103
...
66-
{"query": "mutation {activateCard(token: \"abcdef\", card: \"9999\") {authToken}}"}
104+
{"query": "mutation {uploadPic(name: \"pic999\", base64_pic: \"R0FOIEFOR0xJVA…\") {url}}"},
67105
}
68106
```
69107

70-
Because the API does not limit the number of times the activateCard operation
71-
can be attempted, one of the mutations will succeed.
108+
Because the API does not limit the number of times the `uploadPic` operation can
109+
be attempted, the call will lead to exhaustion of server memory and Denial of
110+
Service.
72111

73112
### Scenario #3
74113

@@ -86,7 +125,8 @@ the next monthly bill increases from US$13, on average, to US$8k.
86125
## How To Prevent
87126

88127
* Use a solution that makes it easy to limit [memory][1],
89-
[CPU][2], [number of restarts][3], [file descriptors, and processes][4] such as Containers / Serverless code (e.g. Lambdas).
128+
[CPU][2], [number of restarts][3], [file descriptors, and processes][4] such
129+
as Containers / Serverless code (e.g. Lambdas).
90130
* Define and enforce a maximum size of data on all incoming parameters and
91131
payloads, such as maximum length for strings, maximum number of elements in
92132
arrays, and maximum upload file size (regardless of whether it is stored

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ Don't assume that an API endpoint is regular or administrative only based on
2525
the URL path.
2626

2727
While developers might choose to expose most of the administrative endpoints
28-
under a specific relative path, like `/api/admins`, it's very common to find these
29-
administrative endpoints under other relative paths together with regular
28+
under a specific relative path, like `/api/admins`, it's very common to find
29+
these administrative endpoints under other relative paths together with regular
3030
endpoints, like `/api/users`.
3131

3232
## Example Attack Scenarios
@@ -48,7 +48,10 @@ The attacker exploits the issue and sends a new invite with admin privileges:
4848
```
4949
POST /api/invites/new
5050
51-
{"email":"attacker@somehost.com","role":"admin"}
51+
{
52+
"email": "attacker@somehost.com",
53+
"role":"admin"
54+
}
5255
```
5356

5457
Later on, the attacker uses the maliciously crafted invite in order to create
@@ -70,7 +73,6 @@ module that is invoked from all your business functions. Frequently, such
7073
protection is provided by one or more components external to the application
7174
code.
7275

73-
7476
* The enforcement mechanism(s) should deny all access by default, requiring
7577
explicit grants to specific roles for access to every function.
7678
* Review your API endpoints against function level authorization flaws, while

2023/en/src/0xa7-server-side-request-forgery.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ API7:2023 Server Side Request Forgery
88

99
## Is the API Vulnerable?
1010

11-
Server-Side Request Forgery (SSRF) flaws occur whenever an API is fetching a
12-
remote resource without validating the user-supplied URL. It allows an attacker
13-
to coerce the application to send a crafted request to an unexpected
14-
destination, even when protected by a firewall or a VPN.
11+
Server-Side Request Forgery (SSRF) flaws occur when an API is fetching a remote
12+
resource without validating the user-supplied URL. It enables an attacker to
13+
coerce the application to send a crafted request to an unexpected destination,
14+
even when protected by a firewall or a VPN.
1515

1616
Modern concepts in application development make SSRF more common and more
1717
dangerous.
@@ -24,7 +24,6 @@ More dangerous - Modern technologies like cloud providers, Kubernetes, and
2424
Docker expose management and control channels over HTTP on predictable,
2525
well-known paths. Those channels are an easy target for an SSRF attack.
2626

27-
2827
It is also more challenging to limit outbound traffic from your application,
2928
because of the connected nature of modern applications.
3029

@@ -42,14 +41,18 @@ image. Choosing the second, will trigger the following API call:
4241
```
4342
POST /api/profile/upload_picture
4443
45-
{"picture_url":"http://example.com/profile_pic.jpg"}
44+
{
45+
"picture_url": "http://example.com/profile_pic.jpg"
46+
}
4647
```
4748

4849
An attacker can send a malicious URL and initiate port scanning within the
4950
internal network using the API Endpoint.
5051

5152
```
52-
{"picture_url":"localhost:8080"}
53+
{
54+
"picture_url": "localhost:8080"
55+
}
5356
```
5457

5558
Based on the response time, the attacker can figure out whether the port is
@@ -91,7 +94,7 @@ POST /graphql
9194
9295
```
9396

94-
During the creation process, the API backend sends a test request to the
97+
During the creation process, the API back-end sends a test request to the
9598
provided webhook URL, and presents to the user the response.
9699

97100
An attacker can leverage this flow, and make the API request a sensitive
@@ -129,7 +132,7 @@ can view the credentials of the cloud environment.
129132

130133
* Isolate the resource fetching mechanism in your network: usually these
131134
features are aimed to retrieve remote resources and not internal ones.
132-
* Whenever possible, use allow lists of
135+
* Whenever possible, use allow lists of:
133136
* Remote origins users are expected to download resources from (e.g. Google
134137
Drive, Gravatar, etc.)
135138
* URL schemes and ports

2023/en/src/0xa8-security-misconfiguration.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@ not required):
5656
GET /dm/user_updates.json?conversation_id=1234567&cursor=GRlFp7LCUAAAA
5757
```
5858

59-
Because the API response does not include the Cache-Control HTTP response
59+
Because the API response does not include the `Cache-Control` HTTP response
6060
header, private conversations end-up cached by the web browser, allowing
6161
malicious actors to retrieve them from the browser cache files in the
6262
filesystem.
6363

6464
## How To Prevent
6565

66-
The API life cycle should include
66+
The API life cycle should include:
6767

6868
* A repeatable hardening process leading to fast and easy deployment of a
6969
properly locked down environment
@@ -86,8 +86,6 @@ Furthermore:
8686
* include applicable Security Headers
8787
* Restrict incoming content types/data formats to those that meet the business/
8888
functional requirements.
89-
* Implement a proper Cross-Origin Resource Sharing (CORS) policy on APIs
90-
expected to be accessed from browser-based clients (e.g. web app front-ends).
9189
* Ensure all servers in the HTTP server chain (e.g. load balancers, reverse
9290
and forward proxies, and back-end servers) process incoming requests in a
9391
uniform manner to avoid desync issues.

2023/en/src/0xa9-improper-inventory-management.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,3 @@ sells the information for malicious purposes.
104104
* [CWE-1059: Incomplete Documentation][1]
105105

106106
[1]: https://cwe.mitre.org/data/definitions/1059.html
107-

0 commit comments

Comments
 (0)