A RetroSearch Logo

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

Search Query:

Showing content from https://github.com/python/cpython/commit/0902a2d6b2d1d9dbde36aeaaccf1788ceaa97143 below:

Fix catastrophic backtracking vulns (GH-5955) · python/cpython@0902a2d · GitHub

File tree Expand file treeCollapse file tree 6 files changed

+39

-4

lines changed

Filter options

Expand file treeCollapse file tree 6 files changed

+39

-4

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

@@ -1083,7 +1083,7 @@ def _qformat(self, aline, bline, atags, btags):

1083 1083 1084 1084

import re

1085 1085 1086 -

def IS_LINE_JUNK(line, pat=re.compile(r"\s*#?\s*$").match):

1086 +

def IS_LINE_JUNK(line, pat=re.compile(r"\s*(?:#\s*)?$").match):

1087 1087

r"""

1088 1088

Return 1 for ignorable line: iff `line` is blank or contains a single '#'.

1089 1089 Original file line number Diff line number Diff line change

@@ -308,7 +308,7 @@ def rpop(self, user):

308 308

return self._shortcmd('RPOP %s' % user)

309 309 310 310 311 -

timestamp = re.compile(br'\+OK.*(<[^>]+>)')

311 +

timestamp = re.compile(br'\+OK.[^<]*(<.*>)')

312 312 313 313

def apop(self, user, password):

314 314

"""Authorisation

Original file line number Diff line number Diff line change

@@ -466,13 +466,33 @@ def _assert_type_error(self, msg, generator, *args):

466 466

list(generator(*args))

467 467

self.assertEqual(msg, str(ctx.exception))

468 468 469 +

class TestJunkAPIs(unittest.TestCase):

470 +

def test_is_line_junk_true(self):

471 +

for line in ['#', ' ', ' #', '# ', ' # ', '']:

472 +

self.assertTrue(difflib.IS_LINE_JUNK(line), repr(line))

473 + 474 +

def test_is_line_junk_false(self):

475 +

for line in ['##', ' ##', '## ', 'abc ', 'abc #', 'Mr. Moose is up!']:

476 +

self.assertFalse(difflib.IS_LINE_JUNK(line), repr(line))

477 + 478 +

def test_is_line_junk_REDOS(self):

479 +

evil_input = ('\t' * 1000000) + '##'

480 +

self.assertFalse(difflib.IS_LINE_JUNK(evil_input))

481 + 482 +

def test_is_character_junk_true(self):

483 +

for char in [' ', '\t']:

484 +

self.assertTrue(difflib.IS_CHARACTER_JUNK(char), repr(char))

485 + 486 +

def test_is_character_junk_false(self):

487 +

for char in ['a', '#', '\n', '\f', '\r', '\v']:

488 +

self.assertFalse(difflib.IS_CHARACTER_JUNK(char), repr(char))

469 489 470 490

def test_main():

471 491

difflib.HtmlDiff._default_prefix = 0

472 492

Doctests = doctest.DocTestSuite(difflib)

473 493

run_unittest(

474 494

TestWithAscii, TestAutojunk, TestSFpatches, TestSFbugs,

475 -

TestOutputFormat, TestBytes, Doctests)

495 +

TestOutputFormat, TestBytes, TestJunkAPIs, Doctests)

476 496 477 497

if __name__ == '__main__':

478 498

test_main()

Original file line number Diff line number Diff line change

@@ -308,9 +308,19 @@ def test_noop(self):

308 308

def test_rpop(self):

309 309

self.assertOK(self.client.rpop('foo'))

310 310 311 -

def test_apop(self):

311 +

def test_apop_normal(self):

312 312

self.assertOK(self.client.apop('foo', 'dummypassword'))

313 313 314 +

def test_apop_REDOS(self):

315 +

# Replace welcome with very long evil welcome.

316 +

# NB The upper bound on welcome length is currently 2048.

317 +

# At this length, evil input makes each apop call take

318 +

# on the order of milliseconds instead of microseconds.

319 +

evil_welcome = b'+OK' + (b'<' * 1000000)

320 +

with test_support.swap_attr(self.client, 'welcome', evil_welcome):

321 +

# The evil welcome is invalid, so apop should throw.

322 +

self.assertRaises(poplib.error_proto, self.client.apop, 'a', 'kb')

323 + 314 324

def test_top(self):

315 325

expected = (b'+OK 116 bytes',

316 326

[b'From: postmaster@python.org', b'Content-Type: text/plain',

Original file line number Diff line number Diff line change

@@ -356,6 +356,7 @@ Jonathan Dasteel

356 356

Pierre-Yves David

357 357

A. Jesse Jiryu Davis

358 358

Jake Davis

359 +

Jamie (James C.) Davis

359 360

Ratnadeep Debnath

360 361

Merlijn van Deen

361 362

John DeGood

Original file line number Diff line number Diff line change

@@ -0,0 +1,4 @@

1 +

Regexes in difflib and poplib were vulnerable to catastrophic backtracking.

2 +

These regexes formed potential DOS vectors (REDOS). They have been

3 +

refactored. This resolves CVE-2018-1060 and CVE-2018-1061.

4 +

Patch by Jamie Davis.

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