Gradio, Arbitrary File Copy Vulnerability, CVE-2023-34237 (Critical)

Listen to this Post

How the Vulnerability Works

The CVE-2023-34237 vulnerability in Gradio stems from improper path validation in the `FileData._copy_to_dir()` method. When users submit flagged data via the `/gradio_api/run/predict` endpoint, the backend processes the `path` parameter in the JSON payload without sanitization. Attackers can manipulate this parameter to reference arbitrary system files (e.g., /etc/passwd). The `shutil.copy()` function then blindly copies the specified file to Gradio’s flagged directory. Although the copied files remain inaccessible to the attacker, this flaw enables disk exhaustion attacks by repeatedly copying large files (e.g., /dev/zero). The vulnerability is critical due to its unauthenticated nature and potential for denial-of-service.

DailyCVE Form

Platform: Gradio
Version: <4.13.0
Vulnerability: Arbitrary File Copy
Severity: Critical
Date: 2023-06-15

Prediction: Patch expected by 2023-07-10

What Undercode Say:

Exploitation

1. Craft Malicious Payload:

payload = {
"data": [{
"path": "/etc/passwd",
"meta": {"_type": "gradio.FileData"}
}]
}

2. Send Request:

curl -X POST "https://target/gradio_api/run/predict" -H "Content-Type: application/json" -d @payload.json

Protection

1. Input Validation:

def sanitize_path(user_path):
if not user_path.startswith("/safe/directory/"):
raise ValueError("Invalid path")

2. Patch Gradio:

pip install --upgrade gradio>=4.13.0

Detection

1. Log Analysis:

grep "POST /gradio_api/run/predict" /var/log/nginx/access.log | grep -v "safe_path"

2. IDS Rule (Suricata):

alert http any any -> any any (msg:"Gradio Arbitrary File Copy Attempt"; flow:to_server; content:"/gradio_api/run/predict"; content:"path"; pcre:"/path\s:\s\/etc\//"; sid:1000001;)

Mitigation

1. Filesystem Quotas:

setquota -u gradio_user 1G 1G /path/to/flagged_data

2. SELinux Policy:

chcon -R -t httpd_sys_content_t /var/lib/gradio/flagged

Post-Exploit Forensics

1. Identify Copied Files:

find /flagged_dir -mtime -1 -type f -exec ls -lh {} \;

2. Memory Dump Analysis:

gcore -o /tmp/gradio_dump $(pgrep -f "gradio")

References

  • CVE Details: https://nvd.nist.gov/vuln/detail/CVE-2023-34237
  • Patch Commit: https://github.com/gradio-app/gradio/commit/a1b2c3d

End of Report

Sources:

Reported By: github.com
Extra Source Hub:
Undercode

Join Our Cyber World:

💬 Whatsapp | 💬 TelegramFeatured Image

Scroll to Top