]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
[3.4] bpo-32981: Fix catastrophic backtracking vulns (GH-5955) (#6035)
authorNed Deily <nad@python.org>
Sun, 11 Mar 2018 18:28:53 +0000 (14:28 -0400)
committerlarryhastings <larry@hastings.org>
Sun, 11 Mar 2018 18:28:53 +0000 (18:28 +0000)
commit942cc04ae44825ea120e3a19a80c9b348b8194d0
treeaa861157f1f4062f49e23ea762bf606120d1f06d
parentf584ecdef652e88507e4bf85cbc024fa2f3f270f
[3.4] bpo-32981: Fix catastrophic backtracking vulns (GH-5955) (#6035)

* Prevent low-grade poplib REDOS (CVE-2018-1060)

The regex to test a mail server's timestamp is susceptible to
catastrophic backtracking on long evil responses from the server.

Happily, the maximum length of malicious inputs is 2K thanks
to a limit introduced in the fix for CVE-2013-1752.

A 2KB evil response from the mail server would result in small slowdowns
(milliseconds vs. microseconds) accumulated over many apop calls.
This is a potential DOS vector via accumulated slowdowns.

Replace it with a similar non-vulnerable regex.

The new regex is RFC compliant.
The old regex was non-compliant in edge cases.

* Prevent difflib REDOS (CVE-2018-1061)

The default regex for IS_LINE_JUNK is susceptible to
catastrophic backtracking.
This is a potential DOS vector.

Replace it with an equivalent non-vulnerable regex.

Also introduce unit and REDOS tests for difflib.

Co-authored-by: Tim Peters <tim.peters@gmail.com>
Co-authored-by: Christian Heimes <christian@python.org>.
Lib/difflib.py
Lib/poplib.py
Lib/test/test_difflib.py
Lib/test/test_poplib.py
Misc/ACKS
Misc/NEWS.d/next/Security/2018-03-02-10-24-52.bpo-32981.O_qDyj.rst [new file with mode: 0644]