This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author nandiya
Recipients nandiya
Date 2013-12-27.02:11:15
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1388110280.6.0.508484621949.issue20078@psf.upfronthosting.co.za>
In-reply-to
Content
I am using the zipfile module on a webserver which provides a service which processes files in zips uploaded by users, while hardening against zip bombs, I tried binary editing a zip to put in false file size information. The result is interesting, when with a ZIP_STORED file, or with carefully crafted ZIP_DEFLATED file (and perhaps ZIP_BZIP2 and ZIP_LZMA for craftier hackers than I), when the stated file size exceeds the size of the archive itself, ZipExtFile.read goes into an infinite loop, consuming 100% CPU.

The following methods on such an archive all result in an infinite loop:
ZipExtFile.read
ZipExtFile.read(n)
ZipExtFile.readlines
ZipFile.extract
ZipFile.extractall


ZipExtFile.read1 silently returns corrupt data but does not hang.

Obviously the module doesn't need to bend over backwards to deal gracefully with deliberately and maliciously crafted input, since all the user hopes for is to bring the program crashing down, but the 100% CPU infinite loop is probably one of the less satisfactory possible failure modes. It should either raise an exception or do something like read1 and silently return corrupt data.

This is low priority except for security since unless a zip is maliciously crafted some kind of exception will almost certainly be raised due to a decompression or invalid zip exception.
History
Date User Action Args
2013-12-27 02:11:20nandiyasetrecipients: + nandiya
2013-12-27 02:11:20nandiyasetmessageid: <1388110280.6.0.508484621949.issue20078@psf.upfronthosting.co.za>
2013-12-27 02:11:20nandiyalinkissue20078 messages
2013-12-27 02:11:19nandiyacreate