This is our team's final project for Web Security. This code creates a web login portal using MongoDB that is vulnerable to NoSQL injection. Then, we patch the vulnerability using Natural Language Processing techniques to train and classify potentially malicious inputs.
- I've sent out invitations to your jhu emails, so you should have access to the cloud MongoDB database. Lmk if you have not received it or are having issues using it.
- Follow https://www.mongodb.com/docs/drivers/node/current/quick-start/ to create your own cloud database and change const uri (line 16 in index.js) to your connection string
- Set up mongodb locally and modify index.js accordingly
In terminal, go into the server folder
Make sure you have installed dependencies:
- npm install mongodb@4.12
- npm install express --save
- npm install --save body-parser multer
Then do node index.js and go to http://localhost:3000/
URLs:
- Homepage, not important, you can submit something and go to MongoDB > Database > Find Collections > Look for a collection called "testing.test_data", check if your input is there
- print entries in side the collection called "testing.users", you can check username and password. You can add entries using the database website
- Login page
- Note that the inputs get converted to string so the injection does not work well here.
- However, we can use REST APIs (I use Postman https://www.postman.com/) to send JSON directly to make the injection work. E.g.
{
"username": "aa",
"password": { "$ne": null }
}