/

CVE-2026-54070

Severity:

HIGH RISK

(7.1)

Stored XSS (CWE-79) in SiYuan Bazaar README Renderer

CVE-2026-54070

Deferred

Vulnerability type

Category:

Cross-Site Scripting (XSS)

CWE:

CWE-79, CWE-184

Impact:

Stored Cross-Site Scripting leading to administrator session compromise and workspace takeover

Severity:

HIGH RISK

(7.1)

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 Bazaar README renderer mishandles HTML sanitization, allowing modern inline event handlers in Markdown to pass through and execute as JavaScript in the Administrator's browser.

When an Administrator views a malicious package README in the Marketplace, the attacker's code can run in the authenticated SiYuan origin and potentially take full control of the workspace.

Affected context

The vulnerability occurs in SiYuan's Marketplace (Bazaar) package viewing flow where README files are rendered from Markdown to HTML.

It is relevant in deployments where:

  • Administrators browse third-party packages via Settings → Marketplace
  • README content from packages is treated as trusted Markdown
  • Server-side sanitization relies solely on a legacy event-handler blocklist
  • The rendered HTML is injected into the main document without an additional client-side sanitizer or sandboxing

Exploit preconditions

  • Attack surface: Bazaar Marketplace README rendering in the SiYuan web UI.
  • Required access: Ability to publish or control the content of a Bazaar package README that an Administrator can view; no direct access to the victim's instance is required beyond normal Marketplace exposure.
  • Trigger point: An Administrator opens a malicious package in Settings → Marketplace, causing the README to be rendered and its HTML assigned to innerHTML in the main document, then interacts with the page so the bound events fire.
  • Why exploitation is possible: The lute sanitizer uses a fixed event-handler blocklist copied from a legacy list and does not recognize modern event attributes such as onpointerover, onpointerdown, onauxclick, onbeforetoggle, onfocusin, onanimationstart, and ontransitionend. These attributes are preserved verbatim and, since the HTML is injected without CSP or iframe sandboxing, inline handlers execute in the Administrator's browser context.

Why this happens

The underlying bug is incomplete HTML sanitization stemming from a fragile, allowlist/blocklist approach to event attributes.

In the renderPackageREADME path, Markdown is converted to HTML with the lute engine and SetSanitize(true), but the sanitizer's allowAttr function only rejects attribute names found in a static eventAttrs map derived from an outdated w3schools handler list.

Modern DOM event handler attributes are simply not included in that map, so they bypass filtering entirely and are delivered to the client unchanged.

On the frontend, this HTML is directly assigned to mdElement.innerHTML without additional sanitization or isolation, mapping to CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-Site Scripting) and CWE-184: Incomplete List of Disallowed Inputs, where partial blocklists create gaps that attackers can exploit.

Potential impact

  • An attacker may execute arbitrary JavaScript in the Administrator's browser session.
  • Malicious code could manipulate or exfiltrate workspace content, notes, and configurations.
  • The attacker can potentially perform administrative actions on behalf of the Administrator.
  • Session cookies or tokens accessible to frontend scripts could be stolen or abused.
  • The SiYuan instance can be driven into an unsafe state, including data corruption or unauthorized configuration changes.

General mitigation guidance

Effective mitigation focuses on robust HTML sanitization and minimizing trust in remote package content.

Common defensive patterns include:

  • Replacing ad-hoc event-handler blocklists with well-maintained, security-focused sanitization libraries that enforce strict HTML and attribute allowlists.
  • Treating remote Markdown and README content as untrusted input and sanitizing it with context-aware rules before inserting it into the DOM.
  • Avoiding direct innerHTML assignments for untrusted content; instead, render through templating systems or APIs that strip scriptable constructs by default.
  • Applying least-privilege principles to the administrative UI by limiting what untrusted content can access, and considering rendering risky content in sandboxed iframes where feasible.
  • Leveraging browser security headers (e.g., a restrictive Content Security Policy, X-Frame-Options, X-Content-Type-Options) to reduce the impact of any remaining script injection vectors.

How teams detect issues like this

Detection typically involves a combination of code-level and behavioral analysis:

  • Static analysis rules that flag use of innerHTML or similar DOM injection APIs with data derived from external or package-controlled sources.
  • Code review practices that look for custom sanitizers relying on blocklists or incomplete event/attribute filters, especially those based on legacy lists.
  • Automated security testing of the README rendering pipeline with fuzzed or crafted Markdown containing modern event handlers and script-like constructs.
  • Policy enforcement in CI/CD that requires any HTML sanitization logic to be backed by vetted libraries and prohibits bypassing centralized sanitization routines.
  • Application-level monitoring that logs and alerts on unexpected script executions or anomalous administrative actions following Marketplace interactions.

Sources

SourceLink
github.comgithub.com/siyuan-note/siyuan/security/advisories/GHSA-w7cg-whh7-xp28

Frequently asked

questions

Yes. A Bazaar package author who publishes a malicious README can exploit the vulnerability when an Administrator of a vulnerable SiYuan instance views that package in the Marketplace, without needing direct access to the target deployment.

The attacker only needs the ability to control README content in a Bazaar package that appears in the Marketplace. The Administrator must then open the package listing and interact with the rendered page for the injected event handlers to execute.

The safest pattern is to treat all remotely sourced HTML/Markdown as untrusted, sanitize it with a well-maintained, allowlist-based sanitizer, and avoid direct innerHTML insertion. Supplement this with browser-enforced protections such as a strict Content Security Policy and, where appropriate, sandboxed rendering contexts.

To prevent similar issues, centralize HTML sanitization logic, rely on proven libraries rather than custom blocklists, enforce secure-by-default rendering practices, and include XSS-focused checks in code review and automated security testing for any feature that renders user- or third-party-controlled content.

Find out what's already
exploitable in your codebase.