A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/python/cpython/commit/75d7b615ba70fc5759d16dee95bbd8f0474d8a9c below:

Prevent HTTPoxy attack (CVE-2016-1000110) · python/cpython@75d7b61 · GitHub

File tree Expand file treeCollapse file tree 7 files changed

+46

-0

lines changed

Filter options

Expand file treeCollapse file tree 7 files changed

+46

-0

lines changed Original file line number Diff line number Diff line change

@@ -525,6 +525,11 @@ setting up a `Basic Authentication`_ handler: ::

525 525

through a proxy. However, this can be enabled by extending urllib2 as

526 526

shown in the recipe [#]_.

527 527 528 +

.. note::

529 + 530 +

``HTTP_PROXY`` will be ignored if a variable ``REQUEST_METHOD`` is set; see

531 +

the documentation on :func:`~urllib.getproxies`.

532 + 528 533 529 534

Sockets and Layers

530 535

==================

Original file line number Diff line number Diff line change

@@ -295,6 +295,16 @@ Utility functions

295 295

If both lowercase and uppercase environment variables exist (and disagree),

296 296

lowercase is preferred.

297 297 298 +

.. note::

299 + 300 +

If the environment variable ``REQUEST_METHOD`` is set, which usually

301 +

indicates your script is running in a CGI environment, the environment

302 +

variable ``HTTP_PROXY`` (uppercase ``_PROXY``) will be ignored. This is

303 +

because that variable can be injected by a client using the "Proxy:"

304 +

HTTP header. If you need to use an HTTP proxy in a CGI environment,

305 +

either use ``ProxyHandler`` explicitly, or make sure the variable name

306 +

is in lowercase (or at least the ``_proxy`` suffix).

307 + 298 308

.. note::

299 309

urllib also exposes certain utility functions like splittype, splithost and

300 310

others parsing URL into various components. But it is recommended to use

Original file line number Diff line number Diff line change

@@ -229,6 +229,11 @@ The following classes are provided:

229 229 230 230

To disable autodetected proxy pass an empty dictionary.

231 231 232 +

.. note::

233 + 234 +

``HTTP_PROXY`` will be ignored if a variable ``REQUEST_METHOD`` is set;

235 +

see the documentation on :func:`~urllib.getproxies`.

236 + 232 237 233 238

.. class:: HTTPPasswordMgr()

234 239 Original file line number Diff line number Diff line change

@@ -170,6 +170,18 @@ def test_getproxies_environment_keep_no_proxies(self):

170 170

self.assertTrue(urllib.proxy_bypass_environment('anotherdomain.com:8888'))

171 171

self.assertTrue(urllib.proxy_bypass_environment('newdomain.com:1234'))

172 172 173 +

def test_proxy_cgi_ignore(self):

174 +

try:

175 +

self.env.set('HTTP_PROXY', 'http://somewhere:3128')

176 +

proxies = urllib.getproxies_environment()

177 +

self.assertEqual('http://somewhere:3128', proxies['http'])

178 +

self.env.set('REQUEST_METHOD', 'GET')

179 +

proxies = urllib.getproxies_environment()

180 +

self.assertNotIn('http', proxies)

181 +

finally:

182 +

self.env.unset('REQUEST_METHOD')

183 +

self.env.unset('HTTP_PROXY')

184 + 173 185

def test_proxy_bypass_environment_host_match(self):

174 186

bypass = urllib.proxy_bypass_environment

175 187

self.env.set('NO_PROXY',

Original file line number Diff line number Diff line change

@@ -1380,12 +1380,21 @@ def getproxies_environment():

1380 1380

If you need a different way, you can pass a proxies dictionary to the

1381 1381

[Fancy]URLopener constructor.

1382 1382

"""

1383 +

# Get all variables

1383 1384

proxies = {}

1384 1385

for name, value in os.environ.items():

1385 1386

name = name.lower()

1386 1387

if value and name[-6:] == '_proxy':

1387 1388

proxies[name[:-6]] = value

1388 1389 1390 +

# CVE-2016-1000110 - If we are running as CGI script, forget HTTP_PROXY

1391 +

# (non-all-lowercase) as it may be set from the web server by a "Proxy:"

1392 +

# header from the client

1393 +

# If "proxy" is lowercase, it will still be used thanks to the next block

1394 +

if 'REQUEST_METHOD' in os.environ:

1395 +

proxies.pop('http', None)

1396 + 1397 +

# Get lowercase variables

1389 1398

for name, value in os.environ.items():

1390 1399

if name[-6:] == '_proxy':

1391 1400

name = name.lower()

Original file line number Diff line number Diff line change

@@ -1123,6 +1123,7 @@ Burton Radons

1123 1123

Jeff Ramnani

1124 1124

Varpu Rantala

1125 1125

Brodie Rao

1126 +

Rémi Rampin

1126 1127

Senko Rasic

1127 1128

Antti Rasinen

1128 1129

Nikolaus Rath

Original file line number Diff line number Diff line change

@@ -29,6 +29,10 @@ Core and Builtins

29 29

Library

30 30

-------

31 31 32 +

- Issue #27568: Prevent HTTPoxy attack (CVE-2016-1000110). Ignore the

33 +

HTTP_PROXY variable when REQUEST_METHOD environment is set, which indicates

34 +

that the script is in CGI mode.

35 + 32 36

- Issue #27130: In the "zlib" module, fix handling of large buffers

33 37

(typically 2 or 4 GiB). Previously, inputs were limited to 2 GiB, and

34 38

compression and decompression operations did not properly handle results of

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4