-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Python: Add Server-side Request Forgery sinks #8275
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
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.
Thanks for this contribution 👍
Please do the same rewrites I have suggested for python/ql/lib/semmle/python/frameworks/Aiohttp.qll
to the other files as well.
Also please add tests to highlight the cases we can now handle, like in https://github.com/github/codeql/blob/main/python/ql/test/library-tests/frameworks/requests/test.py
DataFlow::Node getUrlArg() { | ||
result = this.getArgByName("url") | ||
or | ||
not methodName = "request" and | ||
result = this.getArg(0) | ||
or | ||
methodName = "request" and | ||
result = this.getArg(1) | ||
} | ||
|
||
override DataFlow::Node getAUrlPart() { result = this.getUrlArg() } |
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 see any reason to have this separate predicate, can we just do
DataFlow::Node getUrlArg() { | |
result = this.getArgByName("url") | |
or | |
not methodName = "request" and | |
result = this.getArg(0) | |
or | |
methodName = "request" and | |
result = this.getArg(1) | |
} | |
override DataFlow::Node getAUrlPart() { result = this.getUrlArg() } | |
override DataFlow::Node getAUrlPart() { | |
result = this.getArgByName("url") | |
or | |
not methodName = "request" and | |
result = this.getArg(0) | |
or | |
methodName = "request" and | |
result = this.getArg(1) | |
} |
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.
Also please add tests to highlight the cases we can now handle, like in https://github.com/github/codeql/blob/main/python/ql/test/library-tests/frameworks/requests/test.py
Please review whether the test file is correct, thank you!
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.
They looked great, but there was a failure for httpx
. Next time you should run the tests in all directories before submitting 😉
Thanks for the updates @haby0. Since you did not target |
@RasmusWL 👍 |
Performance looks good 👍 |
Thanks. |
Add some sinks in the CodeQL-Python SSRF model. Modeled Python libraries are:
Aiohttp
,Httpx
,Libtaxii
,Urllib
,Urllib2
,Urllib3
.There may be inappropriate modeling, please point out the project maintainer so that I can improve it.