-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Python : Add support for detecting XSLT Injection #3521
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
Conversation
Hi @porcupineyhairs, thanks for both submissions 👍 As An example is the modeling of the flask library here. In the tests that use flask, use need to specify that the stubbed libraries should be imported using an So if you could make stubs for It seems like the only interaction with the ClassValue etree() { result = Value::named("lxml.etree") } But that won't work, since
P.S. Just to clear up confusion Unless you want me to review your code in its current state, I'll postpone reviewing it until you have done the library stubbing. Does that sound good with you? Could you also please move all the contributed files to the |
Oh yeah, both queries also seem to be missing |
@RasmusWL I have stubbed the dependencies and added the qhelp file. |
This PR adds support for detecting XSLT injection in Python. I have included the ql files as well as the tests with this.
@RasmusWL I have included changes you mentioned in the other PR. I have also rebased this to the current master. Please note that while this is similar to the XPath injection PR, both of them tackle different issues and different impact. In the case of this one, XSLT injection, the attacker can obtain code injection quite easily. While in the XPath injection's case, this was not possible. As for "one valid CVE", I don't have any out the top of my head. Googling does give you a few results But this is a quite common vulnerability. Most of the other scanners such as Fortify support this. Hence, I think CodeQL should support this too. |
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.
see below
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.
Just like you added an example of how to properly handle user input for the XPath query, could you expand the qhelp with an example of how to actually do this:
If the application logic necessiates processing untrusted XSL stylesheets, the input should be properly filtered and sanitized before use.
Besides that, (and the getASuccessor
), I'm happy to merge this PR (pending evaluation on all Python projects).
exists(CallNode call, AttrNode atr | | ||
atr = etree().getAReference().getASuccessor() and | ||
// XML(text, parser=None, base_url=None) | ||
atr.getName() = "XML" and | ||
atr = call.getFunction() |
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.
Seems like I was a bit quick to say "all good", would like you to change this getASuccessor
as well 👍
@porcupineyhairs similar to #3522 for consideration of bounty award it is a requirement that the query finds a real world result. If you can map this query to any CVE or an existing project result, that would be helpful in further assessing the bounty award eligibility. We were unable to uncover a qualifying result set via LGTM. Thanks! |
As an update, the same evaluation as #3522 applies to this PR re: bounty award. |
@anticomputer @RasmusWL I am unable to find any cve's for this. Since the codebase is being rewritten, it makes little sense to make the changes @RasmusWL requested and get this ready to merge today. Hence, I am closing this one for now. |
I would probably have merged this anyway, and fixed up with |
Turned out that |
Python: Add support for detecting XSLT Injection (#3521 revived)
This can't detect the case mentioned here. Adding a comment here to keep track of this limitation. |
This PR adds support for detecting XSLT injection in Python.
I have included the ql files as well as the tests with this.
However, I haven't included included the
*.expected
files as lxml isnot stubbed into master yet. If someone could run
depstubber
and pushthe stubs, I would be able to complete my work.
cc: @RasmusWL @tausbn