secDevLabs
secDevLabs copied to clipboard
[A3] - Injection - Mongection
This solution refers to which of the apps?
A3 - Mongection
What did you do to mitigate the vulnerability?
I sanitized the user entries for the database with the mongo-sanitize library.
Did you test your changes? What commands did you run?
- User created
$ curl -X POST http://localhost:10001/register -H "Content-Type: application/json" --data '{"name":"bob", "email":"[email protected]", "password":"bobisboss"}'
<h1>Welcome to Mongection System</h1><h3>[email protected]</h3>%
- User log-in
$ curl -X POST http://localhost:10001/login -H "Content-Type: application/json" --data '{"email":"[email protected]", "password":"bobisboss"}'
<h1>Hello, Welcome Again!</h1><h3>[email protected]</h3>%
- Payload 1
$ curl -X 'POST' 'http://localhost:10001/login' -H "Content-Type: application/json" --data '{"email": {"$ne":""}, "password": {"$ne":""}}'
curl: (52) Empty reply from server
- Payload 2
$ curl -X 'POST' 'http://localhost:10001/login' -H "Content-Type: application/json" --data '{"email": {"$gt": ""}, "password": {"$gt": ""}}'
curl: (52) Empty reply from server
- Payload 3
$ curl -X 'POST' 'http://localhost:10001/login' -H "Content-Type: application/json" --data '{"email": {"$in":["[email protected]", "root@example", "[email protected]", "bob"]}, "password": {"$gt":""}}'
curl: (52) Empty reply from server
This pull request fixes 1 alert when merging 06f01e25d087f3c756ec1367e45b4ef6bf7e402c into 6e036c0860098d7b705ef56eb3a944e94471ef77 - view on LGTM.com
fixed alerts:
- 1 for Database query built from user-controlled sources
You hacked the hack @ragoso congratz! After you change I can't reproduce the vulnerability. 🚀