Skip to content

fix: added NoSQL scenario example #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 4, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions 2019/en/src/0xa8-injection.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,30 @@ vulnerable firmware:
$ curl -k "https://${deviceIP}:4567/api/CONFIG/restore" -F 'appid=$(/etc/pod/power_down.sh)'
```
### Scenario #3
We have MEAN stack application with basic CRUD functionality for operations with
bookings. Attacker managed to identify that NoSQL injection might be possible
through `bookingId` query string parameter in delete booking request.
Request looks like:
`DELETE /bookings?bookingId=678`
On server side, application uses the following function to handle a request:
```
router.delete('/bookings', async function (req, res, next) {
try {
const deletedBooking = await Bookings.findOneAndRemove({'_id' : req.query.bookingId});
res.status(200);
} catch (err) {
res.status(400).json({error: 'Unexpected error occured while processing a request'});
};
```
Attacker intercepted the request and changed bookingId query string parameter as below:
`DELETE /bookings?bookingId[$ne]=678`
As a result, an attacker managed to delete another user booking.
## How To Prevent
Preventing injection requires keeping data separate from commands and queries.
Expand Down