Above line 494 of packages/svelte/src/utils.js, ten lines of comment tell you what the regex is for. It rejects whitespace, quotes, angle brackets, slashes, equals, "or other characters that could break out of a tag-name token and enable markup injection." It is an XSS gate. Six lines further down the file tree, in packages/svelte/src/internal/server/index.js, the Svelte 5 SSR runtime calls the same regex against the user-supplied tag field of <svelte:element this={tag}> before concatenating that value into the response stream. CVE-2026-42567 is the input a-----------------------------------!, thirty-five hyphens and a terminator, hanging the SSR worker the gate was meant to protect.
CVE-2026-42567: Svelte's `<svelte:element>` Tag Validator Hangs On Strings It Was Written To Reject
vendor
pattern
cve
proof of concept
The regex was added to prevent markup injection
REGEX_VALID_TAG_NAME is exported from packages/svelte/src/utils.js. The maintainers wrote ten lines of comment above it to name its role:
// Matches valid HTML/SVG/MathML element names and custom element names.
// https://html.spec.whatwg.org/multipage/custom-elements.html#valid-custom-element-name
//
// Standard elements: ASCII alpha start, followed by ASCII alphanumerics.
// Custom elements: ASCII alpha start, followed by any mix of PCENChar (which
// includes ASCII alphanumerics, `-`, `.`, `_`, and specified Unicode ranges),
// with at least one hyphen required somewhere after the first character.
//
// Rejects strings containing whitespace, quotes, angle brackets, slashes, equals,
// or other characters that could break out of a tag-name token and enable markup injection.
export const REGEX_VALID_TAG_NAME =
/^[a-zA-Z][a-zA-Z0-9]*(-[a-zA-Z0-9.\-_\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}]+)*$/u;The regex's purpose, in the maintainers' own words, is to keep characters that "break out of a tag-name token" away from the renderer. It is a defensive primitive. The threat it was written against is markup injection, the canonical web-framework concern about user-controllable HTML.
Six lines down the same package, packages/svelte/src/internal/server/index.js exports the runtime function that backs <svelte:element> in SSR:
export function element(renderer, tag, attributes_fn = noop, children_fn = noop) {
renderer.push('<!---->');
if (tag) {
if (!REGEX_VALID_TAG_NAME.test(tag)) {
e.dynamic_element_invalid_tag(tag);
}
renderer.push(`<${tag}`);
attributes_fn();
renderer.push(`>`);
if (!is_void(tag)) {
children_fn();
if (!is_raw_text_element(tag)) {
renderer.push(EMPTY_COMMENT);
}
renderer.push(`</${tag}>`);
}
}
renderer.push('<!---->');
}The tag argument arrives from the compiled output of any <svelte:element this={expression}></svelte:element> in any Svelte 5 component rendered server-side. The regex .test() runs synchronously on the SSR worker's Node event loop, before any byte of the response is written. The gate has to clear before the renderer concatenates <${tag}.
That is the wiring: a defensive validator, designed to reject markup-breaking characters, run synchronously on attacker-controlled input on the server-side hot path. CVE-2026-42567 is what happens when the same wiring is exercised by an input the gate rejects.
The outer quantifier owns dashes the inner quantifier can also own
Strip the comment. Strip the Unicode ranges. The pre-patch regex is structurally:
/^[a-zA-Z][a-zA-Z0-9]*(-[CHARS]+)*$/uwhere CHARS is a character class that includes a-zA-Z0-9, the literal ., the literal -, the literal _, and the PCENChar Unicode ranges.
The grammar the maintainers were reaching for: an HTML standard element name (ASCII alpha plus alphanumerics) or a custom element name (a hyphen-separated identifier whose segments can contain PCENChar characters). The custom-elements spec treats the hyphen as the segment separator. The regex encodes the same grammar two ways: the outer (-[CHARS]+)* says "zero or more hyphen-separated segments," and the inner [CHARS]+ says "each segment contains one or more characters from the PCENChar set."
The structural mistake is that the inner CHARS set contains the literal hyphen. PCENChar lists - as a valid intra-segment character; the regex inherits that. So the same byte, a -, can be consumed either as the leading literal - of the next outer iteration or as a character inside the current inner +. Two readings of the same input.
(-X+)* with - inside X is the textbook nested-quantifier ReDoS shape. For an N-hyphen input followed by a character that fails the trailing $, the engine can partition the hyphen run into outer iterations in any of 2^(N-1) ways, and a failing terminator forces it to try them all.
The upstream regression test that ships with the patch picks the smallest convincing payload:
test('REGEX_VALID_TAG_NAME no ReDoS', () => {
const before = performance.now();
REGEX_VALID_TAG_NAME.test('a-----------------------------------!');
const after = performance.now();
if (after - before > 10) {
throw new Error(`REGEX_VALID_TAG_NAME is vulnerable to ReDoS`);
}
});Thirty-five hyphens and an exclamation mark. The leading a matches ^[a-zA-Z]. The second class [a-zA-Z0-9]* matches empty. The engine now reaches (-[CHARS]+)* with -----------------------------------! left to consume. Each iteration eats one leading - and at least one character from CHARS. CHARS includes -, so each iteration can eat any number of trailing hyphens. The engine tries every partition. The ! at the end fails $. The engine backtracks through 2^34 partitions. On a Node SSR worker, the regex does not return for the rest of the request lifecycle, and because Node's event loop is single-threaded per worker, neither does anything else that worker is handling.
The CVSS vector for CVE-2026-42567 reads AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H. Availability High, network-reachable, no authentication, no user interaction. The advisory frames the impact as "exhausting computational resources through regex backtracking." Read in reverse: the worker is hung by a 36-character body.
The patch flattens the quantifier; it does not change the grammar
The commit that ships the fix, d2375e2ebcab5c88feb5652f1a9d621b8f06b259, has commit message fix: harden regex. The diff is one line:
diff --git a/packages/svelte/src/utils.js b/packages/svelte/src/utils.js
@@ -491,7 +491,7 @@ export function is_raw_text_element(name) {
// Rejects strings containing whitespace, quotes, angle brackets, slashes, equals,
// or other characters that could break out of a tag-name token and enable markup injection.
export const REGEX_VALID_TAG_NAME =
- /^[a-zA-Z][a-zA-Z0-9]*(-[a-zA-Z0-9.\-_\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}]+)*$/u;
+ /^[a-zA-Z][a-zA-Z0-9]*(-[a-zA-Z0-9.\-_\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C-\u200D\u203F-\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u{10000}-\u{EFFFF}]*)?$/u;Two characters changed at the tail of the outer group. The pre-patch shape is (-[CHARS]+)*. The post-patch shape is (-[CHARS]*)?. The required-then-repeated nested group becomes a single optional non-repeated group.
The inner character class still contains -. The patch did not remove it. PCENChar still admits intra-segment hyphens; the maintainers preserved the character set the comment describes. What they removed is the engine's option to partition the hyphen run across multiple outer iterations, because there are no outer iterations anymore. The matcher has exactly one structural path through any run of hyphens: greedy consumption inside the single optional inner *. No backtracking is possible because there is no ambiguity for the engine to backtrack into.
The accepted language is materially unchanged for any input that would reach a sensible developer's keyboard. The pre-patch regex matched my-custom-element in a single outer iteration, with the inner [CHARS]+ greedily consuming custom-element because - is in CHARS. The post-patch regex matches the same string by the same path: one optional segment whose inner class consumes custom-element in a single pass. A caller who only ever passes valid custom-element names sees no behavioral change. A caller who passes a-----------------------------------! sees the regex return in microseconds instead of geological time.
This is not grammar repair. The grammar the comment describes is still encoded in the same wrong way: the segment separator is a member of the segment alphabet, so the regex would still be linguistically ambiguous if any caller cared. The patch repairs only the engine's worst case, by removing the structural feature the worst case depends on.
The "unconstrained tag length" caveat is the application-developer footgun
The GHSA advisory carries a narrowing clause: "The vulnerability only affects applications that accept unconstrained tag lengths. Systems using predefined tag lists or enforcing length restrictions remain unaffected." A developer reading the advisory may take that as reassurance.
It is not reassurance. It is a description of the population.
<svelte:element this={tag}> is the runtime escape hatch for any Svelte component that needs to pick the wrapping element name at render time. The canonical use cases are the ones that hand the choice to a non-developer: a CMS block whose author picks h2 or h3, a Markdown extension that maps shortcodes to wrapping tags, a low-code page builder whose editor surface exposes "wrap in
The defensive convention the framework expects is that the application layer enforces a length cap or an allowlist before the string reaches <svelte:element>. The framework does not enforce either. The character set the regex rejects (whitespace, quotes, angle brackets, slashes, equals) does not include the byte the worst case is built from (the literal -, which is a legal custom-element character). The regex's accept criterion is "the string looks like a tag name." A 36-byte string of hyphens looks enough like one to drive the engine into its worst case before the validator decides the verdict.
The reject branch is what costs
A regex matcher built on backtracking has two cost regimes. The accept regime is the cost of finding any single path through the input that reaches the trailing anchor. The reject regime is the cost of proving no such path exists. The first regime terminates the moment a match is found. The second regime terminates only when every possible path has been tried.
The accept regime for REGEX_VALID_TAG_NAME is linear in the input length for any string that the grammar accepts. The reject regime, before the patch, was exponential in the count of trailing hyphens for any string that fails the trailing anchor. The accept path is what the comment block describes. The reject path is what the comment block does not.
The validator's defensive purpose is rejection. Its caller, the SSR runtime, invokes it for exactly the reason that rejection might be required: the input is untrusted and the output is markup. The validator's job is to make rejection happen as often as the input requires. The validator's worst case is the same path.
We are naming the class: validation is the cost. A defensive validator whose acceptance is cheap and whose rejection requires exhaustive search puts the rejection cost on the attacker's clock. The validator's accept set is the strings the caller would have allowed anyway. The validator's reject set is everywhere else, and the attacker selects the input from anywhere in either set. When the rejection path's worst-case cost grows without bound with respect to input length, the gate's defensive utility and the gate's DoS primitive are the same artifact.
CWE-1333 names the engine-shape symptom (inefficient regular expression complexity). The pattern is larger than regex engines. Any input validator whose runtime is bounded only by the input distribution it expects, called on an input distribution the attacker chooses, has the same shape.
The release notes say "fix: harden regex"
The Svelte 5.55.7 release shipped on May 14, 2026. Five bullets, in order:
fix: prevent XSS on hydratable from user contents- Devalue dependency bump
fix: disallow empty attribute names during SSRfix: harden regexfix: move Svelte runtime properties to symbols
Bullet four is this CVE. The bullet does not name <svelte:element>. The bullet does not name REGEX_VALID_TAG_NAME. The bullet does not name ReDoS. The bullet does not link the advisory. The changeset filename, .changeset/proud-dogs-go.md, contains the same four-word phrase and nothing else.
The advisory was published twenty-six days later, on June 9, 2026. The advisory deliberately does not quote the regex. The advisory does not link the commit. A reader following the advisory's reference list reaches the release-notes page and reads fix: harden regex. A reader following the release-notes page does not reach the advisory.
This is not concealment. It is the modal disclosure shape for a CVE in a popular framework: the patch ships in the next routine release, the advisory points at the release, the release does not point at the advisory, and the commit that closes the gap is one of five bullets in a changelog whose other bullets touch unrelated subsystems. The reader who reads both connects the dots. The reader who reads either alone does not.
For twenty-six days, the patch was a public commit on a high-visibility repository and the CVE was not yet a record. Anyone reading the Svelte git log during that window had the disclosure. Anyone running 5.51.5 through 5.55.6 in production and watching the CVE feed instead did not.
The accept path is constant. The reject path is whatever the attacker types.