/

CVE-2026-33066

Severity:

CRITICAL RISK

(9.0)

XSS in SiYuan Package README Rendering Leading to RCE

CVE-2026-33066

Analyzed

Vulnerability type

Category:

Cross-Site Scripting (XSS)

CWE:

CWE-79

Impact:

Remote Code Execution via Stored Cross-Site Scripting in Electron

Severity:

CRITICAL RISK

(9.0)

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's README rendering pipeline failed to sanitize HTML in Markdown content and injected the result directly into the DOM via innerHTML.

A malicious package author could embed arbitrary JavaScript in their README, which executes when users view package details and, due to insecure Electron settings, can escalate to full remote code execution.

Affected context

The vulnerability appears in SiYuan's handling of package README files in versions 3.6.0 and below.

The backend uses lute.New() to render Markdown without enabling sanitization, allowing raw HTML to survive rendering.

The frontend then assigns this untrusted HTML to innerHTML in an Electron environment configured with nodeIntegration: true and contextIsolation: false.

When a user opens a malicious package's details view, the README content is rendered and executed in this privileged context.

Exploit preconditions

  • Attack surface: SiYuan's package README viewer within the Electron-based desktop application.
  • Required access: Ability to publish or otherwise influence package README content that a victim will later view.
  • Victim interaction: A user must browse or click to view the package details for the malicious package.
  • Trigger point: The backend renders the README with lute.New() (without SetSanitize(true)), and the frontend injects the resulting HTML via innerHTML.
  • Why exploitation is possible:
  • Raw HTML in Markdown is not sanitized server-side.
  • The client trusts the rendered HTML and inserts it directly into the DOM.
  • Electron is configured with nodeIntegration: true and contextIsolation: false, so injected JavaScript gains access to Node.js APIs and the underlying system.

Why this happens

At its core, this is a Cross-Site Scripting (CWE-79) issue stemming from insufficient output sanitization and risky browser integration.

The backend Markdown renderer (lute.New()) is used without enabling HTML sanitization (SetSanitize(true)), so user-controlled README content can include arbitrary HTML and script-related constructs.

On the frontend, this content is assigned to innerHTML without sanitization or a content security boundary, allowing any embedded script to execute.

In a standard browser this would already be XSS, but in this case, the Electron configuration (nodeIntegration: true, contextIsolation: false) conflates web and system privileges, turning a markup injection bug into a direct remote code execution pathway.

Potential impact

  • Execution of arbitrary JavaScript whenever a user views a malicious package's README.
  • Full remote code execution on the user's machine via Node.js APIs in Electron.
  • Exfiltration of local knowledge data, configuration files, or authentication secrets handled by the app.
  • Installation of additional malware or persistence mechanisms on the host system.
  • Lateral movement by accessing other local resources or network services reachable from the victim's machine.
  • Impersonation of the user within the application and tampering with stored notes or knowledge bases.

General mitigation guidance

Effective mitigation combines robust HTML sanitization with safer Electron isolation defaults and defensive rendering patterns:

  • Prefer Markdown renderers configured in a "safe HTML" mode, or explicitly enable sanitization options so that dangerous tags, attributes, and protocols are stripped from README content.
  • Treat all package metadata and documentation as untrusted; apply a well-maintained HTML sanitizer on the final HTML, not just the Markdown, before it reaches the UI.
  • Avoid directly assigning untrusted HTML to innerHTML; instead, use templating mechanisms that encode content by default, only whitelisting specific markup if truly required.
  • In Electron, design the application around contextIsolation: true and nodeIntegration: false, delegating privileged operations to carefully scoped preload scripts or IPC handlers.
  • Apply least-privilege principles for renderer processes: limit the available APIs and file system access so that, even if a rendering bug appears, the impact is constrained.
  • Document and enforce a security model where package content cannot directly invoke privileged APIs, regardless of the UI surface it flows through.

How teams detect issues like this

Identifying similar vulnerabilities involves both code-centric and configuration-centric checks:

  • Static analysis and linting:
  • Search for innerHTML, outerHTML, or equivalent DOM sinks fed from variables that originate in network, file, or package content without passing through a sanitizer.
  • Flag uses of Markdown/HTML rendering libraries where sanitization flags (such as SetSanitize(true) or equivalents) are not set while processing untrusted content.
  • Configuration review:
  • Audit Electron configuration for nodeIntegration: true, contextIsolation: false, or other settings that expose Node.js in regular web contexts.
  • Review preload scripts and IPC handlers to ensure they do not expose overly broad system capabilities to rendered web content.
  • Code review patterns:
  • Trace data flows from package repositories or registries into UI components; highlight any path that leads to raw HTML rendering.
  • Check for centralized sanitization utilities; if they are absent or inconsistently used, treat it as a sign of elevated risk across the codebase.
  • Automated tooling:
  • Incorporate SAST tools that recognize XSS sinks and insecure Electron settings into CI pipelines.
  • Add custom checks or policies that block merges when new uses of dangerous DOM APIs or insecure Electron flags are introduced.

Sources

SourceLink
github.comgithub.com/siyuan-note/siyuan/commit/b382f50e1880ed996364509de5a10a72d7409428
github.comgithub.com/siyuan-note/siyuan/security/advisories/GHSA-4663-4mpg-879v

Frequently asked

questions

It is remotely exploitable in the sense that an attacker only needs to publish or control a package README that a victim will later view; the victim's local application then processes and executes the content.

Typically, the attacker just needs the ability to supply README content to the package ecosystem or any channel that feeds into SiYuan's package viewer. If the package system is public or semi-public, no additional authentication on the victim's side is required beyond normal usage.

Apply HTML sanitization by default on all rendered Markdown that originates from untrusted sources, and avoid writing that HTML directly to innerHTML. At the platform level, configure Electron with contextIsolation: true and nodeIntegration: false, exposing only narrowly scoped, well-validated IPC interfaces for privileged operations.

Establish a consistent "untrusted content" model: any user-generated or third-party content must be sanitized and encoded before display, and must never run in a context with direct system access. Combine secure markdown/HTML handling with secure-by-default Electron configuration, security-focused code review checklists, and automated checks that flag new uses of dangerous sinks and high-privilege renderer settings.

Find out what's already
exploitable in your codebase.