/

CVE-2026-74902

Severity:

HIGH RISK

(8.6)

Cross-Site Scripting (CWE-79) in SiYuan Upload Flow

CVE-2026-74902

Deferred

Vulnerability type

Category:

Cross-Site Scripting

CWE:

CWE-79

Impact:

Script Execution and Potential OS Command Execution

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 contains a cross-site scripting vulnerability in its file upload validation flow because filenames are inserted into HTML without adequate escaping. An attacker who can provide a maliciously named file may execute script when a user drags, drops, or pastes that file into the editor; in the desktop application context, this could expose OS command capabilities.

Affected context

The vulnerability occurs in SiYuan's file handling and editor integration when a filename is accepted from an untrusted source and later inserted into the document interface. Risk is increased when users interact with attacker-supplied files through drag-and-drop or paste operations and when the application runs with access to local operating-system capabilities.

Exploit preconditions

  • Attack surface: File upload, drag-and-drop, or paste handling in the editor
  • Required access: The ability to provide or cause a user to handle a file with a crafted filename
  • Trigger point: Filename validation or rendering that inserts the name into the DOM
  • Why exploitation is possible: Unescaped filename content is interpreted as HTML and may execute in the application's trusted origin
  • Additional condition: Impact may be greater in desktop deployments that expose privileged OS integration to rendered content

Why this happens

The underlying bug is a failure to treat filenames as untrusted text before placing them into an HTML parsing context. Using insertAdjacentHTML with unescaped user-controlled data allows markup and script-bearing content to be interpreted by the browser or embedded webview rather than displayed literally. This maps to CWE-79: Improper Neutralization of Input During Web Page Generation, commonly known as cross-site scripting.

Potential impact

  • An attacker may execute script in the application's trusted origin
  • A script could access application data available to the affected document context
  • User actions or editor content could be manipulated
  • In desktop deployments, malicious content could potentially invoke exposed OS command capabilities
  • The application session could be abused for further local or network activity

General mitigation guidance

Mitigation generally focuses on preserving the distinction between untrusted filenames and executable markup.

Common defensive patterns include:

  • Rendering filenames with text-oriented DOM APIs such as textContent or equivalent safe element properties
  • Applying context-appropriate output encoding whenever dynamic values enter HTML
  • Avoiding string-based HTML construction for user-controlled values
  • Using narrowly scoped sanitization only when HTML rendering is genuinely required
  • Validating filenames against an allowlist of expected characters and formats as a secondary control
  • Limiting web-content privileges and OS integration available to rendered application content
  • Applying defense-in-depth browser, webview, and content security policies where supported

How teams detect issues like this

Detection can combine static analysis, review, and runtime controls:

  • Search for insertAdjacentHTML, innerHTML, template interpolation, and similar HTML sinks receiving filename or upload metadata
  • Flag data flows from file names, drag-and-drop events, clipboard data, or upload responses into HTML-generating APIs
  • Review whether output encoding is appropriate for the exact rendering context
  • Add tests using markup-like filenames to verify literal rendering rather than execution
  • Enforce secure DOM-manipulation and content-security policies through automated quality gates
  • Use neutral automated code-review tools to identify untrusted data reaching browser or webview execution sinks

Sources

SourceLink
github.comgithub.com/siyuan-note/siyuan/security/advisories/GHSA-jf56-jrhq-j2qp
vulncheck.comvulncheck.com/advisories/siyuan-before-xss-to-rce-via-malicious-filename-upload

Frequently asked

questions

Exploitation generally requires a maliciously named file to reach the victim through a file-sharing, upload, drag-and-drop, or paste workflow. It is not necessarily exploitable as a network-only attack without that file-handling interaction.

The attacker needs a way to supply or influence the filename and a realistic opportunity for a user to process the file. The exact access requirement depends on how files are transferred to the application.

Treat filenames strictly as text and render them with text-safe DOM APIs instead of concatenating them into HTML. Context-appropriate encoding and narrowly scoped sanitization provide additional defense in depth.

Apply trusted-types or equivalent DOM safety policies where available, review all dynamic HTML sinks, test untrusted file metadata, and minimize OS privileges exposed to embedded application content.

Find out what's already
exploitable in your codebase.