-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Python: detecting header splitting in synthetic app #20919
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
base: main
Are you sure you want to change the base?
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.
Pull request overview
This PR adds test coverage and modeling for header injection vulnerabilities using Python's http.server module and extends support for urllib.parse.ParseResult.
Key changes:
- Adds a test case demonstrating header injection vulnerability in
http.server.BaseHTTPRequestHandler - Introduces models for
urllib.parse.ParseResultclass to track taint propagation through URL parsing - Extends
urllib.parse.urlparsefunction modeling with taint propagation
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
python/ql/test/query-tests/Security/CWE-113-HeaderInjection/Tests1/http_test.py |
New test case demonstrating header injection vulnerability using http.server module |
python/ql/test/query-tests/Security/CWE-113-HeaderInjection/Tests1/HeaderInjection.expected |
Updated expected test results to include new test case findings (generated file) |
python/ql/lib/semmle/python/frameworks/Stdlib.qll |
Adds ParseResult module with taint tracking for urllib.parse.ParseResult class |
python/ql/lib/semmle/python/frameworks/Stdlib.model.yml |
Adds taint model for urlparse function and type model for ParseResult class |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # if __name__ == "__main__": | ||
| # print("Serving vulnerable app on http://127.0.0.1:8080") | ||
| # httpd = HTTPServer(("127.0.0.1", 8080), VulnerableHandler) | ||
| # httpd.serve_forever() |
Copilot
AI
Nov 26, 2025
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 comment appears to contain commented-out code.
| # if __name__ == "__main__": | |
| # print("Serving vulnerable app on http://127.0.0.1:8080") | |
| # httpd = HTTPServer(("127.0.0.1", 8080), VulnerableHandler) | |
| # httpd.serve_forever() | |
| # To run this server manually for testing, use: | |
| # python -m http.server 8080 --bind 127.0.0.1 | |
| # Or implement the main block as shown in documentation. |
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.
We normally leave such a code block there, so people can easily test for actual vulnerabilities.
| @@ -0,0 +1,22 @@ | |||
| from http.server import HTTPServer, BaseHTTPRequestHandler | |||
Copilot
AI
Nov 26, 2025
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.
Import of 'HTTPServer' is not used.
| from http.server import HTTPServer, BaseHTTPRequestHandler | |
| from http.server import BaseHTTPRequestHandler |
joefarebrother
left a comment
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.
Looks good 👍
Follow up work for https://github.com/github/field-security-codeql/issues/194