Skip to content
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

bpo-37461: Fix infinite loop in parsing of specially crafted email headers #14794

Merged
merged 3 commits into from Jul 17, 2019

Conversation

@maxking
Copy link
Contributor

maxking commented Jul 16, 2019

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.

https://bugs.python.org/issue37461

…aders.

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.
@maxking maxking requested a review from python/email-team as a code owner Jul 16, 2019
@maxking

This comment has been minimized.

Copy link
Contributor Author

maxking commented Jul 16, 2019

working on adding tests and NEWS entry.

@maxking

This comment has been minimized.

Copy link
Contributor Author

maxking commented Jul 16, 2019

I have added a slightly different test case than given in BPO and that fails with a different exception. I'll keep this PR around and convert it to a WIP, while I figure out what is going on. I may need to dig deeper than I originally thought and might need more time :)

@maxking maxking changed the title bpo-37461: Fix infinite loop in parsing of specially crafted email headers WIP: bpo-37461: Fix infinite loop in parsing of specially crafted email headers Jul 16, 2019
@mangrisano

This comment has been minimized.

Copy link
Contributor

mangrisano commented Jul 16, 2019

@aeros

This comment has been minimized.

Copy link
Member

aeros commented Jul 17, 2019

@maxking Instead of using WIP, you can also start the PR as a draft and open it once the tests are passing. I don't think it's possible to do this for a PR that's already been opened, but just for any future PRs it's a useful feature that I've started using recently.

@maxking

This comment has been minimized.

Copy link
Contributor Author

maxking commented Jul 17, 2019

@aeros167 Yeah, I added the tests after I opened the PR, which is why I had to switch it to WIP.

It is a feature in Gitlab, which I more frequently use, where you can switch between WIP PRs (a.k.a draft PR) and normal ones by just adding the WIP: prefix.

Thanks for the tip though, I should have opened a draft PR initially.

@maxking maxking changed the title WIP: bpo-37461: Fix infinite loop in parsing of specially crafted email headers bpo-37461: Fix infinite loop in parsing of specially crafted email headers Jul 17, 2019
@maxking

This comment has been minimized.

Copy link
Contributor Author

maxking commented Jul 17, 2019

So, I think my initial solution was correct, but my test case was wrong. That is a separate bug and I am working on a separate PR to fix that. Pushed a fix and I think this is ready for a review now.

Fingers crossed for the tests (they passed locally) ;-)

@warsaw
warsaw approved these changes Jul 17, 2019
@warsaw warsaw merged commit a4a994b into python:master Jul 17, 2019
5 checks passed
5 checks passed
Azure Pipelines PR #20190717.27 succeeded
Details
bedevere/issue-number Issue number 37461 found
Details
bedevere/news News entry found in Misc/NEWS.d
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@miss-islington

This comment has been minimized.

Copy link

miss-islington commented Jul 17, 2019

Thanks @maxking for the PR, and @warsaw for merging it 🌮🎉.. I'm working now to backport this PR to: 3.6, 3.7, 3.8.
🐍🍒🤖 I'm not a witch! I'm not a witch!

@miss-islington

This comment has been minimized.

Copy link

miss-islington commented Jul 17, 2019

I'm having trouble backporting to 3.8. Reason: 'Error 110 while writing to socket. Connection timed out.'. Please retry by removing and re-adding the needs backport to 3.8 label.

miss-islington added a commit to miss-islington/cpython that referenced this pull request Jul 17, 2019
…aders (pythonGH-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 a4a994b)

Co-authored-by: Abhilash Raj <maxking@users.noreply.github.com>
@bedevere-bot

This comment has been minimized.

Copy link

bedevere-bot commented Jul 17, 2019

GH-14816 is a backport of this pull request to the 3.7 branch.

miss-islington added a commit to miss-islington/cpython that referenced this pull request Jul 17, 2019
…aders (pythonGH-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 a4a994b)

Co-authored-by: Abhilash Raj <maxking@users.noreply.github.com>
@bedevere-bot

This comment has been minimized.

Copy link

bedevere-bot commented Jul 17, 2019

GH-14817 is a backport of this pull request to the 3.6 branch.

@miss-islington

This comment has been minimized.

Copy link

miss-islington commented Jul 17, 2019

Thanks @maxking for the PR, and @warsaw for merging it 🌮🎉.. I'm working now to backport this PR to: 3.6.
🐍🍒🤖

@miss-islington

This comment has been minimized.

Copy link

miss-islington commented Jul 17, 2019

Thanks @maxking for the PR, and @warsaw for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7.
🐍🍒🤖

@miss-islington

This comment has been minimized.

Copy link

miss-islington commented Jul 17, 2019

Thanks @maxking for the PR, and @warsaw for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8.
🐍🍒🤖

miss-islington added a commit to miss-islington/cpython that referenced this pull request Jul 17, 2019
…aders (pythonGH-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 a4a994b)

Co-authored-by: Abhilash Raj <maxking@users.noreply.github.com>
@bedevere-bot

This comment has been minimized.

Copy link

bedevere-bot commented Jul 17, 2019

GH-14818 is a backport of this pull request to the 3.8 branch.

miss-islington added a commit that referenced this pull request Jul 17, 2019
…aders (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 a4a994b)

Co-authored-by: Abhilash Raj <maxking@users.noreply.github.com>
miss-islington added a commit that referenced this pull request Jul 17, 2019
…aders (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 a4a994b)

Co-authored-by: Abhilash Raj <maxking@users.noreply.github.com>
ned-deily added a commit that referenced this pull request Aug 1, 2019
…aders (GH-14794) (GH-14817)

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 a4a994b)

Co-authored-by: Abhilash Raj <maxking@users.noreply.github.com>
LorenzMende added a commit to LorenzMende/cpython that referenced this pull request Aug 11, 2019
…aders (pythonGH-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.
maxking added a commit to maxking/cpython-1 that referenced this pull request Aug 24, 2019
…ail headers (pythonGH-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 a4a994b)

Co-authored-by: Abhilash Raj <maxking@users.noreply.github.com>
larryhastings added a commit that referenced this pull request Sep 7, 2019
…ail headers (GH-14794) (#15446)

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

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 a4a994b)

Co-authored-by: Abhilash Raj <maxking@users.noreply.github.com>
Co-Authored-By: Ashwin Ramaswami <aramaswamis@gmail.com>
lisroach added a commit to lisroach/cpython that referenced this pull request Sep 10, 2019
…aders (pythonGH-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.
vrpolakatcisco added a commit to vrpolakatcisco/cpython that referenced this pull request Sep 12, 2019
…aders (pythonGH-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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.