summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_urllib.py
diff options
context:
space:
mode:
authorSenthil Kumaran <senthil@uthcode.com>2016-07-30 12:49:53 (GMT)
committerSenthil Kumaran <senthil@uthcode.com>2016-07-30 12:49:53 (GMT)
commit75d7b615ba70fc5759d16dee95bbd8f0474d8a9c (patch)
tree6fedc2530db2160bf68039a3bf28b4fefbb39743 /Lib/test/test_urllib.py
parenta850ef698e55d07173051747e96207496c6f1bdb (diff)
downloadcpython-75d7b615ba70fc5759d16dee95bbd8f0474d8a9c.zip
cpython-75d7b615ba70fc5759d16dee95bbd8f0474d8a9c.tar.gz
cpython-75d7b615ba70fc5759d16dee95bbd8f0474d8a9c.tar.bz2
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 reported and patch contributed by Rémi Rampin.
Diffstat (limited to 'Lib/test/test_urllib.py')
-rw-r--r--Lib/test/test_urllib.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py
index 434d533..27a1d38 100644
--- a/Lib/test/test_urllib.py
+++ b/Lib/test/test_urllib.py
@@ -170,6 +170,18 @@ class ProxyTests(unittest.TestCase):
self.assertTrue(urllib.proxy_bypass_environment('anotherdomain.com:8888'))
self.assertTrue(urllib.proxy_bypass_environment('newdomain.com:1234'))
+ def test_proxy_cgi_ignore(self):
+ try:
+ self.env.set('HTTP_PROXY', 'http://somewhere:3128')
+ proxies = urllib.getproxies_environment()
+ self.assertEqual('http://somewhere:3128', proxies['http'])
+ self.env.set('REQUEST_METHOD', 'GET')
+ proxies = urllib.getproxies_environment()
+ self.assertNotIn('http', proxies)
+ finally:
+ self.env.unset('REQUEST_METHOD')
+ self.env.unset('HTTP_PROXY')
+
def test_proxy_bypass_environment_host_match(self):
bypass = urllib.proxy_bypass_environment
self.env.set('NO_PROXY',