NoSQL injection - java server

218 views Asked by At

I am trying to create a java servlet with a NoSQL injection vulnerability. I've connected the servlet with MongoDB and check if the login info submitted by the user exists, I'm doing the next query:

String andQuery = "{$and: [{user: \""+u+"\"}, {password: \""+p+"\"}]}";

Where u is the user and p is the password given by the user. For what I've seen this is correct, and the NoSQL injection should exist, bu I really dont kno how to prove it.

I've tried submitting with burp this:

username[$ne]=1&password[$ne]=1

But its not working, and when I check the content of u and p after I submitted that the content of both variables is null. I dont have the servlet configured to receive json objects so I need a solition that doesn't imply send a json object with burp.

PD: I tryed also to insert something like this:

{\"$gt\":\"\" }

in the user and password fields but the result query is

{"$and": [{"user": "{\"$gt\":\"\" }"}, {"password": "{\"$gt\":\"\" }"}]}

I guess this doesn't work because the {"$gt":"" } is in quotes, ¿how can I do the servlet to be vulnarable and with which input it would be vulnerabel?

0

There are 0 answers