bpo-37461: Fix infinite loop in parsing of specially crafted email headers (GH-14794)

* bpo-37461: Fix infinite loop in parsing of specially crafted email headers.

Some crafted email header would cause the get_parameter method to run in an
infinite loop causing a DoS attack surface when parsing those headers. This
patch fixes that by making sure the DQUOTE character is handled to prevent
going into an infinite loop.
(cherry picked from commit a4a994bd3e)

Co-authored-by: Abhilash Raj <maxking@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2019-07-17 10:13:54 -07:00 committed by GitHub
parent 1fc43a3faf
commit 6816ca30af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 0 deletions

View file

@ -2690,6 +2690,13 @@ class Test_parse_mime_parameters(TestParserMixin, TestEmailBase):
# Defects are apparent missing *0*, and two 'out of sequence'.
[errors.InvalidHeaderDefect]*3),
# bpo-37461: Check that we don't go into an infinite loop.
'extra_dquote': (
'r*="\'a\'\\"',
' r="\\""',
'r*=\'a\'"',
[('r', '"')],
[errors.InvalidHeaderDefect]*2),
}
@parameterize