/

CVE-2026-41421

Severity:

HIGH RISK

(8.8)

Cross-Site Scripting (XSS) Leading to Code Execution

CVE-2026-41421

Deferred

Vulnerability type

Category:

Cross-Site Scripting (XSS) Leading to Code Execution

CWE:

CWE-78, CWE-79

Impact:

Arbitrary Code Execution in Electron Desktop Environment

Severity:

HIGH RISK

(8.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

SiYuan desktop prior to 3.6.5 contains a DOM-based cross-site scripting vulnerability in its notification system, where user-controlled messages are rendered as raw HTML inside an Electron renderer.

Because the Electron windows run with nodeIntegration enabled, contextIsolation disabled, and webSecurity off, injected JavaScript can directly access Node APIs and escalate from XSS to arbitrary desktop code execution when crafted messages reach the notification sink.

Affected context

This issue affects the SiYuan desktop application where notifications are rendered in an Electron renderer process.

The vulnerable path is triggered when the backend endpoint POST /api/notification/pushMsg accepts a msg parameter, forwards it through the broadcast layer, and the frontend inserts it into the DOM via insertAdjacentHTML(...) in message.ts.

The risk is specific to desktop builds configured with nodeIntegration: true, contextIsolation: false, and webSecurity: false in main.js, which together allow JavaScript in the notification context to reach Node.js APIs.

Exploit preconditions

  • Attack surface: The /api/notification/pushMsg HTTP endpoint used to deliver notifications to desktop clients.
  • Required access: Ability to send or influence requests that set the msg field, either directly or via an upstream feature that calls this API.
  • Trigger point: Rendering of the notification in the Electron renderer, where msg is inserted into the DOM using insertAdjacentHTML(...).
  • Why exploitation is possible: The application treats msg as trusted HTML, performing no encoding or sanitization, and renders it in a context where Electron is configured with full Node integration and disabled isolation, enabling script execution to bridge from the browser environment into the Node.js runtime.

Why this happens

The core issue is untrusted HTML content being directly injected into the DOM in a privileged renderer without sanitization or contextual encoding.

The use of insertAdjacentHTML(...) on a user-controlled msg value embodies CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-site Scripting), because it allows arbitrary script execution in the renderer.

In the Electron environment, this DOM XSS is amplified: nodeIntegration: true, contextIsolation: false, and webSecurity: false merge the web and Node.js contexts, so injected scripts can invoke Node APIs, spawn processes, and interact with the host OS.

When an attacker-controlled script can drive OS-level commands via Node facilities, the behavior aligns with CWE-78: Improper Neutralization of Special Elements used in an OS Command, as untrusted input is effectively channeled into command execution through the Node bridge.

Potential impact

  • Execution of arbitrary JavaScript within the SiYuan desktop renderer context.
  • Direct access to Node.js APIs from injected scripts, including file system and process management capabilities.
  • Arbitrary code execution on the desktop system running SiYuan, subject to the application's privileges.
  • Reading, modifying, or exfiltrating local knowledge base data managed by the application.
  • Use of the compromised application as a foothold for broader system compromise or lateral movement in the user's environment.

General mitigation guidance

Effective mitigation focuses on both output handling and Electron security posture:

  • Neutralize untrusted HTML in notifications:
  • Treat notification messages as plain text by default and apply strict output encoding before inserting into the DOM.
  • Where rich formatting is required, restrict to a whitelist of safe tags and attributes using a robust HTML sanitizer, avoiding script execution contexts entirely.
  • Avoid APIs such as insertAdjacentHTML(...) and innerHTML for untrusted data; prefer safe DOM construction (e.g., textContent, createTextNode) and explicit element creation.
  • Harden the Electron environment:
  • Disable nodeIntegration in renderer windows that display any remotely or indirectly supplied content.
  • Enable contextIsolation so that web content runs in a separate JavaScript context from privileged APIs.
  • Re-enable webSecurity to enforce origin and content restrictions wherever feasible.
  • Route all privileged operations through a minimal, well-audited IPC layer that validates and constrains messages from the renderer.
  • Reduce trust boundaries around notifications:
  • Treat any data reaching notification sinks as untrusted, regardless of internal origin.
  • Apply centralized validation and encoding at the boundary where messages cross into the UI layer, rather than relying on upstream callers.

How teams detect issues like this

Detection can leverage both code-level and behavioral approaches:

  • Static analysis and linting:
  • Configure rules to flag usage of innerHTML, insertAdjacentHTML, and similar sinks when they receive variables originating from external inputs or internal messaging APIs.
  • Add Electron-specific checks for windows created with nodeIntegration: true, contextIsolation: false, or webSecurity: false, especially when those windows display dynamic content.
  • Use taint analysis where available to trace the flow of data from HTTP endpoints like /api/notification/pushMsg into DOM sinks in renderer code.
  • Code review patterns:
  • During review, scrutinize all notification and messaging features for direct DOM insertion patterns and confirm that outputs are encoded according to context.
  • Verify that any bridge between backend notifications and frontend renderers applies sanitization in a single, consistent layer rather than piecemeal.
  • Policy and tooling:
  • Establish internal guidelines that forbid enabling Node integration for windows rendering content influenced by user or network data.
  • Integrate automated checks into CI/CD pipelines that enforce Electron security baselines and flag deviations for manual review.

Sources

SourceLink
github.comgithub.com/siyuan-note/siyuan/security/advisories/GHSA-grjj-6f6g-cq8q

Frequently asked

questions

Exploitability depends on how the /api/notification/pushMsg endpoint is exposed.

If it is reachable over the network or via features that accept remote input, an attacker may be able to inject malicious notification messages remotely; if it is restricted to local use, exploitation typically requires local or internal access to that interface.

An attacker must be able to influence the msg parameter that ultimately reaches the notification API.

This could occur through direct HTTP access to /api/notification/pushMsg, through another application feature that calls this endpoint on the user's behalf, or via a compromised component within the same environment.

The most robust fix pattern is to stop treating untrusted content as HTML and instead encode it for its output context, while simultaneously enforcing secure Electron defaults.

That means emitting messages as text-only or sanitised HTML, avoiding dangerous DOM APIs for dynamic content, and ensuring that renderer processes handling user-influenced data run without Node integration and with context isolation.

Prevention hinges on designing with strict trust boundaries and least privilege in mind: treat all inputs as untrusted until encoded, centralize output encoding and sanitization logic, and keep privileged APIs behind narrow IPC interfaces.

For Electron-based applications, adopt a security baseline that disables Node integration for content-rendering windows, enables context isolation and web security, and enforces these constraints via documentation, code review, and automated checks.

Find out what's already
exploitable in your codebase.