CVE-2024-47872: Gradio: stored XSS via malicious file upload

GHSA-gvv6-33j7-884g MEDIUM
Published October 10, 2024
CISO Take

Any Gradio deployment allowing file uploads is vulnerable to stored XSS — an authenticated user (insider, contractor, or compromised account) can upload a malicious HTML/SVG/JS file that executes in the browser of any user who views it, enabling session hijacking and credential theft. Upgrade to gradio>=5.0.0 immediately; if you cannot patch, block uploads of HTML, SVG, and JavaScript file types at the server. Audit your internal ML tooling — Gradio is pervasive in data science teams and often runs with broader internal network access than its exposure suggests.

What is the risk?

Effective risk is higher than CVSS 5.4 suggests for AI-heavy organizations. Gradio is the de facto standard for ML model demos, internal evaluation interfaces, and collaborative prototyping — deployments frequently run on internal networks with access to model artifacts, training data, and infrastructure credentials. The authenticated requirement (PR:L) is a low bar: AI teams routinely share Gradio instances with contractors, partners, and large internal groups. EPSS of 0.0025 reflects limited public exploitation, but the attack requires no AI/ML expertise — any web attacker can exploit this. The real risk is lateral movement from a compromised Gradio session into ML infrastructure.

What systems are affected?

Package Ecosystem Vulnerable Range Patched
Gradio pip No patch
43.0K OpenSSF 5.6 685 dependents Pushed 4d ago 26% patched ~110d to patch Full package profile →
Gradio pip < 5.0.0 5.0.0
43.0K OpenSSF 5.6 685 dependents Pushed 4d ago 26% patched ~110d to patch Full package profile →

How severe is it?

CVSS 3.1
5.4 / 10
EPSS
0.3%
chance of exploitation in 30 days
Higher than 16% of all CVEs
Exploitation Status
No known exploitation
Sophistication
Trivial

What is the attack surface?

AV AC PR UI S C I A
AV Network
AC Low
PR Low
UI Required
S Changed
C Low
I Low
A None

What should I do?

6 steps
  1. Patch: upgrade to gradio>=5.0.0 — this is the only complete fix.

  2. If patching is blocked: restrict accepted MIME types server-side to images, CSV, and plain text; reject HTML, SVG, JS, and XML.

  3. Implement Content Security Policy (CSP) headers on all Gradio deployments to limit script execution scope.

  4. Audit existing uploaded files in your Gradio instance for malicious content (look for <script>, javascript:, onload= patterns in SVG/HTML files).

  5. Review who has upload access — reduce to minimum necessary.

  6. For detection: alert on uploads of HTML/SVG/JS file types; monitor for unusual session activity following file downloads.

What does CISA's SSVC say?

Decision Track
Exploitation none
Automatable Yes
Technical Impact partial

Source: CISA Vulnrichment (SSVC v2.0). Decision based on the CISA Coordinator decision tree.

How is it classified?

Which compliance frameworks are affected?

This CVE is relevant to:

EU AI Act
Article 15 - Accuracy, robustness and cybersecurity
ISO 42001
A.6.2.3 - AI system security testing and vulnerability management
NIST AI RMF
MANAGE 2.4 - Residual risks from AI system operation are managed
OWASP LLM Top 10
LLM07:2025 - System Prompt Leakage

Frequently Asked Questions

What is CVE-2024-47872?

Any Gradio deployment allowing file uploads is vulnerable to stored XSS — an authenticated user (insider, contractor, or compromised account) can upload a malicious HTML/SVG/JS file that executes in the browser of any user who views it, enabling session hijacking and credential theft. Upgrade to gradio>=5.0.0 immediately; if you cannot patch, block uploads of HTML, SVG, and JavaScript file types at the server. Audit your internal ML tooling — Gradio is pervasive in data science teams and often runs with broader internal network access than its exposure suggests.

Is CVE-2024-47872 actively exploited?

No confirmed active exploitation of CVE-2024-47872 has been reported, but organizations should still patch proactively.

How to fix CVE-2024-47872?

1. Patch: upgrade to gradio>=5.0.0 — this is the only complete fix. 2. If patching is blocked: restrict accepted MIME types server-side to images, CSV, and plain text; reject HTML, SVG, JS, and XML. 3. Implement Content Security Policy (CSP) headers on all Gradio deployments to limit script execution scope. 4. Audit existing uploaded files in your Gradio instance for malicious content (look for <script>, javascript:, onload= patterns in SVG/HTML files). 5. Review who has upload access — reduce to minimum necessary. 6. For detection: alert on uploads of HTML/SVG/JS file types; monitor for unusual session activity following file downloads.

What systems are affected by CVE-2024-47872?

This vulnerability affects the following AI/ML architecture patterns: ML prototyping platforms, model demo interfaces, internal AI tooling, model evaluation platforms, collaborative data annotation pipelines.

What is the CVSS score for CVE-2024-47872?

CVE-2024-47872 has a CVSS v3.1 base score of 5.4 (MEDIUM). The EPSS exploitation probability is 0.25%.

What is the AI security impact?

Affected AI Architectures

ML prototyping platformsmodel demo interfacesinternal AI toolingmodel evaluation platformscollaborative data annotation pipelines

MITRE ATLAS Techniques

AML.T0011 User Execution
AML.T0012 Valid Accounts
AML.T0025 Exfiltration via Cyber Means
AML.T0048.003 User Harm
AML.T0049 Exploit Public-Facing Application

Compliance Controls Affected

EU AI Act: Article 15
ISO 42001: A.6.2.3
NIST AI RMF: MANAGE 2.4
OWASP LLM Top 10: LLM07:2025

What are the technical details?

Original Advisory

Gradio is an open-source Python package designed for quick prototyping. This vulnerability involves **Cross-Site Scripting (XSS)** on any Gradio server that allows file uploads. Authenticated users can upload files such as HTML, JavaScript, or SVG files containing malicious scripts. When other users download or view these files, the scripts will execute in their browser, allowing attackers to perform unauthorized actions or steal sensitive information from their sessions. This impacts any Gradio server that allows file uploads, particularly those using components that process or display user-uploaded files. Users are advised to upgrade to `gradio>=5` to address this issue. As a workaround, users can restrict the types of files that can be uploaded to the Gradio server by limiting uploads to non-executable file types such as images or text. Additionally, developers can implement server-side validation to sanitize uploaded files, ensuring that HTML, JavaScript, and SVG files are properly handled or rejected before being stored or displayed to users.

Exploitation Scenario

A red-teamer or malicious insider with basic Gradio access uploads a crafted SVG file containing an embedded JavaScript payload to a shared model evaluation interface. The payload exfiltrates the document.cookie (session token) to an attacker-controlled endpoint via a fetch() call. When a senior ML engineer opens the file to review it, their session token is silently stolen. The attacker replays the token to access the Gradio backend, which has environment variables containing OpenAI/Anthropic API keys and S3 paths to proprietary fine-tuned model weights. No AI/ML expertise required — standard stored XSS tooling works out of the box.

Weaknesses (CWE)

CWE-79 — Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'): The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.

  • [Architecture and Design] Use a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid [REF-1482]. Examples of libraries and frameworks that make it easier to generate properly encoded output include Microsoft's Anti-XSS library, the OWASP ESAPI Encoding module, and Apache Wicket.
  • [Implementation, Architecture and Design] Understand the context in which your data will be used and the encoding that will be expected. This is especially important when transmitting data between different components, or when generating outputs that can contain multiple encodings at the same time, such as web pages or multi-part mail messages. Study all expected communication protocols and data representations to determine the required encoding strategies. For any data that will be output to another web page, especially any data that was received from external inputs, use the appropriate encoding on all non-alphanumeric characters. Parts of the same output document may require different encodings, which will vary depending on whether the output is in the: etc. Note that HTML Entity Encoding is only appropriate for the HTML body. Consult the XSS Prevention Cheat Sheet [REF-724] for more details on the types of encoding and escaping that are needed. HTML body Element attributes (such as src="XYZ") URIs JavaScript sections Casca

Source: MITRE CWE corpus.

CVSS Vector

CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N

Timeline

Published
October 10, 2024
Last Modified
January 21, 2025
First Seen
October 10, 2024

Related Vulnerabilities