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-39017 Fix infinite loop in the tarfile module #21454
Conversation
Add a check for length = 0 in the _proc_pax function to avoid running into an infinite loop
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.
Could you note the CVE number that got assigned to this flaw?
Misc/NEWS.d/next/Library/2020-07-12-22-16-58.bpo-39017.x3Cg-9.rst
Outdated
Show resolved
Hide resolved
Lib/test/test_tarfile.py
Outdated
def test_length_zero_header(self): | ||
with self.assertRaisesRegex(tarfile.ReadError, "file could not be opened successfully"): | ||
with tarfile.open(support.findfile('recursion.tar')) as tar: | ||
tar.getmembers() |
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.
I think this tar.getmembers()
can be replaced with pass
since it should never be called. Or you can call tarfile.is_tarfile
instead of with tarfile.open...
. Feel free to ignore this comment.
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.
Thank you for the comment, I replaced the tar.getmembers()
with pass
as you suggested
Add relevant CVE number in inline comments Co-authored-by: Petr Viktorin <encukou@gmail.com>
Replace code that is never called with pass in tarfile testcase
Thank you! |
Avoid infinite loop when reading specially crafted TAR files using the tarfile module (CVE-2019-20907). (cherry picked from commit 5a8d121) Co-authored-by: Rishi <rishi_devan@mail.com>
GH-21482 is a backport of this pull request to the 3.9 branch. |
Avoid infinite loop when reading specially crafted TAR files using the tarfile module (CVE-2019-20907). (cherry picked from commit 5a8d121) Co-authored-by: Rishi <rishi_devan@mail.com>
GH-21483 is a backport of this pull request to the 3.8 branch. |
GH-21484 is a backport of this pull request to the 3.7 branch. |
GH-21485 is a backport of this pull request to the 3.6 branch. |
Avoid infinite loop when reading specially crafted TAR files using the tarfile module (CVE-2019-20907). (cherry picked from commit 5a8d121) Co-authored-by: Rishi <rishi_devan@mail.com>
Avoid infinite loop when reading specially crafted TAR files using the tarfile module (CVE-2019-20907). (cherry picked from commit 5a8d121) Co-authored-by: Rishi <rishi_devan@mail.com>
Thank you everyone, for this opportunity |
…GH-21482) Avoid infinite loop when reading specially crafted TAR files using the tarfile module (CVE-2019-20907). (cherry picked from commit 5a8d121) Co-authored-by: Rishi <rishi_devan@mail.com> Automerge-Triggered-By: @encukou
…GH-21483) Avoid infinite loop when reading specially crafted TAR files using the tarfile module (CVE-2019-20907). (cherry picked from commit 5a8d121) Co-authored-by: Rishi <rishi_devan@mail.com> Automerge-Triggered-By: @encukou
…1484) Avoid infinite loop when reading specially crafted TAR files using the tarfile module (CVE-2019-20907). (cherry picked from commit 5a8d121) Co-authored-by: Rishi <rishi_devan@mail.com>
Avoid infinite loop when reading specially crafted TAR files using the tarfile module (CVE-2019-20907). (cherry picked from commit 5a8d121) Co-authored-by: Rishi <rishi_devan@mail.com>
Avoid infinite loop when reading specially crafted TAR files using the tarfile module (CVE-2019-20907). (cherry picked from commit 5a8d121) Co-authored-by: Rishi <rishi_devan@mail.com>
…#21489) Avoid infinite loop when reading specially crafted TAR files using the tarfile module (CVE-2019-20907). (cherry picked from commit 5a8d121) Co-authored-by: Rishi <rishi_devan@mail.com>
Avoid infinite loop when reading specially crafted TAR files using the tarfile module (CVE-2019-20907).
Avoid infinite loop when reading specially crafted TAR files using the tarfile module (CVE-2019-20907).
Avoid infinite loop when reading specially crafted TAR files using the tarfile module (CVE-2019-20907).
Avoid infinite loop when reading specially crafted TAR files using the tarfile module (CVE-2019-20907).
Add a check for length = 0 in the _proc_pax function to avoid running into an infinite loop
https://bugs.python.org/issue39017