summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/python/python3/python3-fix-CVE-2016-1000110.patch
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/python3/python3-fix-CVE-2016-1000110.patch
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/python3/python3-fix-CVE-2016-1000110.patch')
-rw-r--r--meta/recipes-devtools/python/python3/python3-fix-CVE-2016-1000110.patch148
1 files changed, 148 insertions, 0 deletions
diff --git a/meta/recipes-devtools/python/python3/python3-fix-CVE-2016-1000110.patch b/meta/recipes-devtools/python/python3/python3-fix-CVE-2016-1000110.patch
new file mode 100644
index 0000000000..ab1b7230ea
--- /dev/null
+++ b/meta/recipes-devtools/python/python3/python3-fix-CVE-2016-1000110.patch
@@ -0,0 +1,148 @@
1From aab3e8c432b90508ac14755128f5a687be2fdf43 Mon Sep 17 00:00:00 2001
2From: Mingli Yu <Mingli.Yu@windriver.com>
3Date: Thu, 22 Sep 2016 16:39:49 +0800
4Subject: [PATCH] python3: fix 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 #27568 Reported and patch contributed by RĂ©mi Rampin. [#27568]
13
14Backport patch from https://hg.python.org/cpython/rev/a0ac52ed8f79
15
16Upstream-Status: Backport
17CVE: CVE-2016-1000110
18Signed-off-by: Mingli Yu <Mingli.Yu@windriver.com>
19---
20 Doc/howto/urllib2.rst | 5 +++++
21 Doc/library/urllib.request.rst | 17 ++++++++++++++++-
22 Lib/test/test_urllib.py | 14 +++++++++++++-
23 Lib/urllib/request.py | 6 ++++++
24 Misc/NEWS | 4 ++++
25 5 files changed, 44 insertions(+), 2 deletions(-)
26
27diff --git a/Doc/howto/urllib2.rst b/Doc/howto/urllib2.rst
28index 24a4156..d2c7991 100644
29--- a/Doc/howto/urllib2.rst
30+++ b/Doc/howto/urllib2.rst
31@@ -538,6 +538,11 @@ setting up a `Basic Authentication`_ handler: ::
32 through a proxy. However, this can be enabled by extending urllib.request as
33 shown in the recipe [#]_.
34
35+.. note::
36+
37+ ``HTTP_PROXY`` will be ignored if a variable ``REQUEST_METHOD`` is set; see
38+ the documentation on :func:`~urllib.request.getproxies`.
39+
40
41 Sockets and Layers
42 ==================
43diff --git a/Doc/library/urllib.request.rst b/Doc/library/urllib.request.rst
44index 1338906..1291aeb 100644
45--- a/Doc/library/urllib.request.rst
46+++ b/Doc/library/urllib.request.rst
47@@ -173,6 +173,16 @@ The :mod:`urllib.request` module defines the following functions:
48 If both lowercase and uppercase environment variables exist (and disagree),
49 lowercase is preferred.
50
51+ .. note::
52+
53+ If the environment variable ``REQUEST_METHOD`` is set, which usually
54+ indicates your script is running in a CGI environment, the environment
55+ variable ``HTTP_PROXY`` (uppercase ``_PROXY``) will be ignored. This is
56+ because that variable can be injected by a client using the "Proxy:" HTTP
57+ header. If you need to use an HTTP proxy in a CGI environment, either use
58+ ``ProxyHandler`` explicitly, or make sure the variable name is in
59+ lowercase (or at least the ``_proxy`` suffix).
60+
61
62 The following classes are provided:
63
64@@ -280,6 +290,11 @@ The following classes are provided:
65 list of hostname suffixes, optionally with ``:port`` appended, for example
66 ``cern.ch,ncsa.uiuc.edu,some.host:8080``.
67
68+ .. note::
69+
70+ ``HTTP_PROXY`` will be ignored if a variable ``REQUEST_METHOD`` is set;
71+ see the documentation on :func:`~urllib.request.getproxies`.
72+
73
74 .. class:: HTTPPasswordMgr()
75
76@@ -1138,7 +1153,7 @@ the returned bytes object to string once it determines or guesses
77 the appropriate encoding.
78
79 The following W3C document, https://www.w3.org/International/O-charset\ , lists
80-the various ways in which a (X)HTML or a XML document could have specified its
81+the various ways in which an (X)HTML or an XML document could have specified its
82 encoding information.
83
84 As the python.org website uses *utf-8* encoding as specified in its meta tag, we
85diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py
86index 5d05f8d..247598a 100644
87--- a/Lib/test/test_urllib.py
88+++ b/Lib/test/test_urllib.py
89@@ -1,4 +1,4 @@
90-"""Regresssion tests for what was in Python 2's "urllib" module"""
91+"""Regression tests for what was in Python 2's "urllib" module"""
92
93 import urllib.parse
94 import urllib.request
95@@ -232,6 +232,18 @@ class ProxyTests(unittest.TestCase):
96 self.assertTrue(urllib.request.proxy_bypass_environment('anotherdomain.com:8888'))
97 self.assertTrue(urllib.request.proxy_bypass_environment('newdomain.com:1234'))
98
99+ def test_proxy_cgi_ignore(self):
100+ try:
101+ self.env.set('HTTP_PROXY', 'http://somewhere:3128')
102+ proxies = urllib.request.getproxies_environment()
103+ self.assertEqual('http://somewhere:3128', proxies['http'])
104+ self.env.set('REQUEST_METHOD', 'GET')
105+ proxies = urllib.request.getproxies_environment()
106+ self.assertNotIn('http', proxies)
107+ finally:
108+ self.env.unset('REQUEST_METHOD')
109+ self.env.unset('HTTP_PROXY')
110+
111 def test_proxy_bypass_environment_host_match(self):
112 bypass = urllib.request.proxy_bypass_environment
113 self.env.set('NO_PROXY',
114diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py
115index 1731fe3..3be327d 100644
116--- a/Lib/urllib/request.py
117+++ b/Lib/urllib/request.py
118@@ -2412,6 +2412,12 @@ def getproxies_environment():
119 name = name.lower()
120 if value and name[-6:] == '_proxy':
121 proxies[name[:-6]] = value
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 for name, value in os.environ.items():
129 if name[-6:] == '_proxy':
130 name = name.lower()
131diff --git a/Misc/NEWS b/Misc/NEWS
132index 4ad2551..2fcc95b 100644
133--- a/Misc/NEWS
134+++ b/Misc/NEWS
135@@ -329,6 +329,10 @@ Library
136 - Issue #26644: Raise ValueError rather than SystemError when a negative
137 length is passed to SSLSocket.recv() or read().
138
139+- Issue #27568: Prevent HTTPoxy attack (CVE-2016-1000110). Ignore the
140+ HTTP_PROXY variable when REQUEST_METHOD environment is set, which indicates
141+ that the script is in CGI mode.
142+
143 - Issue #23804: Fix SSL recv(0) and read(0) methods to return zero bytes
144 instead of up to 1024.
145
146--
1472.8.1
148