GHSA-99rq-75j6-5j9f: SiYuan: Stored and reflected XSS in SiYuan through an SVG sanitizer bypass
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
.svgasset:GET /assets/<name>.svg
I confirmed this on a live SiYuan 3.7.2 kernel.
References
Code Behaviors & Features
Detect and mitigate GHSA-99rq-75j6-5j9f with GitLab Dependency Scanning
Secure your software supply chain by verifying that all open source dependencies used in your projects contain no disclosed vulnerabilities. Learn more about Dependency Scanning →