Zip and similar.
WHAT PYTHON PROVIDES
Creating, reading and extracting common archive formats.
WHAT THIS SUITS
Packaging output Handling uploads that arrive compressed Backups Reducing transfer size
WHAT TO BE CAREFUL WITH WHEN EXTRACTING
Paths inside the archive, which may point outside the intended directory Total extracted size, which may be far larger than the archive Files overwriting existing ones
THE PATH POINT
An archive can contain entries with paths that escape the destination.
Validate every entry's destination before extracting.
That is a known attack.
THE SIZE POINT
A small archive can expand to an enormous size, exhausting disk or memory.
Check before extracting anything from outside.
WHAT TO DO WITH UNTRUSTED ARCHIVES
Validate entries Limit total size Extract to an isolated location
WHAT TO CHECK AFTER CREATING ONE
That it opens and contains what you expect.
WHAT TO AVOID
Extracting directly into a live directory Trusting filenames within an archive