The SentinelOne Annual Threat Report - A Defenders Guide from the FrontlinesThe SentinelOne Annual Threat ReportGet the Report
Experiencing a Breach?Blog
Get StartedContact Us
SentinelOne
  • Platform
    Platform Overview
    • Singularity Platform
      Welcome to Integrated Enterprise Security
    • AI for Security
      Leading the Way in AI-Powered Security Solutions
    • Securing AI
      Accelerate AI Adoption with Secure AI Tools, Apps, and Agents.
    • How It Works
      The Singularity XDR Difference
    • Singularity Marketplace
      One-Click Integrations to Unlock the Power of XDR
    • Pricing & Packaging
      Comparisons and Guidance at a Glance
    Data & AI
    • Purple AI
      Accelerate SecOps with Generative AI
    • Singularity Hyperautomation
      Easily Automate Security Processes
    • AI-SIEM
      The AI SIEM for the Autonomous SOC
    • AI Data Pipelines
      Security Data Pipeline for AI SIEM and Data Optimization
    • Singularity Data Lake
      AI-Powered, Unified Data Lake
    • Singularity Data Lake for Log Analytics
      Seamlessly Ingest Data from On-Prem, Cloud or Hybrid Environments
    Endpoint Security
    • Singularity Endpoint
      Autonomous Prevention, Detection, and Response
    • Singularity XDR
      Native & Open Protection, Detection, and Response
    • Singularity RemoteOps Forensics
      Orchestrate Forensics at Scale
    • Singularity Threat Intelligence
      Comprehensive Adversary Intelligence
    • Singularity Vulnerability Management
      Application & OS Vulnerability Management
    • Singularity Identity
      Identity Threat Detection and Response
    Cloud Security
    • Singularity Cloud Security
      Block Attacks with an AI-Powered CNAPP
    • Singularity Cloud Native Security
      Secure Cloud and Development Resources
    • Singularity Cloud Workload Security
      Real-Time Cloud Workload Protection Platform
    • Singularity Cloud Data Security
      AI-Powered Threat Detection for Cloud Storage
    • Singularity Cloud Security Posture Management
      Detect and Remediate Cloud Misconfigurations
    Securing AI
    • Prompt Security
      Secure AI Tools Across Your Enterprise
  • Why SentinelOne?
    Why SentinelOne?
    • Why SentinelOne?
      Cybersecurity Built for What’s Next
    • Our Customers
      Trusted by the World’s Leading Enterprises
    • Industry Recognition
      Tested and Proven by the Experts
    • About Us
      The Industry Leader in Autonomous Cybersecurity
    Compare SentinelOne
    • Arctic Wolf
    • Broadcom
    • CrowdStrike
    • Cybereason
    • Microsoft
    • Palo Alto Networks
    • Sophos
    • Splunk
    • Trellix
    • Trend Micro
    • Wiz
    Verticals
    • Energy
    • Federal Government
    • Finance
    • Healthcare
    • Higher Education
    • K-12 Education
    • Manufacturing
    • Retail
    • State and Local Government
  • Services
    Managed Services
    • Managed Services Overview
      Wayfinder Threat Detection & Response
    • Threat Hunting
      World-Class Expertise and Threat Intelligence
    • Managed Detection & Response
      24/7/365 Expert MDR Across Your Entire Environment
    • Incident Readiness & Response
      DFIR, Breach Readiness, & Compromise Assessments
    Support, Deployment, & Health
    • Technical Account Management
      Customer Success with Personalized Service
    • SentinelOne GO
      Guided Onboarding & Deployment Advisory
    • SentinelOne University
      Live and On-Demand Training
    • Services Overview
      Comprehensive Solutions for Seamless Security Operations
    • SentinelOne Community
      Community Login
  • Partners
    Our Network
    • MSSP Partners
      Succeed Faster with SentinelOne
    • Singularity Marketplace
      Extend the Power of S1 Technology
    • Cyber Risk Partners
      Enlist Pro Response and Advisory Teams
    • Technology Alliances
      Integrated, Enterprise-Scale Solutions
    • SentinelOne for AWS
      Hosted in AWS Regions Around the World
    • Channel Partners
      Deliver the Right Solutions, Together
    • SentinelOne for Google Cloud
      Unified, Autonomous Security Giving Defenders the Advantage at Global Scale
    • Partner Locator
      Your Go-to Source for Our Top Partners in Your Region
    Partner Portal→
  • Resources
    Resource Center
    • Case Studies
    • Data Sheets
    • eBooks
    • Reports
    • Videos
    • Webinars
    • Whitepapers
    • Events
    View All Resources→
    Blog
    • Feature Spotlight
    • For CISO/CIO
    • From the Front Lines
    • Identity
    • Cloud
    • macOS
    • SentinelOne Blog
    Blog→
    Tech Resources
    • SentinelLABS
    • Ransomware Anthology
    • Cybersecurity 101
  • About
    About SentinelOne
    • About SentinelOne
      The Industry Leader in Cybersecurity
    • Investor Relations
      Financial Information & Events
    • SentinelLABS
      Threat Research for the Modern Threat Hunter
    • Careers
      The Latest Job Opportunities
    • Press & News
      Company Announcements
    • Cybersecurity Blog
      The Latest Cybersecurity Threats, News, & More
    • FAQ
      Get Answers to Our Most Frequently Asked Questions
    • DataSet
      The Live Data Platform
    • S Foundation
      Securing a Safer Future for All
    • S Ventures
      Investing in the Next Generation of Security, Data and AI
  • Pricing
Get StartedContact Us
CVE Vulnerability Database
Vulnerability Database/CVE-2026-42138

CVE-2026-42138: Dify LLM Platform XSS Vulnerability

CVE-2026-42138 is a cross-site scripting flaw in Dify that allows unauthenticated users to upload malicious SVG files through file upload endpoints. This post covers the technical details, affected versions, and mitigation steps.

Published: May 7, 2026

CVE-2026-42138 Overview

CVE-2026-42138 is a stored Cross-Site Scripting (XSS) vulnerability [CWE-79] in Dify, an open-source large language model (LLM) application development platform. The flaw resides in two file upload endpoints: POST /api/files/upload and POST /v1/files/upload. Attackers can upload SVG files containing embedded JavaScript, which executes in the browser context of any user who later views the file. The unauthenticated endpoint POST /api/files/upload allows exploitation without credentials, expanding the attack surface to anonymous internet users. The issue affects all Dify releases prior to version 1.13.1 and is patched in that release.

Critical Impact

Unauthenticated attackers can upload malicious SVG files that execute arbitrary JavaScript in victim browsers, enabling session theft and account takeover within Dify deployments.

Affected Products

  • Dify versions prior to 1.13.1 (open-source LLM application platform by langgenius)
  • Dify deployments exposing POST /api/files/upload (unauthenticated path)
  • Dify deployments exposing POST /v1/files/upload (authenticated application API)

Discovery Timeline

  • 2026-05-04 - CVE-2026-42138 published to NVD
  • 2026-05-07 - Last updated in NVD database

Technical Details for CVE-2026-42138

Vulnerability Analysis

The vulnerability is a stored XSS [CWE-79] caused by improper handling of Scalable Vector Graphics (SVG) uploads. SVG is an XML-based image format that natively supports <script> elements and event handlers such as onload and onclick. When a server stores SVG content and serves it back with a Content-Type of image/svg+xml from a sensitive origin, browsers execute any embedded JavaScript in that origin's context.

Dify exposes two affected endpoints. POST /api/files/upload accepts uploads without authentication, allowing any anonymous network user to plant malicious payloads. POST /v1/files/upload requires an application API key but remains exploitable by any authenticated tenant. Once a target user navigates to the file URL, the payload runs with their privileges in the Dify origin.

Root Cause

The root cause is the absence of server-side sanitization and content-type restrictions on uploaded files. Dify accepts SVG content without stripping <script> tags or event handlers and serves the file inline rather than forcing download. The unauthenticated upload endpoint compounds the risk by removing the access control barrier that would normally limit who can introduce content into the platform.

Attack Vector

An attacker crafts an SVG file containing JavaScript inside a <script> element or an event-handler attribute on an SVG node. The attacker submits the file to POST /api/files/upload with no authentication, or to POST /v1/files/upload using a valid API key. The server stores the file and returns a URL. The attacker shares the URL or embeds it inside a Dify application, conversation, or knowledge base reference. When a victim's browser fetches the SVG with the response served as image/svg+xml, the embedded script executes within the Dify origin, exposing session cookies, API tokens stored in localStorage, and any in-page state. Refer to the GitHub Security Advisory GHSA-cg94-8v83-7hjj for additional technical details.

Detection Methods for CVE-2026-42138

Indicators of Compromise

  • HTTP POST requests to /api/files/upload or /v1/files/upload with Content-Type: image/svg+xml or filenames ending in .svg.
  • SVG files in Dify storage containing <script>, javascript: URIs, or event-handler attributes such as onload, onerror, or onclick.
  • Outbound browser requests from Dify users to unfamiliar domains immediately after rendering an uploaded asset.
  • Anomalous use of session tokens or API keys originating from IP addresses that do not match a user's normal pattern.

Detection Strategies

  • Inspect web server and reverse proxy access logs for upload requests against the two vulnerable endpoints, especially unauthenticated calls to /api/files/upload.
  • Scan stored uploads for SVG content containing scriptable elements using static analysis or YARA-style rules.
  • Deploy a Web Application Firewall (WAF) rule that inspects multipart upload bodies for SVG payloads carrying <script> tags or on* handlers.
  • Enable Content Security Policy (CSP) violation reporting to surface unexpected script execution on Dify pages.

Monitoring Recommendations

  • Alert on any HTTP 200 response to /api/files/upload from unauthenticated sources, since this endpoint should not be reachable on hardened deployments.
  • Track the volume and source diversity of SVG uploads and flag spikes from new IP ranges or user agents.
  • Correlate file-render events with subsequent privileged API calls from the same browser session to detect token theft.

How to Mitigate CVE-2026-42138

Immediate Actions Required

  • Upgrade Dify to version 1.13.1 or later, which contains the official fix for both upload endpoints.
  • Audit existing file storage for SVG files uploaded prior to patching and remove any containing scriptable content.
  • Rotate Dify session secrets and application API keys if exposure is suspected, since stored XSS can exfiltrate active credentials.
  • Restrict network exposure of /api/files/upload so the unauthenticated endpoint is not reachable from the public internet.

Patch Information

The maintainers released the fix in Dify 1.13.1. The patch addresses both POST /api/files/upload and POST /v1/files/upload. Administrators running self-hosted deployments should pull the updated container images or source release and redeploy. Operators should also review the GitHub Security Advisory GHSA-cg94-8v83-7hjj for upstream guidance.

Workarounds

  • Block SVG uploads at a reverse proxy by rejecting requests where Content-Type is image/svg+xml or filenames end in .svg until the patch is applied.
  • Force user-uploaded files to be served with Content-Disposition: attachment and a non-renderable Content-Type such as application/octet-stream.
  • Serve uploaded content from a sandbox domain isolated from the Dify session origin to contain XSS impact.
  • Apply a strict Content Security Policy that disallows inline scripts and restricts script sources to trusted origins.
bash
# Example NGINX rule blocking SVG uploads to vulnerable endpoints
location ~ ^/(api|v1)/files/upload$ {
    if ($request_method = POST) {
        if ($http_content_type ~* "image/svg\+xml") {
            return 415;
        }
    }
    proxy_pass http://dify_backend;
}

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

  • Vulnerability Details
  • TypeXSS

  • Vendor/TechDify

  • SeverityMEDIUM

  • CVSS Score6.9

  • EPSS Probability0.15%

  • Known ExploitedNo
  • CVSS Vector
  • CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:L/VA:N/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X
  • Impact Assessment
  • ConfidentialityLow
  • IntegrityNone
  • AvailabilityNone
  • CWE References
  • CWE-79
  • Technical References
  • GitHub Release 1.13.1

  • GitHub Security Advisory GHSA-cg94-8v83-7hjj
  • Related CVEs
  • CVE-2026-21866: Dify Stored XSS Vulnerability

  • CVE-2026-26023: Dify LLM Platform XSS Vulnerability

  • CVE-2026-41950: Dify Authorization Bypass Vulnerability

  • CVE-2026-34082: Dify Authorization Bypass Vulnerability
Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

Experience the World’s Most Advanced Cybersecurity Platform

See how our intelligent, autonomous cybersecurity platform can protect your organization now and into the future.

Try SentinelOne
  • Get Started
  • Get a Demo
  • Product Tour
  • Why SentinelOne
  • Pricing & Packaging
  • FAQ
  • Contact
  • Contact Us
  • Customer Support
  • SentinelOne Status
  • Language
  • Platform
  • Singularity Platform
  • Singularity Endpoint
  • Singularity Cloud
  • Singularity AI-SIEM
  • Singularity Identity
  • Singularity Marketplace
  • Purple AI
  • Services
  • Wayfinder TDR
  • SentinelOne GO
  • Technical Account Management
  • Support Services
  • Verticals
  • Energy
  • Federal Government
  • Finance
  • Healthcare
  • Higher Education
  • K-12 Education
  • Manufacturing
  • Retail
  • State and Local Government
  • Cybersecurity for SMB
  • Resources
  • Blog
  • Labs
  • Case Studies
  • Videos
  • Product Tours
  • Events
  • Cybersecurity 101
  • eBooks
  • Webinars
  • Whitepapers
  • Press
  • News
  • Ransomware Anthology
  • Company
  • About Us
  • Our Customers
  • Careers
  • Partners
  • Legal & Compliance
  • Security & Compliance
  • Investor Relations
  • S Foundation
  • S Ventures

©2026 SentinelOne, All Rights Reserved.

Privacy Notice Terms of Use

English