mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
[merge from 3.3] Prevent HTTPoxy attack (CVE-2016-1000110)
Ignore the HTTP_PROXY variable when REQUEST_METHOD environment is set, which indicates that the script is in CGI mode. Issue #27568 Reported and patch contributed by Rémi Rampin.
This commit is contained in:
commit
436fe5a447
5 changed files with 42 additions and 0 deletions
|
@ -222,6 +222,19 @@ class ProxyTests(unittest.TestCase):
|
|||
self.env.set('NO_PROXY', 'localhost, anotherdomain.com, newdomain.com')
|
||||
self.assertTrue(urllib.request.proxy_bypass_environment('anotherdomain.com'))
|
||||
|
||||
def test_proxy_cgi_ignore(self):
|
||||
try:
|
||||
self.env.set('HTTP_PROXY', 'http://somewhere:3128')
|
||||
proxies = urllib.request.getproxies_environment()
|
||||
self.assertEqual('http://somewhere:3128', proxies['http'])
|
||||
self.env.set('REQUEST_METHOD', 'GET')
|
||||
proxies = urllib.request.getproxies_environment()
|
||||
self.assertNotIn('http', proxies)
|
||||
finally:
|
||||
self.env.unset('REQUEST_METHOD')
|
||||
self.env.unset('HTTP_PROXY')
|
||||
|
||||
|
||||
class urlopen_HttpTests(unittest.TestCase, FakeHTTPMixin, FakeFTPMixin):
|
||||
"""Test urlopen() opening a fake http connection."""
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue