File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
python/ql/test/query-tests/Security/CWE-943-NoSqlInjection/PoC Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change 1
1
flask
2
- pymongo
2
+ pymongo == 3.9
Original file line number Diff line number Diff line change @@ -90,6 +90,21 @@ def by_group():
90
90
post = posts .aggregate ([{ "$group" : group }]).next () # $ result=BAD
91
91
return show_post (post , author )
92
92
93
+ # works with pymongo 3.9, `map_reduce` is removed in pymongo 4.0
94
+ @app .route ('/byMapReduce' , methods = ['GET' ])
95
+ def by_map_reduce ():
96
+ author = request .args ['author' ]
97
+ mapper = 'function() { emit(this.author, this.author === "' + author + '") }'
98
+ reducer = "function(key, values) { return values.some( x => x ) }"
99
+ results = posts .map_reduce (mapper , reducer , "results" )
100
+ # Use `" | "a" === "a` as author
101
+ # making the query `this.author === "" | "a" === "a"`
102
+ # Found by http://127.0.0.1:5000/byMapReduce?author=%22%20|%20%22a%22%20===%20%22a
103
+ post = results .find_one ({'value' : True }) # $ MISSING: result=BAD
104
+ if (post ):
105
+ post ["author" ] = post ["_id" ]
106
+ return show_post (post , author )
107
+
93
108
@app .route ('/' , methods = ['GET' ])
94
109
def show_routes ():
95
110
links = []
You can’t perform that action at this time.
0 commit comments