File tree 4 files changed +28
-4
lines changed
4 files changed +28
-4
lines changed Original file line number Diff line number Diff line change @@ -107,6 +107,8 @@ Patches and Contributions
107
107
- Mattias Lundberg
108
108
- Mayur Dhamanwala
109
109
- Mikael Berg
110
+ - Moritz Schneider
111
+ - Moritz Schneider
110
112
- Mugur Rus
111
113
- Nathan Reynolds
112
114
- Niall Donegan
Original file line number Diff line number Diff line change @@ -77,6 +77,15 @@ Breaking Changes
77
77
Stable
78
78
------
79
79
80
+ Version 0.7.5
81
+ ~~~~~~~~~~~~~
82
+
83
+ Released on 4 December, 2017
84
+
85
+ - Fix: A query was not fully traversed in the sanitization. Therefore the
86
+ blacklist for mongo wueries could be bypassed, allowing for dangerous
87
+ ``$where`` queries (Moritz Schneider).
88
+
80
89
Version 0.7.4
81
90
~~~~~~~~~~~~~
82
91
Original file line number Diff line number Diff line change @@ -817,10 +817,14 @@ def sanitize_keys(spec):
817
817
'Query contains operators banned in MONGO_QUERY_BLACKLIST'
818
818
))
819
819
820
- sanitize_keys (spec )
821
- for value in spec .values ():
822
- if isinstance (value , dict ):
823
- sanitize_keys (value )
820
+ if isinstance (spec , dict ):
821
+ sanitize_keys (spec )
822
+ for value in spec .values ():
823
+ self ._sanitize (value )
824
+ if isinstance (spec , list ):
825
+ for value in spec :
826
+ self ._sanitize (value )
827
+
824
828
return spec
825
829
826
830
def _wc (self , resource ):
Original file line number Diff line number Diff line change @@ -205,6 +205,15 @@ def test_get_mongo_query_blacklist(self):
205
205
_ , status = self .get (self .known_resource , '?where=%s' % where )
206
206
self .assert400 (status )
207
207
208
+ def test_get_mongo_query_blacklist_nested (self ):
209
+ where = '{"$or": [{"$where": "this.ref == ' '%s' '"}]}' % self .item_name
210
+ _ , status = self .get (self .known_resource , '?where=%s' % where )
211
+ self .assert400 (status )
212
+
213
+ where = '{"$or": [{"ref": {"$regex": "%s"}}]}' % self .item_name
214
+ _ , status = self .get (self .known_resource , '?where=%s' % where )
215
+ self .assert400 (status )
216
+
208
217
def test_get_where_mongo_objectid_as_string (self ):
209
218
where = '{"tid": "%s"}' % self .item_tid
210
219
response , status = self .get (self .known_resource , '?where=%s' % where )
You can’t perform that action at this time.
0 commit comments