GitHub Advisoryadvisory · Go

GHSA-73g7-86qr-jrg3 SiYuan vulnerable to reflected XSS via SVG namespace prefix bypass in SanitizeSVG (getDynamicIcon, unauthenticated)

HIGH Published 2026-04-01 Modified 2026-04-06 Official page ↗
Aliases
CVE-2026-34605
Ecosystem
Go
Packages
github.com/siyuan-note/siyuan/kernel
Severity
High
CVSS vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
Weaknesses
CWE-79
Reviewed
2026-04-01

Affected packages

• Go github.com/siyuan-note/siyuan/kernel: < 0.0.0-20260330031106-f09953afc57a → fixed in 0.0.0-20260330031106-f09953afc57a

Description

Summary The `SanitizeSVG` function introduced in v3.6.0 to fix XSS in the unauthenticated `/api/icon/getDynamicIcon` endpoint can be bypassed by using namespace-prefixed element names such as ``. The Go HTML5 parser records the element's tag as `"x:script"` rather than `"script"`, so the tag check passes it through. The SVG is served with `Content-Type: image/svg+xml` and no Content Security Policy; when a browser opens the response directly, its XML parser resolves the prefix to the SVG namespace and executes the embedded script. Details The `getDynamicIcon` route is registered without authentication: ```go // kernel/server/serve.go ginServer.Handle("GET", "/api/icon/getDynamicIcon", getDynamicIcon) ``` For type 8, the `content` query parameter is inserted directly into an SVG `` element using `fmt.Sprintf` with no HTML encoding: ```go // kernel/api/icon.go:579-584 return fmt.Sprintf(` %s `, ..., content) ``` `SanitizeSVG` then parses the SVG with `github.com/88250/lute/html` and removes elements whose lowercased tag name matches a fixed list: ```go // kernel/util/misc.go:249-252 tag := strings.ToLower(c.Data) if tag == "script" || tag == "iframe" || tag == "object" || tag == "embed" || tag == "foreignobject" || "animate" == tag || ... { n.RemoveChild(c) ``` The lute HTML parser stores the full qualified name including any namespace prefix in `Node.Data`. A payload like `` gets `Data = "x:script"`. The check `tag == "script"` is false, so the element is not removed and survives in the rendered output. Confirmed with the same library version used by SiYuan: ``` html.Parse input: alert(1) Node.Data result: "x:script" (not "script") Removed by check: false Rendered output: alert(1) ``` The same bypass works for every element on the blocklist: `x:iframe`, `x:object`, `x:foreignObject`, etc. The fix is to strip the namespace prefix before comparing: ```go localName := tag if i := strings.LastIndex(tag, ":"); i >= 0 { localName = tag[i+1:] } if localName == "script" || localName == "iframe" || ... ``` PoC ``` GET /api/icon/getDynamicIcon?type=8&color=red&content=%3C%2Ftext%3E%3Cx%3Ascript%20xmlns%3Ax%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%3Ealert%28document.domain%29%3C%2Fx%3Ascript%3E%3Ctext%3E HTTP/1.1 Host: 127.0.0.1:6806 ``` Decoded `content` value: ``` alert(document.domain) ``` The response is a valid SVG with the script element intact. Opening the URL directly in a browser triggers the alert, confirming script execution at the SiYuan server origin. Impact Any user whose SiYuan instance is reachable over a local network is exposed. An attacker on the same network can craft the URL and share it. When the victim opens it in a browser, JavaScript executes at the `http://:6806` origin. Because SiYuan sets `Access-Control-Allow-Origin: *` and the script runs same-origin, it can call any API endpoint using the victim's existing session cookies, including endpoints to read all notes, export data, or modify settings. No authentication or prior access is needed to construct the payload.

Related

Alias · CVE (1)

  • CVE-2026-34605 SiYuan is a personal knowledge management system. vulnerability

Weakness · CWE (1)

  • CWE-79 Improper Neutralization of Input During Web Page Generation weakness

References