/

CVE-2026-34585

Severity:

HIGH RISK

(8.6)

Cross-Site Scripting (Stored XSS) in SiYuan Knowledge

CVE-2026-34585

Analyzed

Vulnerability type

Category:

Cross-Site Scripting (Stored XSS)

CWE:

CWE-79, CWE-94

Impact:

Stored XSS leading to Remote Code Execution in the Electron desktop client

Severity:

HIGH RISK

(8.6)

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 contained a stored cross-site scripting (XSS) vulnerability where specially crafted block attribute values could bypass server-side escaping and inject executable JavaScript into rendered notes.

An attacker could embed malicious attributes in a .sy document, distribute it as a .sy.zip, and trigger code execution when a victim imports and opens the note, leading to browser-based XSS and, in the Electron desktop client, full remote code execution via Node/Electron APIs.

Affected context

The vulnerability occurs in the handling of block attributes (IAL values) within SiYuan documents that are imported and then rendered as HTML in the application.

It affects contexts where:

  • User-supplied .sy documents can be imported via the standard "Import -> SiYuan .sy.zip" workflow
  • Block attributes are converted into HTML attributes in the rendered note
  • Attribute escaping logic can be bypassed when HTML entities are combined with raw special characters

The risk is most severe in the Electron desktop client, where injected JavaScript gains access to Node/Electron APIs, but the issue also represents stored XSS in other HTML-rendering contexts.

Exploit preconditions

  • Attack surface: SiYuan's note import and rendering pipeline for .sy / .sy.zip documents.
  • Required access: Ability to craft and deliver a malicious .sy file (e.g., shared note package, exported knowledge base) that the victim is willing to import.
  • Victim interaction: The victim must import the attacker-controlled .sy.zip via the normal import workflow and open the resulting note in the application.
  • Trigger point: Rendering of a block containing a malicious IAL value, where mixed HTML entities and raw special characters cause attribute escaping to fail.
  • Why exploitation is possible: The attribute-escaping routine does not correctly handle sequences that combine HTML-encoded entities with literal special characters, enabling the injected value to break out of the intended HTML context and attach an event handler or script-like behavior.

Why this happens

At its core, the bug stems from incomplete output encoding when embedding user-controlled block attributes into HTML output.

The escaping logic assumes that encoding special characters or entities in isolation is sufficient, but it fails to consider that:

  • Attackers can combine HTML entities and raw characters in ways that reconstruct dangerous sequences after parsing.
  • Attribute context has different encoding requirements than text content, particularly around quotes, angle brackets, and event-handler-like patterns.

This aligns with CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-site Scripting), where user input is reflected into HTML without appropriate context-aware escaping.

Because the injected JavaScript runs inside an Electron environment with access to Node/Electron APIs, the vulnerability effectively escalates to a code injection / RCE scenario (CWE-94) in that runtime, even though the root bug is improper HTML/JS output encoding.

Potential impact

  • Stored cross-site scripting within imported notes that can execute whenever the note is opened.
  • Execution of arbitrary JavaScript in the SiYuan rendering context.
  • In the Electron desktop client:
  • Execution of arbitrary OS-level commands via Node/Electron APIs.
  • Reading, modifying, or exfiltrating local files accessible to the application.
  • Stealing or tampering with application data, notes, or authentication tokens stored by SiYuan.
  • Potential lateral movement if the compromised client is used to interact with synced or shared knowledge bases.

General mitigation guidance

Mitigation is primarily about robust, context-aware output encoding and hardening the execution environment:

  • Apply strict, context-sensitive escaping for all user-controlled data before inserting it into HTML, particularly in attribute values (encode quotes, angle brackets, and special characters consistently).
  • Avoid mixing pre-decoded entities and raw characters; treat attributes as opaque data and consistently encode them at the final rendering boundary.
  • Normalize and validate block attributes (IAL values) before storage and rendering, rejecting or sanitizing patterns that resemble event handlers, inline JavaScript, or malformed attributes.
  • Prefer allow-list-based attribute policies, where only a small set of known-safe attributes are permitted, and all others are stripped or neutralized.
  • In desktop/Electron contexts, reduce the impact of XSS by:
  • Disabling or limiting nodeIntegration and direct access to Node/Electron APIs from the rendering layer, where feasible.
  • Using a strict Content Security Policy (CSP) to restrict inline event handlers and inline scripts.
  • Treat imported notes as untrusted content and consider applying a "safe import" pipeline that performs additional sanitization before allowing rendering.

How teams detect issues like this

Detection usually combines code inspection and behavioral testing:

  • Static analysis & code review:
  • Search for places where block attributes or IAL values are concatenated into HTML strings or templates without clear, context-specific escaping.
  • Flag any HTML generation patterns that manually build attribute strings rather than using templating or safe DOM APIs.
  • Review import pipelines for user-controlled data that flows directly into the renderer.
  • Automated testing:
  • Use XSS test suites with payloads that mix HTML entities and raw special characters to probe attribute-escaping behavior.
  • Add regression tests that encode and render malicious-like attributes and verify that the output remains inert.
  • Runtime monitoring (where applicable):
  • Instrument Electron or web views to log unexpected inline event handlers, javascript: URLs, or attempts to access Node/Electron APIs from note-rendering contexts.
  • Tooling:
  • Apply generic static analysis tools or linters that look for unsafe HTML construction.
  • Incorporate security review gates into CI/CD for changes touching rendering logic or import handlers.

Sources

SourceLink
github.comgithub.com/siyuan-note/siyuan/issues/17246
github.comgithub.com/siyuan-note/siyuan/releases/tag/v3.6.2
github.comgithub.com/siyuan-note/siyuan/security/advisories/GHSA-ff66-236v-p4fg

Frequently asked

questions

It can be exploited remotely in the sense that an attacker can distribute a malicious .sy or .sy.zip file over the internet or other channels. However, exploitation still requires the victim to import the file into SiYuan and open the affected note.

No direct prior access is required. The attacker only needs a way to convince the victim to import an attacker-crafted SiYuan package. Once imported and opened, the malicious block attributes execute in the victim's environment.

The safest approach is to ensure strict, context-aware encoding of all user-controlled data before it enters HTML, especially attribute values, combined with allow-listed attribute policies and robust sanitization of imported content. In Electron environments, also harden the runtime so that even successful XSS does not automatically translate into OS-level code execution.

Future prevention should focus on:

  • Adopting a consistent output-encoding strategy that treats different HTML contexts (text, attribute, URL, script) separately.
  • Using secure templating engines or DOM APIs instead of manual string concatenation for HTML.
  • Implementing defense-in-depth in desktop/web runtimes, such as disabling unnecessary Node/Electron integration and enforcing CSP.
  • Including XSS-focused security testing and code review checklists for any changes to import pipelines or rendering logic.
Find out what's already
exploitable in your codebase.