Closed 2561c9ff-0f70-435b-bb88-00745062670a closed 10 years ago
On a WinZip AES-256 encrypted zip, zipfile.extractall raises a RuntimeError for "Bad password for file" when given the correct password. Command line example below:
Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from zipfile import ZipFile
>>> zip = ZipFile("example.zip", "r")
>>> zip.extractall(".", pwd="cat")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.6/zipfile.py", line 935, in extractall
self.extract(zipinfo, path, pwd)
File "/usr/lib/python2.6/zipfile.py", line 923, in extract
return self._extract_member(member, path, pwd)
File "/usr/lib/python2.6/zipfile.py", line 963, in _extract_member
source = self.open(member, pwd=pwd)
File "/usr/lib/python2.6/zipfile.py", line 898, in open
raise RuntimeError("Bad password for file", name)
RuntimeError: ('Bad password for file', <zipfile.ZipInfo object at 0xb739e26c>)
>>>
zipfile only supports the "Traditional PKWARE Encryption" method. Support for other encryption methods would be useful.
Do note that providing a patch first requires that encryption/decryption facilities be made available in the stdlib. (right now we only offer hashing, and "high-level" socket wrapping)
bpo-8998 has been closed (among others due to legal concerns), so this need not be kept open.
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: ```python assignee = None closed_at =
created_at =
labels = ['type-feature', 'library']
title = 'zipfile cannot read AES encrypted files'
updated_at =
user = 'https://bugs.python.org/aymill'
```
bugs.python.org fields:
```python
activity =
actor = 'georg.brandl'
assignee = 'none'
closed = True
closed_date =
closer = 'georg.brandl'
components = ['Library (Lib)']
creation =
creator = 'aymill'
dependencies = ['8998']
files = ['17872']
hgrepos = []
issue_num = 9170
keywords = []
message_count = 4.0
messages = ['109342', '109385', '109650', '199933']
nosy_count = 4.0
nosy_names = ['georg.brandl', 'amaury.forgeotdarc', 'pitrou', 'aymill']
pr_nums = []
priority = 'normal'
resolution = 'wont fix'
stage = 'needs patch'
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue9170'
versions = ['Python 3.2']
```