diff options
author | guido@google.com <guido@google.com> | 2011-03-24 15:07:45 (GMT) |
---|---|---|
committer | guido@google.com <guido@google.com> | 2011-03-24 15:07:45 (GMT) |
commit | 60a4a90c8dd2972eb4bb977e70835be9593cbbac (patch) | |
tree | d8bc2a9dac432760b9a5c7971fe903e8da102af5 /Lib/urllib2.py | |
parent | ce5d0e22fc307a22bf8410dbdd6b4f0190f36fab (diff) | |
download | cpython-60a4a90c8dd2972eb4bb977e70835be9593cbbac.zip cpython-60a4a90c8dd2972eb4bb977e70835be9593cbbac.tar.gz cpython-60a4a90c8dd2972eb4bb977e70835be9593cbbac.tar.bz2 |
Issue 22663: fix redirect vulnerability in urllib/urllib2.
Diffstat (limited to 'Lib/urllib2.py')
-rw-r--r-- | Lib/urllib2.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/urllib2.py b/Lib/urllib2.py index 50d7aaf..db7ce81 100644 --- a/Lib/urllib2.py +++ b/Lib/urllib2.py @@ -555,6 +555,13 @@ class HTTPRedirectHandler(BaseHandler): return newurl = urlparse.urljoin(req.get_full_url(), newurl) + # For security reasons we do not allow redirects to protocols + # other than HTTP or HTTPS. + newurl_lower = newurl.lower() + if not (newurl_lower.startswith('http://') or + newurl_lower.startswith('https://')): + return + # XXX Probably want to forget about the state of the current # request, although that might interact poorly with other # handlers that also use handler-specific request attributes |