CVE-2026-21866
Stored XSS in Dify Mermaid Diagrams Allows Code Execution
Publication date: 2026-03-03
Last updated on: 2026-03-05
Assigner: GitHub, Inc.
Description
Description
CVSS Scores
EPSS Scores
| Probability: | |
| Percentile: |
Meta Information
Affected Vendors & Products
| Vendor | Product | Version / Range |
|---|---|---|
| dify | dify | to 1.11.2 (exc) |
Helpful Resources
Exploitability
| CWE ID | Description |
|---|---|
| CWE-79 | 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. |
Attack-Flow Graph
AI Powered Q&A
Can you explain this vulnerability to me?
This vulnerability affects Dify, an open-source LLM app development platform, in versions prior to 1.11.2. It is a stored Cross-Site Scripting (XSS) issue that occurs when rendering Mermaid diagrams within chats. The root cause is that Dify's default Mermaid configuration uses a security level set to 'loose', which permits potentially unsafe content to execute scripts. This can allow malicious code to be stored and later executed in the context of the application.
How can this vulnerability impact me? :
The stored XSS vulnerability can allow attackers to inject malicious scripts into Mermaid diagrams that are rendered within chats. When other users view these diagrams, the malicious scripts can execute in their browsers, potentially leading to unauthorized actions such as stealing session tokens, performing actions on behalf of the user, or delivering malware. This can compromise user data and the integrity of the application.
How does this vulnerability affect compliance with common standards and regulations (like GDPR, HIPAA)?:
I don't know
How can this vulnerability be detected on my network or system? Can you suggest some commands?
I don't know
What immediate steps should I take to mitigate this vulnerability?
To mitigate this vulnerability, upgrade Dify to version 1.11.2 or later, where the stored XSS issue related to Mermaid diagrams is fixed by changing the default Mermaid configuration from securityLevel: loose to a more secure setting.