Skip to main content
Vulnerability Database/CVE-2024-12374

CVE-2024-12374: Automatic1111 Stable Diffusion XSS Vulnerability

CVE-2024-12374 is a stored cross-site scripting vulnerability in Automatic1111 Stable-diffusion-webui that allows attackers to execute malicious JavaScript through uploaded HTML files. This article covers technical details, affected versions, impact analysis, and mitigation strategies.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2024-12374 Overview

CVE-2024-12374 is a stored cross-site scripting (XSS) vulnerability in automatic1111/stable-diffusion-webui at git commit 82a973c. The application accepts user-uploaded HTML files and serves them back with a content type that browsers render as HTML. An attacker can upload a crafted HTML file containing JavaScript, then share the resulting link with a victim. When the victim opens the link, the attacker-controlled script executes in the victim's browser session against the Stable Diffusion WebUI origin. The flaw is tracked under CWE-79 and was reported through the Huntr bug bounty program.

Critical Impact

Attackers can execute arbitrary JavaScript in a victim's browser against the Stable Diffusion WebUI origin, enabling session theft, UI manipulation, and pivoting to local model management functions.

Affected Products

  • automatic1111 stable-diffusion-webui (git commit 82a973c)
  • Build dated 2024-07-27 per NVD CPE data
  • Deployments exposing the WebUI to multiple users or networks

Discovery Timeline

  • 2025-03-20 - CVE-2024-12374 published to the National Vulnerability Database
  • 2026-06-17 - Last updated in NVD database

Technical Details for CVE-2024-12374

Vulnerability Analysis

The vulnerability stems from how stable-diffusion-webui handles file uploads and subsequent file serving. The application allows a user to upload an HTML file and later retrieve it through an application-generated URL. When the file is served, the HTTP response declares a content type that browsers treat as HTML, so any <script> tags inside the uploaded document execute. This produces a stored XSS condition because the payload persists on the server and executes for every victim who follows the attacker-supplied link.

The stable-diffusion-webui project is widely self-hosted by individual users, hobbyist communities, and small teams running Gradio-based inference servers. Instances exposed on local networks, behind lightweight reverse proxies, or through tunneling services inherit the risk. A successful XSS payload runs under the WebUI origin, so it can read Gradio session state, trigger model management actions, and interact with any local plugin endpoints reachable from the browser.

Root Cause

The root cause is improper handling of upload MIME types combined with missing output sanitization during file retrieval. The server treats the file name or declared type as authoritative instead of forcing a safe content type such as text/plain or application/octet-stream with Content-Disposition: attachment. There is no HTML escaping or sandboxing applied before the browser renders the file.

Attack Vector

Exploitation requires network access to the WebUI and victim interaction. The attacker uploads an HTML file containing JavaScript through a legitimate upload path, obtains the resulting URL, and delivers it to a victim through chat, email, or a forum post. When the victim clicks the link, the browser renders the attacker's HTML and runs the embedded script in the context of the WebUI origin. No authentication is required on instances that expose uploads without access control.

// No verified proof-of-concept code is published for CVE-2024-12374.
// See the Huntr report for technical reproduction details:
// https://huntr.com/bounties/3dae386a-f442-4be6-87ef-956606c8a6ac

Detection Methods for CVE-2024-12374

Indicators of Compromise

  • Uploaded files with .html, .htm, or .svg extensions stored in WebUI upload or output directories
  • HTTP responses from the WebUI serving user-uploaded content with Content-Type: text/html or application/html
  • Outbound browser requests to attacker-controlled domains originating from sessions that previously accessed the WebUI

Detection Strategies

  • Inspect reverse proxy and application logs for GET requests to upload directories returning HTML content types
  • Scan the WebUI file store for user-submitted files whose contents contain <script>, onerror=, or javascript: payloads
  • Correlate unexpected administrative actions in the WebUI with recently opened upload URLs from the same browser session

Monitoring Recommendations

  • Alert when the WebUI serves non-image, non-model file types to browsers over the network
  • Monitor for new file uploads from unauthenticated or unexpected source addresses
  • Track browser process network connections from workstations that administer stable-diffusion-webui instances

How to Mitigate CVE-2024-12374

Immediate Actions Required

  • Restrict network exposure of stable-diffusion-webui by binding it to 127.0.0.1 or placing it behind authenticated access controls
  • Disable or restrict file upload endpoints for untrusted users until a fixed build is deployed
  • Review and remove any HTML, SVG, or script-bearing files already stored in WebUI upload directories

Patch Information

No vendor advisory URL is listed in the NVD entry at publication time. Monitor the automatic1111/stable-diffusion-webui GitHub repository for commits that constrain upload MIME handling and update to the latest release once a fix is published. Reference the Huntr Bug Bounty Report for the original disclosure.

Workarounds

  • Configure the reverse proxy to override responses for upload paths with Content-Type: text/plain and Content-Disposition: attachment
  • Enforce a Content Security Policy that blocks inline script execution and restricts script sources on the WebUI origin
  • Require authentication (for example, HTTP basic auth at the proxy) before any user can reach the WebUI or its upload endpoints
bash
# Example nginx snippet to neutralize served HTML uploads
location /file= {
    proxy_pass http://127.0.0.1:7860;
    proxy_hide_header Content-Type;
    add_header Content-Type "text/plain; charset=utf-8" always;
    add_header Content-Disposition "attachment" always;
    add_header Content-Security-Policy "default-src 'none'; sandbox;" always;
}

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.