Python: detecting header splitting in synthetic app#20919
Merged
yoff merged 5 commits intogithub:mainfrom Dec 3, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
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.
Comment on lines
+19
to
+22
| # 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() |
There was a problem hiding this comment.
This comment appears to contain commented-out code.
Suggested change
| # 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. |
Contributor
Author
There was a problem hiding this comment.
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 | |||
There was a problem hiding this comment.
Import of 'HTTPServer' is not used.
Suggested change
| from http.server import HTTPServer, BaseHTTPRequestHandler | |
| from http.server import BaseHTTPRequestHandler |
Contributor
Author
|
Performance looks fine, merging. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Follow up work for https://github.com/github/field-security-codeql/issues/194