This is incorrect. Python's tarfile and zipfile (and shutil) modules have no protection against directory traversal.
This is incorrect. Python's tarfile and zipfile (and shutil) modules have no protection against directory traversal.
> If a member filename is an absolute path, a drive/UNC sharepoint and leading (back)slashes will be stripped, e.g.: ///foo/bar becomes foo/bar on Unix, and C:\foo\bar becomes foo\bar on Windows. And all ".." components in a member filename will be removed, e.g.: ../../foo../../ba..r becomes foo../ba..r. On Windows illegal characters (:, <, >, |, ", ?, and *) replaced by underscore (_).
Sure reads like directory traversal mitigation.
While by itself this might be a deliberate design choice, it vows for an easy mistake.
I'm a fan of telling that a function is unsafe (by design) by its name. So `unsafeExtractall` or something like it. That should give a clear warning to investigate unless you know what you're doing.
See https://github.com/python/cpython/blob/3.6/Lib/zipfile.py
You're misreading the warning. It's saying that the module attempts to mitigate the issue (referring back to ZipFile.extract) but pointing out that this may not be entirely reliable, and thus that as the library user you really should inspect/validate archive paths before doing an on-disk extraction.
The tarfile module is still vulnerable: