The vulnerability is a DOM Clobbering issue in Svelte, which can lead to Cross-Site Scripting (XSS). The root cause was Svelte's internal mechanism for managing component state, which relied on storing data in properties directly on DOM elements using predictable string names (e.g., __attributes, __className, __style).
An attacker could exploit this by using Svelte's attribute spreading feature (<element {...user_controlled_data}>) to supply attributes with names that match Svelte's internal properties, such as { name: '__attributes', value: '...' }. This would "clobber" or overwrite the framework's internal state, leading to unpredictable behavior. In the worst case, this could be escalated to XSS by tricking the attribute_effect function into setting dangerous HTML attributes like innerHTML.
The patch addresses this vulnerability comprehensively:
- Prevents Clobbering: It replaces all clobberable string-based property names with JavaScript
Symbols. Since Symbols are unique and cannot be created from user-provided strings in attributes, this effectively isolates Svelte's internal state from the DOM and prevents it from being overwritten.
- Hardens Attribute Spreading: As a defense-in-depth measure, the
get_setters function was updated to explicitly block dangerous attributes (innerHTML, textContent, innerText) from being set via attribute spreading, closing a direct XSS vector.
- Fixes SSR Vulnerability: A related issue was fixed in the server-side rendering logic to disallow empty attribute names, preventing another potential injection vector.
The identified vulnerable functions (attribute_effect, get_setters, set_class, set_style, set_text, and attributes) are the exact locations in the codebase where this vulnerable pattern was present and subsequently fixed. During an exploit, these functions would be on the call stack as they process the malicious, clobbering attributes.