You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix an open redirection vulnerability in the `http.server` module when
an URI path starts with `//` that could produce a 301 Location header
with a misleading target. Vulnerability discovered, and logic fix
proposed, by Hamza Avvan (@hamzaavvan).
Test and comments authored by Gregory P. Smith [Google].
(cherry picked from commit 4abab6b)
Co-authored-by: Gregory P. Smith <[email protected]>
Copy file name to clipboardExpand all lines: Lib/http/server.py
+7Lines changed: 7 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -331,6 +331,13 @@ def parse_request(self):
331
331
returnFalse
332
332
self.command, self.path=command, path
333
333
334
+
# gh-87389: The purpose of replacing '//' with '/' is to protect
335
+
# against open redirect attacks possibly triggered if the path starts
336
+
# with '//' because http clients treat //path as an absolute URI
337
+
# without scheme (similar to http://path) rather than a path.
338
+
ifself.path.startswith('//'):
339
+
self.path='/'+self.path.lstrip('/') # Reduce to a single /
340
+
334
341
# Examine the headers and look for a Connection directive.
0 commit comments