
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2019-07-01 03:21 byGuido, last changed2022-04-11 14:59 byadmin. This issue is nowclosed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| reproducer.py | vstinner,2019-07-15 09:36 | |||
| reproducer2.py | vstinner,2019-07-15 09:36 | |||
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 14551 | closed | n0npax,2019-07-02 10:40 | |
| PR 14794 | merged | maxking,2019-07-16 15:08 | |
| PR 14816 | merged | miss-islington,2019-07-17 16:44 | |
| PR 14817 | merged | miss-islington,2019-07-17 16:44 | |
| PR 14818 | merged | miss-islington,2019-07-17 16:45 | |
| PR 15430 | merged | GeeTransit,2019-08-24 04:29 | |
| PR 15432 | merged | GeeTransit,2019-08-24 04:33 | |
| PR 15446 | merged | maxking,2019-08-24 04:55 | |
| Messages (19) | |||
|---|---|---|---|
| msg346953 -(view) | Author: Guido Vranken (Guido) | Date: 2019-07-01 03:21 | |
The following will hang, and consume a large amount of memory:from email.parser import BytesParser, Parserfrom email.policy import defaultpayload = "".join(chr(c) for c in [0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x54, 0x79, 0x70, 0x65, 0x3a, 0x78, 0x3b, 0x61, 0x72, 0x1b, 0x2a, 0x3d, 0x22, 0x73, 0x4f, 0x27, 0x23, 0x61, 0xff, 0xff, 0x27, 0x5c, 0x22])Parser(policy=default).parsestr(payload) | |||
| msg347014 -(view) | Author: Marcin Niemira (Marcin Niemira) | Date: 2019-07-01 13:07 | |
Sounds like there is an infinite loop here:```Pdb) > /usr/lib/python3.7/email/_header_value_parser.py(2370)get_parameter()-> v.append(token)(Pdb) > /usr/lib/python3.7/email/_header_value_parser.py(2365)get_parameter()-> while value:```the ```v.append(token)``` is just growing with ```ValueTerminal(''), ValueTerminal(''), ValueTerminal('')...```I'd be happy to try to fix this. | |||
| msg347108 -(view) | Author: Karthikeyan Singaravelan (xtreak)*![]() | Date: 2019-07-02 06:29 | |
Since the parser could take user input this looks like a security issue to me along with high CPU usage. Feel free to remove the tag if it's not a security issue. Thanks. | |||
| msg347263 -(view) | Author: Marcin Niemira (Marcin Niemira) | Date: 2019-07-04 10:04 | |
I'm terribly sorry, but I feel I won't be able to fix this issue. Sorry for fuss. Closing my PR, because it's broken. | |||
| msg347953 -(view) | Author: STINNER Victor (vstinner)*![]() | Date: 2019-07-15 09:36 | |
>>> bytes([0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x54, 0x79, 0x70, 0x65, 0x3a, 0x78, 0x3b, 0x61, 0x72, 0x1b, 0x2a, 0x3d, 0x22, 0x73, 0x4f, 0x27, 0x23, 0x61, 0xff, 0xff, 0x27, 0x5c, 0x22])b'Content-Type:x;ar\x1b*="sO\'#a\xff\xff\'\\"'The following loop ofLib/email/_header_value_parser.py does never stop:def get_parameter(value): """ attribute [section] ["*"] [CFWS] "=" value The CFWS is implied by the RFC but not made explicit in the BNF. This simplified form of the BNF from the RFC is made to conform with the RFC BNF through some extra checks. We do it this way because it makes both error recovery and working with the resulting parse tree easier. """ ... if remainder is not None: ... while value: ...Attached reproducer.py is code from initialmsg346953.reproducer2.py simplify the input and calls directly get_parameter(). Simplified input string: r*="'a'\" | |||
| msg348060 -(view) | Author: Abhilash Raj (maxking)*![]() | Date: 2019-07-17 14:00 | |
I have proposed a PR for this:https://github.com/python/cpython/pull/14794Reviews are welcome. | |||
| msg348064 -(view) | Author: Guido Vranken (Guido) | Date: 2019-07-17 15:04 | |
I used fuzzing to find this bug. After applying your patch, the infinite loop is gone and it cannot find any other bugs of this nature. | |||
| msg348070 -(view) | Author: Barry A. Warsaw (barry)*![]() | Date: 2019-07-17 16:44 | |
New changeseta4a994bd3e619cbaff97610a1cee8ffa87c672f5 by Barry Warsaw (Abhilash Raj) in branch 'master':bpo-37461: Fix infinite loop in parsing of specially crafted email headers (GH-14794)https://github.com/python/cpython/commit/a4a994bd3e619cbaff97610a1cee8ffa87c672f5 | |||
| msg348071 -(view) | Author: miss-islington (miss-islington) | Date: 2019-07-17 17:02 | |
New changeset391511ccaaf0050970dfbe95bf2df1bcf6c33440 by Miss Islington (bot) in branch '3.7':bpo-37461: Fix infinite loop in parsing of specially crafted email headers (GH-14794)https://github.com/python/cpython/commit/391511ccaaf0050970dfbe95bf2df1bcf6c33440 | |||
| msg348072 -(view) | Author: miss-islington (miss-islington) | Date: 2019-07-17 17:14 | |
New changeset6816ca30af7705db691343100e696ea3d8f447d5 by Miss Islington (bot) in branch '3.8':bpo-37461: Fix infinite loop in parsing of specially crafted email headers (GH-14794)https://github.com/python/cpython/commit/6816ca30af7705db691343100e696ea3d8f447d5 | |||
| msg348850 -(view) | Author: Karthikeyan Singaravelan (xtreak)*![]() | Date: 2019-08-01 12:10 | |
3.5 also seems to be affected. git cherry pick works and the patch fixes the problem so I assume the backport would be straightforward. Since 3.5 is open for security fixes with 3.5.8 as next release I am adding Larry.$ git cherry-pick a4a994bPerforming inexact rename detection: 100% (566740/566740), done.[detached HEAD9877e9283c]bpo-37461: Fix infinite loop in parsing of specially crafted email headers (GH-14794) Author: Abhilash Raj <maxking@users.noreply.github.com> Date: Wed Jul 17 09:44:27 2019 -0700 3 files changed, 12 insertions(+) create mode 100644bpo-37461.1Ahz7O.rst">Misc/NEWS.d/next/Security/2019-07-16-08-11-00.bpo-37461.1Ahz7O.rst | |||
| msg348867 -(view) | Author: Ned Deily (ned.deily)*![]() | Date: 2019-08-01 16:36 | |
New changeset1789bbdd3e03023951a39933ef12dee0a03be616 by Ned Deily (Miss Islington (bot)) in branch '3.6':bpo-37461: Fix infinite loop in parsing of specially crafted email headers (GH-14794) (GH-14817)https://github.com/python/cpython/commit/1789bbdd3e03023951a39933ef12dee0a03be616 | |||
| msg350344 -(view) | Author: Ned Deily (ned.deily)*![]() | Date: 2019-08-24 04:30 | |
New changeset799e4e527019d9429fdef12d08a0c03b08a1fb59 by Ned Deily (GeeTransit) in branch '3.7':[3.7]bpo-37461: Fix typo (inifite -> infinite) (GH-15430)https://github.com/python/cpython/commit/799e4e527019d9429fdef12d08a0c03b08a1fb59 | |||
| msg350345 -(view) | Author: Ned Deily (ned.deily)*![]() | Date: 2019-08-24 04:33 | |
New changesetf1f9c0c532089824791cfc18e6d6f29e1cd62596 by Ned Deily (GeeTransit) in branch '3.6':[3.6]bpo-37461: Fix typo (inifite -> infinite) (#15432)https://github.com/python/cpython/commit/f1f9c0c532089824791cfc18e6d6f29e1cd62596 | |||
| msg350346 -(view) | Author: Ned Deily (ned.deily)*![]() | Date: 2019-08-24 04:36 | |
xtreak, would you be willing to make the PR for 3.5? That will make it easier for Larry to decide whether to include it in a 3.5 security release. | |||
| msg350348 -(view) | Author: Abhilash Raj (maxking)*![]() | Date: 2019-08-24 04:56 | |
I manually created a backport PR for 3.5 and added Larry as a reviewer.https://github.com/python/cpython/pull/15446 | |||
| msg351289 -(view) | Author: Larry Hastings (larry)*![]() | Date: 2019-09-07 07:08 | |
New changesetc28e4a5160d3283b12514c7c28ed6e0a2a52271a by larryhastings (Abhilash Raj) in branch '3.5':[3.5]bpo-37461: Fix infinite loop in parsing of specially crafted email headers (GH-14794) (#15446)https://github.com/python/cpython/commit/c28e4a5160d3283b12514c7c28ed6e0a2a52271a | |||
| msg378396 -(view) | Author: Irit Katriel (iritkatriel)*![]() | Date: 2020-10-10 13:24 | |
This seems complete, can it be closed? | |||
| msg379027 -(view) | Author: Barry A. Warsaw (barry)*![]() | Date: 2020-10-19 21:45 | |
Thanks everyone for the fixes; I think this bug is now resolved. Closing. | |||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:17 | admin | set | github: 81642 |
| 2020-10-19 21:45:01 | barry | set | status: open -> closed resolution: fixed messages: +msg379027 stage: patch review -> resolved |
| 2020-10-13 00:53:21 | eamanu | set | nosy: +eamanu |
| 2020-10-10 13:24:20 | iritkatriel | set | nosy: +iritkatriel messages: +msg378396 |
| 2019-09-07 07:08:55 | larry | set | messages: +msg351289 |
| 2019-08-24 04:56:40 | maxking | set | messages: +msg350348 |
| 2019-08-24 04:55:44 | maxking | set | pull_requests: +pull_request15138 |
| 2019-08-24 04:36:26 | ned.deily | set | messages: +msg350346 |
| 2019-08-24 04:33:39 | ned.deily | set | messages: +msg350345 |
| 2019-08-24 04:33:24 | GeeTransit | set | pull_requests: +pull_request15137 |
| 2019-08-24 04:30:28 | ned.deily | set | messages: +msg350344 |
| 2019-08-24 04:29:50 | GeeTransit | set | pull_requests: +pull_request15136 |
| 2019-08-01 16:36:50 | ned.deily | set | nosy: +ned.deily messages: +msg348867 |
| 2019-08-01 12:10:44 | xtreak | set | nosy: +larry messages: +msg348850 versions: + Python 3.5 |
| 2019-07-17 17:14:11 | miss-islington | set | messages: +msg348072 |
| 2019-07-17 17:02:11 | miss-islington | set | nosy: +miss-islington messages: +msg348071 |
| 2019-07-17 16:45:28 | miss-islington | set | pull_requests: +pull_request14612 |
| 2019-07-17 16:44:55 | miss-islington | set | pull_requests: +pull_request14611 |
| 2019-07-17 16:44:48 | miss-islington | set | pull_requests: +pull_request14610 |
| 2019-07-17 16:44:41 | barry | set | messages: +msg348070 |
| 2019-07-17 15:04:05 | Guido | set | messages: +msg348064 |
| 2019-07-17 14:00:29 | maxking | set | messages: +msg348060 |
| 2019-07-16 15:08:58 | maxking | set | pull_requests: +pull_request14588 |
| 2019-07-15 09:36:17 | vstinner | set | files: +reproducer2.py |
| 2019-07-15 09:36:10 | vstinner | set | files: +reproducer.py nosy: +vstinner messages: +msg347953 |
| 2019-07-15 09:22:54 | vstinner | set | type: crash -> security |
| 2019-07-15 02:28:05 | Nam.Nguyen | set | nosy: +Nam.Nguyen |
| 2019-07-14 20:22:02 | alex | set | nosy: +alex |
| 2019-07-04 10:04:43 | Marcin Niemira | set | messages: +msg347263 |
| 2019-07-02 10:40:08 | n0npax | set | keywords: +patch stage: patch review pull_requests: +pull_request14369 |
| 2019-07-02 06:29:42 | xtreak | set | versions: + Python 3.6, Python 3.7, Python 3.8 nosy: +xtreak messages: +msg347108 keywords: +security_issue |
| 2019-07-01 13:07:10 | Marcin Niemira | set | nosy: +Marcin Niemira messages: +msg347014 |
| 2019-07-01 03:32:43 | xtreak | set | nosy: +maxking |
| 2019-07-01 03:21:13 | Guido | create | |