Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python: promote nosql query #14070
Python: promote nosql query #14070
Changes from 1 commit
60dc1af
55707d3
db04597
087961d
19046ea
bf8bfd9
114984b
c0b3245
7edebbe
f253f97
970e881
b07d085
d91cd21
154a369
d9f63e1
a063d7d
4614b1a
5611bda
30c37ca
7c085ec
4ec8b3f
12dab88
8156fa9
37a4f35
3fb579e
d90630a
c2b6383
9682c82
2a739b3
eb1be08
2a7b593
a8e0023
d5b64c5
3043633
2e028a4
74d6f37
2d845e3
e170805
f3a0161
9769668
16e1a00
d7ad5a0
3676262
d6d13f8
9b73bbf
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't quite know what to think about this...
I wasn't quite sure if either the old or the new these solutions could handle when the dictionary is not constructed inside the argument to the call, such as:
But I tried it out locally, and it did in fact work. I guess they would since the
.getParameter(0)
takes us into "def node" domain, and we do back-tracking.So basically you seem to be creating an additional taint-step specifically for NoSQL injection directly from the element of a dictionary with key
$where
to the argument of a mongo collection method, if API-graphs can track the dictionary flowing to that argument?I think that works great for simple examples, but if there is any interprocedural steps, it will not be so nice. So I think we need to track these things with data-flow, so it can be part of the path shown to end-users. We might be able to achieve that with a string->dict taint-step directly when constructing a dictionary with a
$where
key?You could apply the same logic to the
$function
andbody
stuff, so there would be string->dict taint-step when constructing dictionary withbody
key, and dict->dict taint-step when constructing dict with$function
key. That would allow for all of the following examples to give alerts (I think only the first would today)Adding query specific taint-steps that mutate flow-state doesn't play very nicely with using Concepts, so I understand the temptation to just reuse the decoding Concepts, but I would argue that in fact no Decoding is taking place here. What I've done previously is to add query specific logic to the library modeling file, which is certainly something we could also do here (example from flask, originally added in #6989)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is basically what we are doing. We just require that the dictionary also flows to a harmful place.
My intuition is that type tracking should basically be an over-approximation to data flow, so this extra requirements is more like a cheap filter.
Anyway, I added the above tests, and they all pass out of the box...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice 👍 I guess that comes from the fact that we say after a
json.loads
, it could be a dict, and our default taint-steps propagate taint through dictionary literals right now.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think we could end up with a very long jumpstep due to the way it's written right now, which I don't think is a good solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, that is a reasonable objection (especially now that we got better path explanations in general). I made the step target the created dictionary instead of the argument that the dictionary flows to. Dataflow is able to link the two for us.