Skip to content

Commit 2391697

Browse files
authored
Merge pull request #1 from PauloASilva/develop
Develop
2 parents e3da47a + a80f06d commit 2391697

File tree

5 files changed

+65
-17
lines changed

5 files changed

+65
-17
lines changed
822 Bytes
Binary file not shown.
15.4 KB
Binary file not shown.

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

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,13 @@ A3:2019 Excessive Data Exposure
44
| Threat agents/Attack vectors | Security Weakness | Impacts |
55
| - | - | - |
66
| API Specific : Exploitability **3** | Prevalence **2** : Detectability **2** | Technical **2** : Business Specific |
7-
| Exploitation of excessive data exposure is simple, and is usually done by using different clients while sniffing the traffic they produce to analyze the API responses and look for sensitive data exposure that should not be returned to the user. | APIs rely on clients to perform the data filtering. Since APIs are used as data sources, sometimes developers try to implement them in a generic way without thinking about the sensitivity of the exposed data. Automatic tools usually can’t detect this type of vulnerability because it’s hard to differentiate between legitimate data returned from the API and sensitive data that should not be returned without a deep understanding of the application. | Excessive Data Exposure commonly leads to exposure of sensitive data. |
7+
| Exploitation of Excessive Data Exposure is simple, and is usually done by sniffing the traffic to analyze the API responses looking for sensitive data exposure that should not be returned to the user. | APIs rely on clients to perform the data filtering. Since APIs are used as data sources, sometimes developers try to implement them in a generic way without thinking about the sensitivity of the exposed data. Automatic tools usually can’t detect this type of vulnerability because it’s hard to differentiate between legitimate data returned from the API and sensitive data that should not be returned without a deep understanding of the application. | Excessive Data Exposure commonly leads to exposure of sensitive data. |
88

99
## Is the API Vulnerable?
1010

11-
There are two types of Excessive Data Exposure:
12-
13-
* **Client Side Data Filtering**: The API returns sensitive data to the client
14-
by design. This data is usually filtered on the client side before being
15-
presented to the user. An attacker can easily sniff the traffic and see the
16-
sensitive data.
17-
* **Filter Manipulation**: the API performs data filtering in an unsafe manner
18-
based on filters from the client. An attacker can send malicious filters
19-
causing the API to return sensitive data they should not be exposed to.
11+
The API returns sensitive data to the client by design. This data is usually
12+
filtered on the client side before being presented to the user. An attacker can
13+
easily sniff the traffic and see the sensitive data.
2014

2115
## Example Attack Scenarios
2216

@@ -31,22 +25,31 @@ object.
3125

3226
### Scenario #2
3327

34-
An open source team chat solution provides the endpoint `/api/v1/users.list`
35-
which supports two parameters: `query` and `fields`. Using a regular user
36-
account and manipulating both parameters an attacker can enumerate admin
37-
accounts, exposing sensitive information such as the password reset token:
38-
`GET /api/v1/users.list?query={“roles”:{$in:“admin”}}&fields={“services.password.reset”:1, “username”:1”, “email.0”:1}`.
39-
Via password reset, the attacker can takeover one of the admin accounts.
28+
An IOT-based surveillance system allows administrators to create users with
29+
different permissions.
30+
An admin created a user for a new security guard that should have access only to
31+
specific buildings in the site.
32+
Once the security guard uses his mobile app, an API call is triggered to:
33+
`"/api/sites/111/cameras"` in order to receive data about the available cameras
34+
and show them on the dashboard.
35+
The response contains a list with details about cameras in the following format:
36+
`{"id":"xxx","live_access_token":"xxxx-bbbbb","building_id":"yyy"}`
37+
While the client GUI shows only cameras which the security guard should have
38+
access to, the actual API response contains a full list of all the cameras in
39+
the site.
4040

4141
## How To Prevent
4242

4343
* Never rely on the client side to perform sensitive data filtering.
4444
* Review the responses from the API to make sure they contain only legitimate
4545
data.
46-
* Be careful when performing data filtering based on filters from the client.
4746

4847
## References
4948

5049
### OWASP
5150

5251
### External
52+
53+
* [CWE-213: Intentional Information Exposure][1]
54+
55+
[1]: https://cwe.mitre.org/data/definitions/213.html

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ following limits is missing or set inappropriately (i.e. too low/high)
2020
* Number of processes
2121
* Request payload size (e.g. uploads)
2222
* Number of requests per client/resource
23+
* Number of records per page to return in a single request response
2324

2425
## Example Attack Scenarios
2526

@@ -40,6 +41,18 @@ combinations using a multi-thread script, against the
4041
`/api/system/verification-codes/{smsToken}` endpoint to discover the right token
4142
within a few minutes.
4243

44+
### Scenario #3
45+
46+
We have an application that contains the users' list on a UI with a limit of
47+
`200` users per page. The users' list is retrieved from the server using the
48+
following query: `/api/users?page=1&size=100`. An attacker changes the `size`
49+
parameter to `200 000`, causing performance issues on the database. Meanwhile,
50+
the API becomes unresponsive and unable to handle further requests from this or
51+
any other clients (aka DoS).
52+
53+
The same scenario might be used to provoke Integer Overflow or Buffer Overflow
54+
errors.
55+
4356
## How To Prevent
4457

4558
* Docker makes it easy to limit [memory][1], [CPU][2], [number of restarts][3],
@@ -48,6 +61,9 @@ within a few minutes.
4861
timeframe.
4962
* Notify the client when the limit is exceeded by providing the limit number and
5063
the time at which the limit will be reset.
64+
* Add proper server side validation for query string and request body
65+
parameters, specifically the one that control the number of records to be
66+
returned in the response.
5167

5268
## References
5369

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,33 @@ vulnerable firmware:
6060
$ curl -k "https://${deviceIP}:4567/api/CONFIG/restore" -F 'appid=$(/etc/pod/power_down.sh)'
6161
```
6262
63+
### Scenario #3
64+
65+
We have an application with basic CRUD functionality for operations with
66+
bookings. An attacker managed to identify that NoSQL injection might be possible
67+
through `bookingId` query string parameter in the delete booking request. This
68+
is how the request looks like: `DELETE /api/bookings?bookingId=678`.
69+
70+
The API server uses the following function to handle delete requests:
71+
72+
```javascript
73+
router.delete('/bookings', async function (req, res, next) {
74+
try {
75+
const deletedBooking = await Bookings.findOneAndRemove({'_id' : req.query.bookingId});
76+
res.status(200);
77+
} catch (err) {
78+
res.status(400).json({error: 'Unexpected error occured while processing a request'});
79+
}
80+
});
81+
```
82+
83+
Attacker intercepted the request and changed `bookingId` query string parameter
84+
as below, the attacker managed to delete another user booking:
85+
86+
```
87+
DELETE /api/bookings?bookingId[$ne]=678
88+
```
89+
6390
## How To Prevent
6491

6592
Preventing injection requires keeping data separate from commands and queries.
@@ -73,6 +100,8 @@ Preventing injection requires keeping data separate from commands and queries.
73100
* Prefer a safe API which provides a parameterized interface.
74101
* Always limit the number of returned records to prevent mass disclosure in case
75102
of injection.
103+
* Validate incoming data using sufficient filters to only allow valid values for
104+
each input parameter.
76105

77106
## References
78107

0 commit comments

Comments
 (0)