The vulnerability, identified as CVE-2026-27902, is a cross-site scripting (XSS) issue in Svelte's server-side rendering (SSR) mechanism. The root cause is the improper handling of errors within a <svelte:boundary>. When an error is thrown inside a boundary during SSR, Svelte is designed to catch the error and embed information about it within an HTML comment in the rendered output. This allows the client-side code to correctly hydrate the component.
The vulnerability lies in the fact that the error object, which can be modified by the developer using the transformError function, was not sanitized before being included in the comment. The error was simply converted to a JSON string. An attacker able to control the content of the error could inject a string like --> <script>alert('XSS')</script> which would close the HTML comment prematurely and allow the execution of arbitrary JavaScript in the user's browser.
The analysis of the patch commit 0298e979371bb583855c9810db79a70a551d22b9 pinpoints the vulnerable code within the Renderer class located at packages/svelte/src/internal/server/renderer.js. The patch replaces direct and unsafe JSON.stringify() calls with a new, safe method Renderer.#serialize_failed_boundary. This new method escapes HTML-sensitive characters (< and >) within the JSON string, thus preventing the injection of malicious HTML. The vulnerable code was identified in the Renderer.boundary method and the private Renderer.#collect_content_async method, which are directly involved in rendering error states for boundaries.