Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[3.7] bpo-32981: Fix catastrophic backtracking vulns (GH-5955) #5969

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 4, 2018

Conversation

miss-islington
Copy link
Contributor

@miss-islington miss-islington commented Mar 4, 2018

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.

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 [email protected]
Co-authored-by: Christian Heimes [email protected]
(cherry picked from commit 0e6c8ee)

Co-authored-by: Jamie Davis [email protected]

https://bugs.python.org/issue32981

* 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 <[email protected]>
Co-authored-by: Christian Heimes <[email protected]>
(cherry picked from commit 0e6c8ee)

Co-authored-by: Jamie Davis <[email protected]>
@miss-islington miss-islington requested a review from a team as a code owner March 4, 2018 05:33
@bedevere-bot bedevere-bot added the type-bug An unexpected behavior, bug, or error label Mar 4, 2018
@miss-islington
Copy link
Contributor Author

@davisjam and @benjaminp: Backport status check is done, and it's a success ✅ .

@benjaminp benjaminp merged commit 0902a2d into python:3.7 Mar 4, 2018
@miss-islington
Copy link
Contributor Author

Thanks, @benjaminp!

@miss-islington miss-islington deleted the backport-0e6c8ee-3.7 branch March 4, 2018 05:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants