Skip to content

Commit 2139e20

Browse files
committed
Merge branch 'pr-13' into develop
2 parents fcca22f + fbfac1d commit 2139e20

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,34 @@ 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+
Attacker intercepted the request and changed `bookingId` query string parameter
83+
as below:
84+
85+
```
86+
DELETE /api/bookings?bookingId[$ne]=678
87+
```
88+
89+
As a result, the attacker managed to delete another user booking.
90+
6391
## How To Prevent
6492

6593
Preventing injection requires keeping data separate from commands and queries.

0 commit comments

Comments
 (0)