-1

I am trying to create vulnerability noSql injection with flask and mongo db. i'm tryin to create route for my app with query params and get stuck with array params. here is my code:

@app.route("/get_test", methods=["GET"])
def test():
    name = request.args.get("name")

and the route looks like this: http://localhost:3214/get_test?name["$ne"]=test while i excpected to get name = {'name':{"$ne":'test'}} actually i get name = None because the key now is "name['$ne']" can I build noSql injection like this on flask or it's only nodeJs and Php stuff?

i have try to use mongo-query-manager library, and it didn't help. also try: args = list(request.args.to_dict()) and didn't help

1 Answer 1

0

What you are trying to do is not possible in flask, by not possible i mean what you are sending in string parameter is not readable by flask. if you want to read name = {'name':{"$ne":'test'}} then send the dict as parameter and do json.loads(request.args.get("name")) to convert the string dict to python dict.

4
  • but the point is that I want to create a vulnerable app, and I can't send Json as a query param. why do I cant send an array as a parameter with Flask? i belive there is a way to send array params with flask
    – Dump Eldor
    Feb 7 at 8:01
  • i am not sure what you are trying to do, but if its sending array as a parameter then go for - example.com/xyz?name=['test', 'test2'] and so on, you can still use json.loads to convert it, but python would convert it to list on its own. Feb 7 at 8:05
  • I'm trying to get array parameters as MongoDB trying to get and name=['test', 'test2'] is not the right way for mongo
    – Dump Eldor
    Feb 7 at 8:12
  • Havent worked with mongo with flask, stackabuse.com/get-request-query-parameters-with-flask refer this and you might be able to achieve this with using multiple arguments and reading args as dict for your mongo query. Feb 7 at 8:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.