The vulnerability is a Regular Expression Denial of Service (ReDoS) within the Svelte runtime, specifically affecting the validation of tag names in <svelte:element>. The root cause is an inefficient regular expression, REGEX_VALID_TAG_NAME, which contains nested quantifiers ((...)+)*) that can lead to exponential backtracking and catastrophic performance when processing certain input strings.
The security patch, identified in commit d2375e2ebcab5c88feb5652f1a9d621b8f06b259, addresses this by modifying the regex in packages/svelte/src/utils.js to a more efficient form, (...)*)?, thus eliminating the potential for ReDoS.
While the patch itself only modifies the regex definition, the actual vulnerability is triggered within the functions that invoke this regex. Analysis of the Svelte source code reveals two key functions where this occurs:
-
get_tag (client-side): This function is responsible for processing the this attribute of <svelte:element> in the browser. When it validates the tag name using the vulnerable regex, a malicious input can freeze the user's browser.
-
render_svelte_element (server-side): During server-side rendering, this function performs the same validation. A malicious tag can cause the server's Node.js process to hang, making the application unavailable to all users.
Therefore, during an exploit, these two functions would be the ones consuming excessive CPU time and would be prominently featured in any runtime profile or stack trace, indicating the source of the performance degradation.