A newly patched flaw in Python’s standard library could let a small zip file consume immense disk space and memory when extracted—and it’s now fixed. The Python Security Team has shipped updates across all supported CPython branches to close a loophole that allowed so-called "quoted-overlap" zip bombs to bypass earlier defenses. The vulnerability, tracked as CVE-2024-0450, affects the built-in zipfile module and has been rated medium severity with high availability impact.

When a Tiny Zip Hides a Monster

At its core, a zip bomb is a malicious archive that expands to a disproportionate size when unpacked, overwhelming the system handling it. For years, Python’s zipfile module had protections to reject simple overlapping entries where two files claimed the same data region. But researchers discovered a subtle variant—quoted overlap—that slipped through. By carefully manipulating ZIP metadata, an attacker could craft an archive where multiple entries pointed to overlapping or identical compressed bytes, yet the module would naively trust the declared sizes and attempt to decompress them. The result: a tiny archive could produce gigabytes of output, exhausting disk or memory.

The fix, delivered in CPython’s maintenance releases, adds rigorous boundary checks. Now, when zipfile detects that an entry’s compressed data region overlaps another entry or the central directory, it immediately raises a BadZipFile exception and refuses to proceed. The update also includes fresh test cases to prevent regressions—one for full overlaps and another specifically for the quoted-overlap trick.

Patch Details and Versions

The vulnerability was raised in GitHub issue #109858 and quickly addressed by pull request #110016. The fix landed in the CPython repository on January 16, 2024, and was then cherry-picked into every supported release branch. Distribution vendors—including Ubuntu, Debian, SUSE, and Amazon Linux—have also released their own patched packages.

The following table lists the first fixed micro-versions for each CPython series. If you’re running an older micro within a series, upgrade to at least the version shown. Always confirm with python --version and your platform’s package listings.

CPython Series Minimum Patched Version
3.12.x 3.12.2
3.11.x 3.11.8
3.10.x 3.10.14
3.9.x 3.9.19
3.8.x 3.8.19

Windows users who installed Python from the Microsoft Store or python.org will receive these updates through those channels. For Python embedded in third-party applications (e.g., GIS tools, backup software), you’ll need to check the vendor’s advisory—some ship with a frozen version that may remain vulnerable until the vendor issues an update.

Why Your System Might Be Exposed

The flaw requires an attacker to deliver a malicious ZIP and have the victim’s Python code extract it—so it’s not a remote code execution threat. Yet it poses a tangible denial-of-service risk, especially in automated environments. Here’s how the impact breaks down by user type:

  • Windows home users and enthusiasts: If you occasionally run Python scripts that open ZIPs—like a data processing utility you downloaded—the risk is limited but real. An unknowingly opened zip bomb could fill your disk or crash the script. Update your Python installation to be safe.
  • Developers and data engineers: The real danger lies in code you haven’t reviewed. Web applications, machine learning pipelines, or ETL jobs that call zipfile.extractall() on user-supplied files are prime targets. An attacker could upload a malicious archive and bring your service to a halt. Immediate patching is critical.
  • IT admins and DevOps: Servers running Python-based services—like CI runners, content scanners, or email gateways—face the highest exposure. An automated process ingesting a weaponized ZIP could lock up system resources, leading to prolonged outages. Many appliances and management tools embed CPython; confirm with vendors that patches have been applied.
  • Enterprise environments: Systems that process files from external sources—malware analysis sandboxes, archive inspection tools, backup agents—must be updated. The attack vector is local, but email attachments, file uploads, and shared drives can all carry the payload.

For all, the CVE’s CVSS v3 score of 6.2 reflects the need for user interaction and local execution, but the high availability impact means a single incident could cause significant disruption. A real-world scenario: an email gateway that auto-extracts attachments could be taken down by a single carefully crafted message from a malicious sender.

How to Defend Against Zip Bombs—Now and Later

Patching is step one, but defense-in-depth is essential for any system that handles untrusted archives. Follow these prioritized actions:

  1. Inventory your Python footprint. Run python --version on all machines, or use where python on Windows to find multiple installations. Don’t forget virtual environments, containers, and bundled interpreters in applications.

  2. Update immediately. Head to python.org/downloads and grab the latest micro for your major version, or use the Microsoft Store if you originally installed from there. For servers, use your system package manager (e.g., apt upgrade python3 on Linux, or winget upgrade Python.Python.3.12 on Windows 10/11). Always test upgrades in a staging environment first if possible.

  3. For developers, harden your code:
    - Avoid using extractall() on untrusted archives. Instead, inspect the namelist() and headers manually, and extract files one by one to a temporary directory with a size quota.
    - Wrap extraction calls in try/except blocks that catch BadZipFile and log the incident.
    - Validate the reported compressed and uncompressed sizes before extraction; reject archives with ratios above a sensible threshold (e.g., 100x) or entries claiming unachievably high compression.

  4. For administrators, apply runtime controls:
    Even after patching, limit the blast radius:
    - Run archive processing in a temporary container or sandboxed process with strict disk quotas and memory limits (ulimit on Unix, Windows Job Objects via PowerShell).
    - Set timeouts on extraction operations; if a zip takes more than a few seconds per megabyte, abort it.
    - Monitor for sudden spikes in disk I/O or unexpected file creation using built-in tools like Windows Performance Monitor or Linux’s iotop.

  5. Detect and respond: Log all BadZipFile exceptions and track extraction metrics. An unhandled exception or a sudden resource spike may indicate an attempted attack. Isolate the offending file for forensics, but do not reopen it outside a controlled environment.

A Persistent Challenge

Zip bombs are a perennial cat-and-mouse game, and this patch addresses one specific technique. Attackers will undoubtedly probe for new metadata quirks that bypass the updated checks. The Python community’s swift response—fixing the flaw within days and pushing coordinated releases—is commendable, but the onus remains on downstream users to actually apply the updates.

In the near term, watch for notices from appliance vendors and software distributors who may lag in incorporating the patch. The broader lesson endures: treat every archive from an untrusted source as hostile. With the fix in place, you can now do so with one less vulnerability to worry about—as long as you update.