Repository navigation
Closed
Labels
3.10 (EOL)end of life3.7 (EOL)end of life3.8 (EOL)end of life3.9 (EOL)end of lifetype-securityA security issue
Description
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee = None
closed_at = <Date 2020-07-16.19:49:38.415>
created_at = <Date 2019-12-10.16:19:56.633>
labels = ['type-security', '3.7', '3.8', '3.9', '3.10']
title = '[CVE-2019-20907] Infinite loop in the tarfile module'
updated_at = <Date 2020-08-03.10:07:01.350>
user = 'https://bugs.python.org/jvoisin'bugs.python.org fields:
activity = <Date 2020-08-03.10:07:01.350>
actor = 'vstinner'
assignee = 'none'
closed = True
closed_date = <Date 2020-07-16.19:49:38.415>
closer = 'larry'
components = []
creation = <Date 2019-12-10.16:19:56.633>
creator = 'jvoisin'
dependencies = []
files = ['48768', '49309']
hgrepos = []
issue_num = 39017
keywords = ['patch']
message_count = 17.0
messages = ['358200', '373339', '373341', '373468', '373473', '373577', '373632', '373681', '373683', '373684', '373685', '373686', '373687', '373688', '373689', '373764', '373972']
nosy_count = 11.0
nosy_names = ['lars.gustaebel', 'larry', 'ned.deily', 'petr.viktorin', 'ethan.furman', 'mgorny', 'serhiy.storchaka', 'miss-islington', 'bc', 'jvoisin', 'rishi93']
pr_nums = ['21454', '21482', '21483', '21484', '21485', '21489']
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'security'
url = 'https://bugs.python.org/issue39017'
versions = ['Python 3.5', 'Python 3.6', 'Python 3.7', 'Python 3.8', 'Python 3.9', 'Python 3.10']Metadata
Metadata
Assignees
Labels
3.10 (EOL)end of life3.7 (EOL)end of life3.8 (EOL)end of life3.9 (EOL)end of lifetype-securityA security issue
Activity
jvoisin commentedon Dec 10, 2019
While playing with fuzzing and Python, I stumbled upon an infinite loop in Python's tarfile module: just open the attached file with
tarfile.open('timeout-a52710a313fdb35fb428c3399277cb640fe2f686'), and Python will be endlessly stuck in the_proc_paxfunction in tarfile.py, likely due to a missing check oflengthbeing strictly superior to zero.bcaller commentedon Jul 8, 2020
I've attached a minimal tar file which reproduces this. I think the minimum length is 516 bytes.
We need a 512 byte PAX format header block as normal.
Then we need a pax header which matches the regex in
cpython/Lib/tarfile.py
Line 1243 in b26a0db
We use the
lengthvariable to iterate:cpython/Lib/tarfile.py
Line 1271 in b26a0db
So we can start the block with "0 X=". This makes length=0. So it will increment pos by 0 each loop and loop the same code forever.
Nice find.
Do you think this denial of service is worth requesting a CVE for? If so, can someone else do it.
bcaller commentedon Jul 8, 2020
A smaller bug: If instead of 0 you use a large number (> 2^63) e.g. 9999999999999999999 you get
OverflowError: Python int too large to convert to C ssize_trather than the expectedtarfile.ReadErrorregardless of errorlevel.rishi93 commentedon Jul 10, 2020
Hi ! I would like to start contributing to CPython. Can I start working on this issue ?
ethanfurman commentedon Jul 10, 2020
Absolutely!
But first, you'll need to sign the Contributor License Agreement:
https://www.python.org/psf/contrib/contrib-form/
Thank you for your help!
rishi93 commentedon Jul 12, 2020
Thank you. I have signed the CLA agreement. I have pushed my code changes and also written a testcase for this issue
jvoisin commentedon Jul 14, 2020
CVE-2019-20907 has been assigned to this issue.
encukou commentedon Jul 15, 2020
New changeset 5a8d121 by Rishi in branch 'master':
bpo-39017: Avoid infinite loop in the tarfile module (GH-21454)
5a8d121
encukou commentedon Jul 15, 2020
Larry and Ned, do you want this fix in the security-only releases you manage?
PRs for 3.6 ad 3.7 are ready, should you wish to merge them.
miss-islington commentedon Jul 15, 2020
New changeset f323229 by Miss Islington (bot) in branch '3.9':
[3.9] bpo-39017: Avoid infinite loop in the tarfile module (GH-21454) (GH-21482)
f323229
miss-islington commentedon Jul 15, 2020
New changeset c554795 by Miss Islington (bot) in branch '3.8':
[3.8] bpo-39017: Avoid infinite loop in the tarfile module (GH-21454) (GH-21483)
c554795
2 remaining items
ned-deily commentedon Jul 15, 2020
New changeset 47a2955 by Miss Islington (bot) in branch '3.6':
bpo-39017: Avoid infinite loop in the tarfile module (GH-21454) (bpo-21485)
47a2955
ned-deily commentedon Jul 15, 2020
Thanks, the PRs for 3.7 and 3.6 are now merged.
larryhastings commentedon Jul 16, 2020
New changeset cac9ca8 by Petr Viktorin in branch '3.5':
[3.5] bpo-39017: Avoid infinite loop in the tarfile module (GH-21454) (bpo-21489)
cac9ca8
mgorny commentedon Jul 19, 2020
Given that a CVE was assigned for this, I think it'd be better if the news were in the 'Security' category and not 'Library'.
[-]Infinite loop in the tarfile module[/-][+][CVE-2019-20907] Infinite loop in the tarfile module[/+][-]Infinite loop in the tarfile module[/-][+][CVE-2019-20907] Infinite loop in the tarfile module[/+]