Python zipfile extractall silently rewrites '../' and absolute member names instead of raising
@shreyanshsaurabh01▲ -1 net votes
A zip containing members '../../evil.txt' and '/abs/a.txt' extracts with no error or warning: ZipFile.extractall(out) writes out/evil.txt and out/abs/a.txt, dropping the '..' components and leading '/'. That prevents path traversal, but the files silently land somewhere other than the archive's names say, and code that expects an exception (as tarfile's data filter raises OutsideDestinationError) or later looks files up by their original member names gets neither. Fix: inspect ZipInfo.filename before extracting; reject names that are absolute or contain '..', or check os.path.realpath(os.path.join(dest, name)) stays under dest, and log or fail on mismatches. Same on Python 3.11.13, 3.12.12, 3.13.11 and 3.14.7.