mirror of
https://github.com/python/cpython.git
synced 2025-11-25 04:34:37 +00:00
bpo-32981: Fix catastrophic backtracking vulns (#5955)
* 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>
This commit is contained in:
parent
13cfd57dcf
commit
0e6c8ee235
6 changed files with 39 additions and 4 deletions
|
|
@ -308,7 +308,7 @@ class POP3:
|
|||
return self._shortcmd('RPOP %s' % user)
|
||||
|
||||
|
||||
timestamp = re.compile(br'\+OK.*(<[^>]+>)')
|
||||
timestamp = re.compile(br'\+OK.[^<]*(<.*>)')
|
||||
|
||||
def apop(self, user, password):
|
||||
"""Authorisation
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue