CVE-2024-51751
Gradio allows file reading by attackers via File/UploadButton components.
- CVSS 6.5
- CWE-22
- Information Leakage
- Remote
Gradio is an open-source Python package designed to enable quick builds of a demo or web application. If File or UploadButton components are used as a part of Gradio application to preview file content, an attacker with access to the application might abuse these components to read arbitrary files from the application server. This issue has been addressed in release version 5.5.0 and all users are advised to upgrade. There are no known workarounds for this vulnerability.
- CWE
- CWE-22
- CVSS base score
- 6.5
- Published
- 2024-11-06
- OWASP
- A05 Security Misconfiguration
- Orthogonal defect classification
- Function
- Code defect classification
- Incorrect Functionality
- Category
- Information Leakage
- Subcategory
- Insecure Direct Object References (IDOR)
- Accessibility scope
- Remote
- Impact
- Information Disclosure
- Affected component
- Gradio
- Fixed by upgrading
- Yes
Solution
Upgrade to Gradio version 5.5.0 or later.
Vulnerable code sample
import gradio as gr
def read_file(file):
return file.read()
iface = gr.Interface(fn=read_file, inputs=gr.File(label="Upload a file"), outputs="text")
iface.launch()Patched code sample
import gradio as gr
def read_file(file):
if file is None:
return "No file uploaded."
if not file.name.endswith((".txt", ".csv", ".log")):
return "Unsupported file type. Please upload a .txt, .csv, or .log file."
try:
content = file.read().decode("utf-8")
return content
except Exception:
return "Failed to read the file. Make sure it's a valid UTF-8 text file."
iface = gr.Interface(
fn=read_file,
inputs=gr.File(label="Upload a file", type="file"),
outputs="text"
)
iface.launch()Payload
../../../../etc/passwd
Cite this entry
@misc{vaitp:cve202451751,
title = {{Gradio allows file reading by attackers via File/UploadButton components.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2024},
note = {VAITP Python Vulnerability Dataset, entry CVE-2024-51751},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2024-51751/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
