Executive brief
Svelte is a popular JavaScript framework used to build web applications. During server-side rendering, Svelte incorrectly processes spread syntax when used with untrusted data, allowing attackers to inject malicious event handlers into HTML output. These injected handlers execute in users' browsers, potentially stealing session tokens, credentials, or sensitive data from the page.
Technical details
The vulnerability is a cross-site scripting (CWE-79) flaw in Svelte versions prior to 5.51.5. When using spread syntax to render HTML element attributes from untrusted or user-controlled data during server-side rendering, event handler properties are not properly filtered and are included in the rendered HTML output. An attacker who can control data being spread as attributes (such as URL parameters, form inputs, or external API responses) can inject properties like `onload`, `onerror`, or `onmouseover` with malicious JavaScript code. The attack requires network access and high privileges (to submit untrusted data) with high attack complexity, but success results in client-side code execution in victim browsers. The fix is available in version 5.51.5 and later.
Affected products
- Svelte Svelte <=5.51.4
Timeline
- 2026-02-19: disclosed
- 2026-02-19: patched: Fixed in version 5.51.5