Denial of Service Vulnerability in Python's zipfile Module

python2.7 Updated 02 Oct 2025

Summary

04/02/2020
N/A
No i
High
7.5

CVE-2019-9674: Lib/zipfile.py in Python through 3.7.2 allows remote attackers to cause a denial of service (resource consumption) via a ZIP bomb. Affects python2.7 versions < 9a3ffc0492d1310ead9ce8f5ee678c26b20a338d. No fix is published. How to fix ↓

Free scan

Check if this vulnerability affects your application

Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.

Check my app free

No signup required · Results in about 60 seconds

Upload your dependency manifest or SBOM

Drag & drop your file here or

Java Javascript PHP Python Go Rust Ruby Dart C/C++ Elixir CycloneDX SPDX

Upload a supported dependency manifest or SBOM. No installation or source-code access required.

See supported files and SBOM formats
SBOM sbom.json · bom.json · bom.xml · *.spdx.json · *.cdx.json · *.cdx.xml
Java pom.xml · gradle.lockfile · buildscript-gradle.lockfile
Javascript package-lock.json · yarn.lock · pnpm-lock.yaml
PHP composer.lock
Python poetry.lock · requirements.txt · Pipfile.lock
Go go.mod
Rust Cargo.lock
Ruby Gemfile.lock
Dart pubspec.lock
C/C++ conan.lock
Elixir mix.lock
Enter your work email to receive your report link.

Verify your email to view the full report and start 30 days of continuous monitoring. No credit card required.

Sponsored Devnack Your last release was probably never penetration tested Manual testing by engineers who build software, not an auditor's checklist. Trusted by teams at Swift and Google Talk to Devnack

Background

Python is a popular programming language known for its simplicity and versatility. It provides a standard library that includes various modules for different functionalities. One such module is 'zipfile', which allows users to work with ZIP archives. This vulnerability affects Python versions up to 3.7.2 and can be exploited remotely to cause a denial of service (DoS) attack by consuming excessive system resources. The vulnerability resides in the 'Lib/zipfile.py' file.

Vulnerability Detail

The vulnerability, identified as CVE-2019-9674, originates from the way Python's 'zipfile' module handles ZIP archives. By crafting a malicious ZIP bomb, an attacker can trigger resource exhaustion on the target system. This can lead to system instability, unresponsiveness, or even a complete system crash. The severity of this vulnerability is rated as 'High' with a CVSS score of 7.5.

How To Fix

No fixed version is published for this vulnerability.

Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →

Workaround

As a workaround, users can implement input validation and limit the size of ZIP archives processed by the 'zipfile' module. By setting a reasonable threshold for the maximum allowed size, the risk of resource exhaustion can be reduced. Here is an example of how to limit the size of a ZIP archive in Python:

import zipfile

def extract_zip(file_path):
    max_size = 1024 * 1024  # Maximum allowed size in bytes
    with zipfile.ZipFile(file_path) as zip_file:
        if zip_file.infolist()[0].file_size > max_size:
            raise ValueError('ZIP archive exceeds the maximum allowed size')
        zip_file.extractall()

In this example, the 'extract_zip' function checks the size of the first file in the ZIP archive and raises an exception if it exceeds the specified threshold.

Conclusion

The vulnerability in Python's 'zipfile' module allows remote attackers to cause a denial of service (DoS) by exploiting a ZIP bomb. It is crucial to update Python to a version beyond 3.7.2 to mitigate this vulnerability. Implementing input validation and size limitations for ZIP archives can serve as a temporary workaround. For further assistance in vulnerability remediation, please contact DevNack.com.

See every vulnerability recorded for python2.7 →

Share this vulnerability

FAQ

This vulnerability can be exploited remotely to cause a denial of service (DoS) attack by consuming excessive system resources. It can lead to system instability, unresponsiveness, or even a complete system crash.

Python versions up to 3.7.2 are affected by this vulnerability.

Yes, the Python development team has addressed this vulnerability in subsequent releases. Users should upgrade to a version beyond 3.7.2 to ensure the vulnerability is mitigated.

Yes, users can implement input validation and limit the size of ZIP archives processed by the 'zipfile' module. By setting a reasonable threshold for the maximum allowed size, the risk of resource exhaustion can be reduced.

The CVSS score of this vulnerability is 7.5, indicating a 'High' severity level.

Related vulnerabilities

Recent vulnerabilities recorded for python2.7.

How To Fix

No fixed version is published for this vulnerability.

Tip — Not sure whether your app is affected? Vulert can check the versions your app actually runs. Scan free →

Subscribe to Vulert on Telegram
Daily digest of new CVEs, critical and high severity, affected packages and fixes — plus a weekly roundup.
Join the channel →
Help improve this record
Report an issue or send feedback