File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
python/ql/test/query-tests/Security/CWE-943-NoSqlInjection/PoC Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,26 @@ def by_function_arg():
71
71
post = posts .find_one ({'$expr' : {'$function' : search }}) # $ result=OK
72
72
return show_post (post , author )
73
73
74
+ @app .route ('/byGroup' , methods = ['GET' ])
75
+ def by_group ():
76
+ author = request .args ['author' ]
77
+ accumulator = {
78
+ "init" : 'function() { return "Not found" }' ,
79
+ "accumulate" : 'function(state, author) { return (author === "' + author + '") ? author : state }' ,
80
+ "accumulateArgs" : ["$author" ],
81
+ "merge" : 'function(state1, state2) { return (state1 === "Not found") ? state2 : state1 }'
82
+ }
83
+ group = {
84
+ "_id" : "null" ,
85
+ "author" : { "$accumulator" : accumulator }
86
+ }
87
+ # Use `" | "a" === "a` as author
88
+ # making the query `this.author === "" | "a" === "a"`
89
+ # Found by http://127.0.0.1:5000/byGroup?author=%22%20|%20%22a%22%20===%20%22a
90
+ post = posts .aggregate ([{ "$group" : group }]).next () # $ MISSING: result=BAD
91
+ app .logger .error ("post" , post )
92
+ return show_post (post , author )
93
+
74
94
@app .route ('/' , methods = ['GET' ])
75
95
def show_routes ():
76
96
links = []
You can’t perform that action at this time.
0 commit comments