Skip to main content

safezipfile: A safe zipfile extract library for python

Summary

This library simply overrides the extractall method of the python ZipFile class with additional checks to prevent zip-slip and zip-bomb attacks. It can be used the same way as the usual extractall method but also accepts additional arguments to limit the number of allowed files in the archive, limit the size of each extract file, the total extracted file size and also the maximum allowed compression ratio (zip bombs have a very high compression ratio).

To make the base use case safe it already starts with some quite relaxed limits of:

  • 500 files in a zip
  • 1GB extracted file size
  • 10GB total extracted file size

But they can all be configured:

import safezipfile

# Base use case
with safezipfile.ZipFile("test.zip", "r") as zf:
    zf.extractall("./outdir")

# Or configure the limits
with safezipfile.ZipFile("test.zip", "r") as zf:
    zf.extractall(
        "./outdir", 
        max_files = 500, 
        max_file_size = 1 * 1024 * 1024 * 1024,
        max_total_size = 10 * 1024 * 1024 * 1024,
        max_compression_ratio = 150.0
    )

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

safezipfile-0.1.5.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

safezipfile-0.1.5-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file safezipfile-0.1.5.tar.gz.

File metadata

  • Download URL: safezipfile-0.1.5.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for safezipfile-0.1.5.tar.gz
Algorithm Hash digest
SHA256 28d48ed22a72aac9144a720ed662d80be1f36f0eebf9230d65c563d62bb1fdc0
MD5 9d697a3f84bca74da135b6a214dfedfe
BLAKE2b-256 2ec2ed54fbaaa9d9a454293403297b7916a55ed9a2184a3c0dd4880c732a6ed9

See more details on using hashes here.

File details

Details for the file safezipfile-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: safezipfile-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for safezipfile-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 cc8ca7d71fa45a463d601d4423a30e3ca2c1684e3b9921c888c817950194cd72
MD5 65742a23b67967c34fe5b22c03f2d78b
BLAKE2b-256 39890f12aef62a773a4703ca3bd4c06e3a5f7d4972f0725339e2596df86c8e3c

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.5 This release

2 files

0.1.4

1 file

0.1.3

1 file

0.0.0

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page