secDevLabs icon indicating copy to clipboard operation
secDevLabs copied to clipboard

[A3] - Injection - Mongection

Open ragoso opened this issue 3 years ago • 1 comments

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?

  1. 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>%
  1. 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>%  
  1. 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
  1. 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
  1. 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

ragoso avatar May 03 '22 18:05 ragoso

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

lgtm-com[bot] avatar May 03 '22 18:05 lgtm-com[bot]

You hacked the hack @ragoso congratz! After you change I can't reproduce the vulnerability. 🚀

fguisso avatar Nov 09 '22 14:11 fguisso