The vulnerability is a stored XSS caused by the application serving user-uploaded SVG files without sanitization. The proof-of-concept demonstrates that a malicious SVG file with embedded JavaScript, when uploaded and accessed, executes the script in the user's browser.
The analysis of the patch commit 11115da3d0de950593ee4ce375cf7f9018484388 reveals the exact location of the vulnerability and the fix.
-
kernel/server/serve.go: The function serveAssets handles HTTP requests for files in the /assets/ directory. Before the patch, it served files directly. The patch modifies serveAssets to delegate the handling of SVG files to a new function, serveSVG.
-
serveSVG function: This new function, also in kernel/server/serve.go, is responsible for handling SVG files specifically. It reads the SVG file and, by default, passes its content to util.RemoveScriptsInSVG for sanitization before sending it in the HTTP response. This sanitization is only skipped if a new, explicit configuration option allowSVGScript is enabled.
-
kernel/util/misc.go: This file contains the new RemoveScriptsInSVG function, which is the core of the sanitization logic. It parses the SVG content and removes any <script> tags, effectively neutralizing the XSS vector.
The vulnerable function is server.serveAssets because it was the entry point for serving the unsanitized files. During exploitation, a runtime profile would show this function being executed when the malicious SVG is requested by a user's browser.