summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/python/python
diff options
context:
space:
mode:
authorMingli Yu <Mingli.Yu@windriver.com>2016-09-26 13:54:34 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-09-28 10:16:03 +0100
commitfd4391d8ba1da590dbf618599a7f72d16e253c4a (patch)
treef0d0d7a6acecb19de587acb04aaa943f96b81570 /meta/recipes-devtools/python/python
parentb5a00339d921510fe8cae68ba625ffa1558e2a7c (diff)
downloadpoky-fd4391d8ba1da590dbf618599a7f72d16e253c4a.tar.gz
python: fix CVE-2016-1000110
Backport patch to fix CVE-2016-1000110 from python upstream: for python2.7 https://hg.python.org/cpython/rev/ba915d561667/ for python3 https://hg.python.org/cpython/rev/a0ac52ed8f79 (From OE-Core rev: 1dd22b9d35983f35c481a1fcf67425aa0fd07a5b) Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/python/python')
-rw-r--r--meta/recipes-devtools/python/python/python-fix-CVE-2016-1000110.patch162
1 files changed, 162 insertions, 0 deletions
diff --git a/meta/recipes-devtools/python/python/python-fix-CVE-2016-1000110.patch b/meta/recipes-devtools/python/python/python-fix-CVE-2016-1000110.patch
new file mode 100644
index 0000000000..97888e2b08
--- /dev/null
+++ b/meta/recipes-devtools/python/python/python-fix-CVE-2016-1000110.patch
@@ -0,0 +1,162 @@
1From cb25fbd5abc0f4eb07dbb8ea819e9c26bda4fc99 Mon Sep 17 00:00:00 2001
2From: Senthil Kumaran <senthil@uthcode.com>
3Date: Sat, 30 Jul 2016 05:49:53 -0700
4Subject: [PATCH] python: fix CVE-2016-1000110
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9Prevent HTTPoxy attack (CVE-2016-1000110)
10
11Ignore the HTTP_PROXY variable when REQUEST_METHOD environment is set, which
12indicates that the script is in CGI mode.
13
14Issue reported and patch contributed by Rémi Rampin.
15
16Backport patch from https://hg.python.org/cpython/rev/ba915d561667/
17
18Upstream-Status: Backport
19CVE: CVE-2016-1000110
20Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
21---
22 Doc/howto/urllib2.rst | 5 +++++
23 Doc/library/urllib.rst | 10 ++++++++++
24 Doc/library/urllib2.rst | 5 +++++
25 Lib/test/test_urllib.py | 12 ++++++++++++
26 Lib/urllib.py | 9 +++++++++
27 Misc/ACKS | 1 +
28 Misc/NEWS | 4 ++++
29 7 files changed, 46 insertions(+)
30
31diff --git a/Doc/howto/urllib2.rst b/Doc/howto/urllib2.rst
32index 6bb06d4..5cf2c0c 100644
33--- a/Doc/howto/urllib2.rst
34+++ b/Doc/howto/urllib2.rst
35@@ -525,6 +525,11 @@ setting up a `Basic Authentication`_ handler: ::
36 through a proxy. However, this can be enabled by extending urllib2 as
37 shown in the recipe [#]_.
38
39+.. note::
40+
41+ ``HTTP_PROXY`` will be ignored if a variable ``REQUEST_METHOD`` is set; see
42+ the documentation on :func:`~urllib.getproxies`.
43+
44
45 Sockets and Layers
46 ==================
47diff --git a/Doc/library/urllib.rst b/Doc/library/urllib.rst
48index 3b5dc16..bddcba9 100644
49--- a/Doc/library/urllib.rst
50+++ b/Doc/library/urllib.rst
51@@ -295,6 +295,16 @@ Utility functions
52 If both lowercase and uppercase environment variables exist (and disagree),
53 lowercase is preferred.
54
55+ .. note::
56+
57+ If the environment variable ``REQUEST_METHOD`` is set, which usually
58+ indicates your script is running in a CGI environment, the environment
59+ variable ``HTTP_PROXY`` (uppercase ``_PROXY``) will be ignored. This is
60+ because that variable can be injected by a client using the "Proxy:"
61+ HTTP header. If you need to use an HTTP proxy in a CGI environment,
62+ either use ``ProxyHandler`` explicitly, or make sure the variable name
63+ is in lowercase (or at least the ``_proxy`` suffix).
64+
65 .. note::
66 urllib also exposes certain utility functions like splittype, splithost and
67 others parsing URL into various components. But it is recommended to use
68diff --git a/Doc/library/urllib2.rst b/Doc/library/urllib2.rst
69index 8a4c80e..b808b98 100644
70--- a/Doc/library/urllib2.rst
71+++ b/Doc/library/urllib2.rst
72@@ -229,6 +229,11 @@ The following classes are provided:
73
74 To disable autodetected proxy pass an empty dictionary.
75
76+ .. note::
77+
78+ ``HTTP_PROXY`` will be ignored if a variable ``REQUEST_METHOD`` is set;
79+ see the documentation on :func:`~urllib.getproxies`.
80+
81
82 .. class:: HTTPPasswordMgr()
83
84diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py
85index 434d533..27a1d38 100644
86--- a/Lib/test/test_urllib.py
87+++ b/Lib/test/test_urllib.py
88@@ -170,6 +170,18 @@ class ProxyTests(unittest.TestCase):
89 self.assertTrue(urllib.proxy_bypass_environment('anotherdomain.com:8888'))
90 self.assertTrue(urllib.proxy_bypass_environment('newdomain.com:1234'))
91
92+ def test_proxy_cgi_ignore(self):
93+ try:
94+ self.env.set('HTTP_PROXY', 'http://somewhere:3128')
95+ proxies = urllib.getproxies_environment()
96+ self.assertEqual('http://somewhere:3128', proxies['http'])
97+ self.env.set('REQUEST_METHOD', 'GET')
98+ proxies = urllib.getproxies_environment()
99+ self.assertNotIn('http', proxies)
100+ finally:
101+ self.env.unset('REQUEST_METHOD')
102+ self.env.unset('HTTP_PROXY')
103+
104 def test_proxy_bypass_environment_host_match(self):
105 bypass = urllib.proxy_bypass_environment
106 self.env.set('NO_PROXY',
107diff --git a/Lib/urllib.py b/Lib/urllib.py
108index 139fab9..c3ba2c9 100644
109--- a/Lib/urllib.py
110+++ b/Lib/urllib.py
111@@ -1380,12 +1380,21 @@ def getproxies_environment():
112 If you need a different way, you can pass a proxies dictionary to the
113 [Fancy]URLopener constructor.
114 """
115+ # Get all variables
116 proxies = {}
117 for name, value in os.environ.items():
118 name = name.lower()
119 if value and name[-6:] == '_proxy':
120 proxies[name[:-6]] = value
121
122+ # CVE-2016-1000110 - If we are running as CGI script, forget HTTP_PROXY
123+ # (non-all-lowercase) as it may be set from the web server by a "Proxy:"
124+ # header from the client
125+ # If "proxy" is lowercase, it will still be used thanks to the next block
126+ if 'REQUEST_METHOD' in os.environ:
127+ proxies.pop('http', None)
128+
129+ # Get lowercase variables
130 for name, value in os.environ.items():
131 if name[-6:] == '_proxy':
132 name = name.lower()
133diff --git a/Misc/ACKS b/Misc/ACKS
134index ee3a465..9c374b7 100644
135--- a/Misc/ACKS
136+++ b/Misc/ACKS
137@@ -1121,6 +1121,7 @@ Burton Radons
138 Jeff Ramnani
139 Varpu Rantala
140 Brodie Rao
141+Rémi Rampin
142 Senko Rasic
143 Antti Rasinen
144 Nikolaus Rath
145diff --git a/Misc/NEWS b/Misc/NEWS
146index 4ab3a70..cc2f65b 100644
147--- a/Misc/NEWS
148+++ b/Misc/NEWS
149@@ -187,6 +187,10 @@ Library
150 - Issue #26644: Raise ValueError rather than SystemError when a negative
151 length is passed to SSLSocket.recv() or read().
152
153+- Issue #27568: Prevent HTTPoxy attack (CVE-2016-1000110). Ignore the
154+ HTTP_PROXY variable when REQUEST_METHOD environment is set, which indicates
155+ that the script is in CGI mode.
156+
157 - Issue #23804: Fix SSL recv(0) and read(0) methods to return zero bytes
158 instead of up to 1024.
159
160--
1612.8.1
162