Skip to main content
COSMICBYTEZLABS
NewsSecurityHOWTOsToolsStudyTraining
ProjectsChecklistsAI RankingsNewsletterStatusTagsAbout
Subscribe

Press Enter to search or Esc to close

News
Security
HOWTOs
Tools
Study
Training
Projects
Checklists
AI Rankings
Newsletter
Status
Tags
About
RSS Feed
Reading List
Subscribe

Stay in the Loop

Get the latest security alerts, tutorials, and tech insights delivered to your inbox.

Subscribe NowFree forever. No spam.
COSMICBYTEZLABS

Your trusted source for IT intelligence, cybersecurity insights, and hands-on technical guides.

666+ Articles
118+ Guides

CONTENT

  • Latest News
  • Security Alerts
  • HOWTOs
  • Projects
  • Exam Prep

RESOURCES

  • Search
  • Browse Tags
  • Newsletter Archive
  • Reading List
  • RSS Feed

COMPANY

  • About Us
  • Contact
  • Privacy Policy
  • Terms of Service

© 2026 CosmicBytez Labs. All rights reserved.

System Status: Operational
  1. Home
  2. Security
  3. CVE-2026-40322: SiYuan XSS via Mermaid innerHTML Injection
CVE-2026-40322: SiYuan XSS via Mermaid innerHTML Injection
SECURITYHIGHCVE-2026-40322

CVE-2026-40322: SiYuan XSS via Mermaid innerHTML Injection

SiYuan knowledge management versions 3.6.3 and below render Mermaid diagrams with loose security, allowing attacker-controlled javascript: URLs to execute arbitrary JavaScript via innerHTML injection.

Dylan H.

Security Team

April 17, 2026
3 min read

Affected Products

  • SiYuan <= 3.6.3

Overview

A cross-site scripting (XSS) vulnerability has been identified in SiYuan, an open-source personal knowledge management system. Tracked as CVE-2026-40322 with a CVSS score of 9.0, the flaw allows attackers to execute arbitrary JavaScript in the context of a victim's SiYuan session by embedding malicious Mermaid diagram code blocks in shared notes or documents.

Technical Details

SiYuan renders Mermaid diagrams using the securityLevel: "loose" configuration. In this mode, Mermaid generates SVG output that is directly injected into the DOM via innerHTML. Because innerHTML does not sanitize anchor href attributes, attacker-controlled javascript: URLs embedded within Mermaid diagram code survive the rendering pipeline and execute when a user interacts with the resulting SVG element.

The attack vector requires that an attacker either:

  • Controls a shared SiYuan document or note accessible to the victim, or
  • Convinces a victim to import or open a crafted .sy document containing the malicious Mermaid block.

Because SiYuan is an Electron-based desktop application, successful XSS can escalate to arbitrary code execution in the local filesystem context, depending on the Electron shell's nodeIntegration and contextIsolation settings in affected builds.

Proof of Concept

A minimal malicious Mermaid block that triggers the vulnerability:

graph LR
  A[<a href="javascript:alert(document.cookie)">Click Me</a>] --> B[Result]

When rendered in affected versions, clicking the node executes the embedded JavaScript payload.

Affected Versions

ProductAffected VersionsStatus
SiYuan3.6.3 and belowPatch pending

CVSS Score

MetricValue
Base Score9.0 (Critical)
Attack VectorNetwork
Attack ComplexityLow
Privileges RequiredNone
User InteractionRequired
ScopeChanged
ConfidentialityHigh
IntegrityHigh
AvailabilityLow

Mitigation

At time of publication, no official patch has been released for this vulnerability. Users of SiYuan are advised to:

  1. Avoid opening untrusted documents — Do not import or view SiYuan notes from unknown sources until a patch is available.
  2. Disable Mermaid rendering — If possible, disable diagram rendering in SiYuan preferences.
  3. Monitor for updates — Watch the SiYuan GitHub repository for a patched release addressing this CVE.
  4. Network isolation — Consider running SiYuan in an isolated environment if processing documents from external parties.

References

  • NVD Entry: CVE-2026-40322
  • SiYuan GitHub Repository
  • Mermaid Security Configuration
#CVE#XSS#SiYuan#Mermaid#Knowledge Management#Vulnerability

Related Articles

CVE-2026-33669: SiYuan Unauthenticated Document Content Exposure (CVSS 9.8)

A critical unauthenticated information disclosure vulnerability in SiYuan, the personal knowledge management system, allows remote attackers to retrieve...

4 min read

CVE-2026-33670: SiYuan readDir Path Traversal Notebook Enumeration (CVSS 9.8)

A critical path traversal vulnerability in SiYuan's /api/file/readDir interface allows unauthenticated remote attackers to traverse notebook directories...

4 min read

CVE-2015-20115: RealtyScript 4.0.2 Stored XSS via File Upload in Admin Panel

CVE-2015-20115 is a stored cross-site scripting vulnerability in RealtyScript 4.0.2 that allows authenticated attackers to upload malicious script files...

5 min read
Back to all Security Alerts