Skip to content

Commit f20b249

Browse files
1 parent 95a4f84 commit f20b249

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"schema_version": "1.4.0",
3+
"id": "GHSA-73g7-86qr-jrg3",
4+
"modified": "2026-04-01T00:30:01Z",
5+
"published": "2026-04-01T00:30:01Z",
6+
"aliases": [
7+
"CVE-2026-34605"
8+
],
9+
"summary": "SiYuan vulnerable to reflected XSS via SVG namespace prefix bypass in SanitizeSVG (getDynamicIcon, unauthenticated)",
10+
"details": "### Summary\n\nThe `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 `<x:script xmlns:x=\"http://www.w3.org/2000/svg\">`. 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.\n\n### Details\n\nThe `getDynamicIcon` route is registered without authentication:\n\n```go\n// kernel/server/serve.go\nginServer.Handle(\"GET\", \"/api/icon/getDynamicIcon\", getDynamicIcon)\n```\n\nFor type 8, the `content` query parameter is inserted directly into an SVG `<text>` element using `fmt.Sprintf` with no HTML encoding:\n\n```go\n// kernel/api/icon.go:579-584\nreturn fmt.Sprintf(`\n <svg id=\"dynamic_icon_type8\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512 512\">\n <path d=\"...\"/>\n <text x=\"50%%\" y=\"55%%\" ...>%s</text>\n </svg>`, ..., content)\n```\n\n`SanitizeSVG` then parses the SVG with `github.com/88250/lute/html` and removes elements whose lowercased tag name matches a fixed list:\n\n```go\n// kernel/util/misc.go:249-252\ntag := strings.ToLower(c.Data)\nif tag == \"script\" || tag == \"iframe\" || tag == \"object\" || tag == \"embed\" ||\n tag == \"foreignobject\" || \"animate\" == tag || ... {\n n.RemoveChild(c)\n```\n\nThe lute HTML parser stores the full qualified name including any namespace prefix in `Node.Data`. A payload like `<x:script xmlns:x=\"http://www.w3.org/2000/svg\">` gets `Data = \"x:script\"`. The check `tag == \"script\"` is false, so the element is not removed and survives in the rendered output.\n\nConfirmed with the same library version used by SiYuan:\n\n```\nhtml.Parse input: <x:script xmlns:x=\"http://www.w3.org/2000/svg\">alert(1)</x:script>\nNode.Data result: \"x:script\" (not \"script\")\nRemoved by check: false\nRendered output: <x:script xmlns:x=\"http://www.w3.org/2000/svg\">alert(1)</x:script>\n```\n\nThe same bypass works for every element on the blocklist: `x:iframe`, `x:object`, `x:foreignObject`, etc.\n\nThe fix is to strip the namespace prefix before comparing:\n\n```go\nlocalName := tag\nif i := strings.LastIndex(tag, \":\"); i >= 0 {\n localName = tag[i+1:]\n}\nif localName == \"script\" || localName == \"iframe\" || ...\n```\n\n### PoC\n\n```\nGET /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\nHost: 127.0.0.1:6806\n```\n\nDecoded `content` value:\n```\n</text><x:script xmlns:x=\"http://www.w3.org/2000/svg\">alert(document.domain)</x:script><text>\n```\n\nThe 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.\n\n### Impact\n\nAny 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://<siyuan-host>: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.",
11+
"severity": [
12+
{
13+
"type": "CVSS_V4",
14+
"score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:A/VC:H/VI:H/VA:L/SC:N/SI:N/SA:N"
15+
}
16+
],
17+
"affected": [
18+
{
19+
"package": {
20+
"ecosystem": "Go",
21+
"name": "github.com/siyuan-note/siyuan/kernel"
22+
},
23+
"ranges": [
24+
{
25+
"type": "ECOSYSTEM",
26+
"events": [
27+
{
28+
"introduced": "0"
29+
},
30+
{
31+
"fixed": "0.0.0-20260330031106-f09953afc57a"
32+
}
33+
]
34+
}
35+
]
36+
}
37+
],
38+
"references": [
39+
{
40+
"type": "WEB",
41+
"url": "https://github.com/siyuan-note/siyuan/security/advisories/GHSA-73g7-86qr-jrg3"
42+
},
43+
{
44+
"type": "WEB",
45+
"url": "https://github.com/siyuan-note/siyuan/issues/17246"
46+
},
47+
{
48+
"type": "PACKAGE",
49+
"url": "https://github.com/siyuan-note/siyuan"
50+
},
51+
{
52+
"type": "WEB",
53+
"url": "https://github.com/siyuan-note/siyuan/releases/tag/v3.6.2"
54+
}
55+
],
56+
"database_specific": {
57+
"cwe_ids": [
58+
"CWE-79"
59+
],
60+
"severity": "HIGH",
61+
"github_reviewed": true,
62+
"github_reviewed_at": "2026-04-01T00:30:01Z",
63+
"nvd_published_at": null
64+
}
65+
}

0 commit comments

Comments
 (0)