We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 1c2d8bb commit d59f721Copy full SHA for d59f721
1 file changed
python/ql/test/query-tests/Security/CWE-113-HeaderInjection/Tests1/http_test.py
@@ -0,0 +1,22 @@
1
+from http.server import HTTPServer, BaseHTTPRequestHandler
2
+import urllib.parse
3
+
4
+class VulnerableHandler(BaseHTTPRequestHandler):
5
+ def do_GET(self):
6
+ parsed_path = urllib.parse.urlparse(self.path)
7
+ params = urllib.parse.parse_qs(parsed_path.query)
8
+ input_value = params.get("input", [""])[0]
9
+ # Unsafe: Directly including user input in headers
10
+ self.send_response(200)
11
+ try:
12
+ self.send_header("X-Info", input_value) # BAD
13
+ except Exception as e:
14
+ print(f"[!] Header injection failed: {e}")
15
+ self.end_headers()
16
+ self.wfile.write(b"Hello world!")
17
18
19
+# if __name__ == "__main__":
20
+# print("Serving vulnerable app on http://127.0.0.1:8080")
21
+# httpd = HTTPServer(("127.0.0.1", 8080), VulnerableHandler)
22
+# httpd.serve_forever()
0 commit comments