File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -60,6 +60,34 @@ vulnerable firmware:
60
60
$ curl -k "https://${deviceIP}:4567/api/CONFIG/restore" -F 'appid=$(/etc/pod/power_down.sh)'
61
61
```
62
62
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
+
63
91
## How To Prevent
64
92
65
93
Preventing injection requires keeping data separate from commands and queries.
You can’t perform that action at this time.
0 commit comments