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
    • 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-21866

CVE-2026-21866: Dify Stored XSS Vulnerability

CVE-2026-21866 is a stored XSS flaw in Dify that allows malicious code execution through Mermaid diagrams. This article covers the technical details, affected versions prior to 1.11.2, security impact, and mitigation.

Published: March 6, 2026

CVE-2026-21866 Overview

CVE-2026-21866 is a stored Cross-Site Scripting (XSS) vulnerability affecting Dify, an open-source LLM (Large Language Model) application development platform. The vulnerability exists in the Mermaid diagram rendering functionality within the chat interface. Due to an insecure default configuration where Dify uses securityLevel: loose for Mermaid diagrams, attackers can inject and execute malicious scripts that persist within chat conversations.

Critical Impact

Authenticated attackers can inject persistent malicious scripts through Mermaid diagrams in chat interfaces, potentially leading to session hijacking, credential theft, or unauthorized actions on behalf of other users.

Affected Products

  • Dify versions prior to 1.11.2
  • Dify LLM application development platform (all deployments with default Mermaid configuration)
  • Self-hosted and cloud-based Dify installations with chat functionality enabled

Discovery Timeline

  • 2026-03-03 - CVE CVE-2026-21866 published to NVD
  • 2026-03-05 - Last updated in NVD database

Technical Details for CVE-2026-21866

Vulnerability Analysis

This stored XSS vulnerability stems from insecure configuration of the Mermaid diagramming library within Dify's chat rendering pipeline. Mermaid is a JavaScript-based tool that renders text-based diagram definitions into visual diagrams. When Dify processes chat messages containing Mermaid diagram syntax, it uses the securityLevel: loose configuration option, which disables critical security protections designed to prevent script execution.

The vulnerability allows an authenticated attacker to craft a malicious Mermaid diagram definition that, when rendered by the application, executes arbitrary JavaScript code in the context of other users viewing the chat. Because this is a stored XSS vulnerability, the malicious payload persists in the chat history and executes each time a user views the affected conversation.

The attack requires low complexity to execute but does require user interaction—a victim must view the chat containing the malicious diagram. The primary impact is on the confidentiality and integrity of other users' sessions within the Dify platform.

Root Cause

The root cause of CVE-2026-21866 is an insecure default configuration choice in Dify's Mermaid integration. The Mermaid library provides multiple security levels:

  • strict - Prevents all potentially dangerous content
  • loose - Allows click functionality and other potentially unsafe features
  • antiscript - Allows click functionality but sanitizes script-like content
  • sandbox - Renders diagrams in an isolated iframe

Dify's implementation defaulted to securityLevel: loose, which permits inline event handlers and other mechanisms that can execute JavaScript. This configuration decision prioritized functionality over security, allowing attackers to bypass content security measures that would otherwise prevent script injection through diagram rendering.

Attack Vector

The attack is network-based and exploits the Mermaid diagram rendering feature within Dify's chat interface. An authenticated attacker with access to a Dify workspace can inject a specially crafted Mermaid diagram containing malicious JavaScript payloads. The diagram syntax supports click handlers and callbacks that, under the loose security level, execute when rendered.

When other users in the same workspace view the chat conversation containing the malicious diagram, the embedded JavaScript executes in their browser context. This can be leveraged to steal session tokens, perform actions on behalf of the victim, redirect users to phishing pages, or exfiltrate sensitive data from the application.

The attack persists because chat messages are stored server-side, meaning the malicious payload affects all users who subsequently view the compromised conversation without requiring the attacker to maintain an active presence.

Detection Methods for CVE-2026-21866

Indicators of Compromise

  • Chat messages containing Mermaid diagram syntax with embedded click handlers, event attributes, or JavaScript URIs
  • Unexpected network requests originating from chat interface pages to external domains
  • Session token exfiltration attempts or unauthorized API calls correlating with chat viewing activity
  • User reports of unusual behavior when viewing specific chat conversations

Detection Strategies

  • Monitor application logs for Mermaid diagram submissions containing suspicious patterns such as javascript:, onclick, or base64-encoded payloads
  • Implement Content Security Policy (CSP) headers that restrict inline script execution and report violations to a logging endpoint
  • Deploy web application firewalls (WAF) with rules to detect XSS payloads in Mermaid diagram syntax
  • Audit stored chat content for known XSS payload patterns, particularly in diagram definitions

Monitoring Recommendations

  • Enable browser security headers reporting (CSP-Report-Only initially) to identify potential XSS execution attempts
  • Configure alerts for unusual JavaScript error patterns or unexpected external resource loading from chat pages
  • Monitor user session activity for anomalies following chat interactions, such as privilege escalation or bulk data access
  • Review application audit logs for Mermaid diagram rendering errors or security exceptions

How to Mitigate CVE-2026-21866

Immediate Actions Required

  • Upgrade Dify installations to version 1.11.2 or later immediately
  • Review chat history for any suspicious Mermaid diagram content that may contain malicious payloads
  • Force session invalidation for users who may have viewed potentially compromised chat conversations
  • Implement Content Security Policy headers as a defense-in-depth measure

Patch Information

The vulnerability has been fixed in Dify version 1.11.2. The fix modifies the Mermaid configuration to use a more restrictive security level that prevents script execution through diagram rendering.

Technical details of the patch are available in the following resources:

  • GitHub Commit ae17537470bba417a8971fff705dd82ecb043564 - Contains the actual code changes
  • GitHub Pull Request #29811 - Discussion and review of the fix
  • GitHub Security Advisory GHSA-qpv6-75c2-75h4 - Official vendor security advisory

Workarounds

  • If immediate patching is not possible, modify the Mermaid configuration to use securityLevel: strict or securityLevel: sandbox in your Dify deployment
  • Implement a web application firewall rule to filter Mermaid diagram content containing potential XSS payloads
  • Temporarily disable Mermaid diagram rendering in chat interfaces until the patch can be applied
  • Restrict chat functionality to trusted users only while awaiting the upgrade
bash
# Configuration example - Update Mermaid security level in Dify configuration
# Locate your Dify configuration and ensure Mermaid uses strict security
# This is a temporary workaround until upgrading to version 1.11.2

# For Docker deployments, update environment variables:
export MERMAID_SECURITY_LEVEL=strict

# Alternatively, upgrade to the patched version:
docker pull langgenius/dify:1.11.2
docker-compose down && docker-compose up -d

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 Score5.1

  • EPSS Probability0.04%

  • Known ExploitedNo
  • CVSS Vector
  • CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:P/VC:N/VI:N/VA:N/SC:L/SI:L/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
  • Vendor Resources
  • GitHub Commit Changes

  • GitHub Pull Request

  • GitHub Security Advisory GHSA-qpv6-75c2-75h4
  • Related CVEs
  • CVE-2026-26023: Dify LLM Platform XSS Vulnerability

  • CVE-2026-28288: Dify Information Disclosure Vulnerability

  • CVE-2025-67732: Dify LLM API Key Exposure Vulnerability
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