summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArmin Kuster <akuster808@gmail.com>2016-10-02 10:48:28 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-10-06 08:51:30 +0100
commit4b27738c5e589079214ad4d20077906ba2ef93ba (patch)
tree309d06390ed5ccefc883bfc316e247dd843bbab0
parent529bbe2cc2cebeec0ee6cef27aba2d1aafe79d38 (diff)
downloadpoky-4b27738c5e589079214ad4d20077906ba2ef93ba.tar.gz
python: Security fix CVE-2016-1000110
(From OE-Core rev: d3f0d6834416b3ee0e09f7b6a3ae09839fc16376) Signed-off-by: Armin Kuster <akuster808@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/recipes-devtools/python/python/CVE-2016-1000110.patch157
-rw-r--r--meta/recipes-devtools/python/python_2.7.11.bb1
2 files changed, 158 insertions, 0 deletions
diff --git a/meta/recipes-devtools/python/python/CVE-2016-1000110.patch b/meta/recipes-devtools/python/python/CVE-2016-1000110.patch
new file mode 100644
index 0000000000..071175acec
--- /dev/null
+++ b/meta/recipes-devtools/python/python/CVE-2016-1000110.patch
@@ -0,0 +1,157 @@
1From 5be8d3e97b1d2e526548cb346fd5f8980d31616a Mon Sep 17 00:00:00 2001
2From: Senthil Kumaran <senthil@uthcode.com>
3Date: Sat, 30 Jul 2016 05:49:53 -0700
4Subject: [PATCH] Prevent HTTPoxy attack (CVE-2016-1000110)
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9Ignore the HTTP_PROXY variable when REQUEST_METHOD environment is set, which
10indicates that the script is in CGI mode.
11
12Issue reported and patch contributed by Rémi Rampin.
13
14Upstream-Status: Backport
15CVE: CVE-2016-1000110
16
17Signed-off-by: Armin Kuster <akuster@mvista.com>
18
19---
20 Doc/howto/urllib2.rst | 5 +++++
21 Doc/library/urllib.rst | 10 ++++++++++
22 Doc/library/urllib2.rst | 5 +++++
23 Lib/test/test_urllib.py | 12 ++++++++++++
24 Lib/urllib.py | 9 +++++++++
25 Misc/ACKS | 1 +
26 Misc/NEWS | 4 ++++
27 7 files changed, 46 insertions(+)
28
29Index: Python-2.7.11/Doc/howto/urllib2.rst
30===================================================================
31--- Python-2.7.11.orig/Doc/howto/urllib2.rst
32+++ Python-2.7.11/Doc/howto/urllib2.rst
33@@ -523,6 +523,11 @@ setting up a `Basic Authentication`_ han
34 through a proxy. However, this can be enabled by extending urllib2 as
35 shown in the recipe [#]_.
36
37+.. note::
38+
39+ ``HTTP_PROXY`` will be ignored if a variable ``REQUEST_METHOD`` is set; see
40+ the documentation on :func:`~urllib.getproxies`.
41+
42
43 Sockets and Layers
44 ==================
45Index: Python-2.7.11/Doc/library/urllib.rst
46===================================================================
47--- Python-2.7.11.orig/Doc/library/urllib.rst
48+++ Python-2.7.11/Doc/library/urllib.rst
49@@ -293,6 +293,16 @@ Utility functions
50 find it, looks for proxy information from Mac OSX System Configuration for
51 Mac OS X and Windows Systems Registry for Windows.
52
53+ .. note::
54+
55+ If the environment variable ``REQUEST_METHOD`` is set, which usually
56+ indicates your script is running in a CGI environment, the environment
57+ variable ``HTTP_PROXY`` (uppercase ``_PROXY``) will be ignored. This is
58+ because that variable can be injected by a client using the "Proxy:"
59+ HTTP header. If you need to use an HTTP proxy in a CGI environment,
60+ either use ``ProxyHandler`` explicitly, or make sure the variable name
61+ is in lowercase (or at least the ``_proxy`` suffix).
62+
63 .. note::
64 urllib also exposes certain utility functions like splittype, splithost and
65 others parsing url into various components. But it is recommended to use
66Index: Python-2.7.11/Doc/library/urllib2.rst
67===================================================================
68--- Python-2.7.11.orig/Doc/library/urllib2.rst
69+++ Python-2.7.11/Doc/library/urllib2.rst
70@@ -229,6 +229,11 @@ The following classes are provided:
71
72 To disable autodetected proxy pass an empty dictionary.
73
74+ .. note::
75+
76+ ``HTTP_PROXY`` will be ignored if a variable ``REQUEST_METHOD`` is set;
77+ see the documentation on :func:`~urllib.getproxies`.
78+
79
80 .. class:: HTTPPasswordMgr()
81
82Index: Python-2.7.11/Misc/ACKS
83===================================================================
84--- Python-2.7.11.orig/Misc/ACKS
85+++ Python-2.7.11/Misc/ACKS
86@@ -1110,6 +1110,7 @@ Jérôme Radix
87 Burton Radons
88 Jeff Ramnani
89 Brodie Rao
90+Rémi Rampin
91 Senko Rasic
92 Antti Rasinen
93 Nikolaus Rath
94Index: Python-2.7.11/Lib/test/test_urllib.py
95===================================================================
96--- Python-2.7.11.orig/Lib/test/test_urllib.py
97+++ Python-2.7.11/Lib/test/test_urllib.py
98@@ -162,6 +162,18 @@ class ProxyTests(unittest.TestCase):
99 self.assertTrue(urllib.proxy_bypass_environment('anotherdomain.com'))
100
101
102+ def test_proxy_cgi_ignore(self):
103+ try:
104+ self.env.set('HTTP_PROXY', 'http://somewhere:3128')
105+ proxies = urllib.getproxies_environment()
106+ self.assertEqual('http://somewhere:3128', proxies['http'])
107+ self.env.set('REQUEST_METHOD', 'GET')
108+ proxies = urllib.getproxies_environment()
109+ self.assertNotIn('http', proxies)
110+ finally:
111+ self.env.unset('REQUEST_METHOD')
112+ self.env.unset('HTTP_PROXY')
113+
114 class urlopen_HttpTests(unittest.TestCase, FakeHTTPMixin):
115 """Test urlopen() opening a fake http connection."""
116
117Index: Python-2.7.11/Lib/urllib.py
118===================================================================
119--- Python-2.7.11.orig/Lib/urllib.py
120+++ Python-2.7.11/Lib/urllib.py
121@@ -1382,11 +1382,21 @@ def getproxies_environment():
122 [Fancy]URLopener constructor.
123
124 """
125+ # Get all variables
126 proxies = {}
127 for name, value in os.environ.items():
128 name = name.lower()
129 if value and name[-6:] == '_proxy':
130 proxies[name[:-6]] = value
131+
132+ # CVE-2016-1000110 - If we are running as CGI script, forget HTTP_PROXY
133+ # (non-all-lowercase) as it may be set from the web server by a "Proxy:"
134+ # header from the client
135+ # If "proxy" is lowercase, it will still be used thanks to the next block
136+ if 'REQUEST_METHOD' in os.environ:
137+ proxies.pop('http', None)
138+
139+ # Get lowercase variables
140 return proxies
141
142 def proxy_bypass_environment(host):
143Index: Python-2.7.11/Misc/NEWS
144===================================================================
145--- Python-2.7.11.orig/Misc/NEWS
146+++ Python-2.7.11/Misc/NEWS
147@@ -10,6 +10,10 @@ What's New in Python 2.7.11?
148 Library
149 -------
150
151+- Issue #27568: Prevent HTTPoxy attack (CVE-2016-1000110). Ignore the
152+ HTTP_PROXY variable when REQUEST_METHOD environment is set, which indicates
153+ that the script is in CGI mode.
154+
155 - Issue #25624: ZipFile now always writes a ZIP_STORED header for directory
156 entries. Patch by Dingyuan Wang.
157
diff --git a/meta/recipes-devtools/python/python_2.7.11.bb b/meta/recipes-devtools/python/python_2.7.11.bb
index 606f153623..9697c1bf0b 100644
--- a/meta/recipes-devtools/python/python_2.7.11.bb
+++ b/meta/recipes-devtools/python/python_2.7.11.bb
@@ -27,6 +27,7 @@ SRC_URI += "\
27 file://use_sysroot_ncurses_instead_of_host.patch \ 27 file://use_sysroot_ncurses_instead_of_host.patch \
28 file://avoid_parallel_make_races_on_pgen.patch \ 28 file://avoid_parallel_make_races_on_pgen.patch \
29 file://add-CROSSPYTHONPATH-for-PYTHON_FOR_BUILD.patch \ 29 file://add-CROSSPYTHONPATH-for-PYTHON_FOR_BUILD.patch \
30 file://CVE-2016-1000110.patch \
30" 31"
31 32
32S = "${WORKDIR}/Python-${PV}" 33S = "${WORKDIR}/Python-${PV}"