diff options
Diffstat (limited to 'meta/recipes-devtools')
-rw-r--r-- | meta/recipes-devtools/python/python/CVE-2016-1000110.patch | 157 | ||||
-rw-r--r-- | meta/recipes-devtools/python/python_2.7.11.bb | 1 |
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 @@ | |||
1 | From 5be8d3e97b1d2e526548cb346fd5f8980d31616a Mon Sep 17 00:00:00 2001 | ||
2 | From: Senthil Kumaran <senthil@uthcode.com> | ||
3 | Date: Sat, 30 Jul 2016 05:49:53 -0700 | ||
4 | Subject: [PATCH] Prevent HTTPoxy attack (CVE-2016-1000110) | ||
5 | MIME-Version: 1.0 | ||
6 | Content-Type: text/plain; charset=UTF-8 | ||
7 | Content-Transfer-Encoding: 8bit | ||
8 | |||
9 | Ignore the HTTP_PROXY variable when REQUEST_METHOD environment is set, which | ||
10 | indicates that the script is in CGI mode. | ||
11 | |||
12 | Issue reported and patch contributed by Rémi Rampin. | ||
13 | |||
14 | Upstream-Status: Backport | ||
15 | CVE: CVE-2016-1000110 | ||
16 | |||
17 | Signed-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 | |||
29 | Index: 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 | ================== | ||
45 | Index: 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 | ||
66 | Index: 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 | |||
82 | Index: 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 | ||
94 | Index: 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 | |||
117 | Index: 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): | ||
143 | Index: 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 | ||
32 | S = "${WORKDIR}/Python-${PV}" | 33 | S = "${WORKDIR}/Python-${PV}" |