-
-
Notifications
You must be signed in to change notification settings - Fork 35k
[CVE-2023-27043] gh-102988: Reject malformed addresses in email.parseaddr() #111116
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
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
663910d
gh-102988: email parseaddr() now rejects malformed address
vstinner 730500c
Fast path
vstinner 1a377ec
Handle escaped quotes
vstinner da25ed3
Check parenthesis
vstinner 2b199bb
Credit myself in the Changelog entry
vstinner 9b95376
Add email.utils.supports_strict_parsing attribute
vstinner cf50482
Simplify getaddresses()
vstinner 0dd5745
Update parseaddr() prototype in the doc
vstinner 637bdb8
Apply theta682's suggestion
vstinner 8df7013
Update Lib/test/test_email/test_email.py
vstinner 59da8f1
Restore removed test_getaddresses_comma_in_name()
vstinner 361b517
Move implementation details to comment
vstinner 3105a75
Simplify _strip_quoted_realnames()
vstinner fc6e86b
Fix _strip_quoted_realnames()
vstinner File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Check parenthesis
- Loading branch information
commit da25ed3b8623eaedce731c95a2ae953df187013a
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can use regular expressions:
Perhaps functions that use
_iter_escaped_chars()can also be written using efficient regular expressions to avoid handling ever char separately. For example,_strip_quoted_realnames()could user'(?s)(?:\\.|[^"])*|(")'or something like.But do what looks good to you, I can optimize it later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR is based on PR #108250 which uses the following code to strip quoted real names:
But this regular expression doesn't handle escape quote character (
\"). So I wrote_strip_quoted_realnames()to replace this invalid regex.I'm not comfortable with regex to write a parser when the grammar is that complicated. For example, antislash can also be escaped:
\\. I didn't check RFC carefully. I mostly tried to support escaped quote character (\").Also, my priority here is more to get a fix as soon as possible, since the vulnerability was reported in March, and I have to fix the CVE at work as soon as possible.