Skip to content

Commit ddb0c68

Browse files
committed
fix: added NoSQL scenario example
1 parent b056d8e commit ddb0c68

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,30 @@ 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 MEAN stack application with basic CRUD functionality for operations with
66+
bookings. Attacker managed to identify that NoSQL injection might be possible
67+
through `bookingId` query string parameter in delete booking request.
68+
Request looks like:
69+
`DELETE /bookings?bookingId=678`
70+
71+
On server side, application uses the following function to handle a request:
72+
73+
```
74+
router.delete('/bookings', async function (req, res, next) {
75+
try {
76+
const deletedBooking = await Bookings.findOneAndRemove({'_id' : req.query.bookingId});
77+
res.status(200);
78+
} catch (err) {
79+
res.status(400).json({error: 'Unexpected error occured while processing a request'});
80+
};
81+
```
82+
83+
Attacker intercepted the request and changed bookingId query string parameter as below:
84+
`DELETE /bookings?bookingId[$ne]=678`
85+
As a result, an attacker managed to delete another user booking.
86+
6387
## How To Prevent
6488
6589
Preventing injection requires keeping data separate from commands and queries.

0 commit comments

Comments
 (0)