-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 NEFARIOUSPLAN-CANONICAL-V1 {"body_md":"## The 5.51.5 patch said what it was for\n\nThe February 18, 2026 commit (`a0c7f289`) carries the changeset title \"fix: strip event handlers during SSR\". The diff to `packages/svelte/src/internal/server/index.js` is three lines, inside the `attributes()` function that handles spread attributes during server-side rendering:\n\n```diff\n+\t\t// omit event handler attributes\n+\t\tif (name.length > 2 && name.startsWith('on')) continue;\n+\n```\n\nThat is the entire mechanism. For every key in the attribute object, before the renderer emits it into the HTML output, the key is tested: is its length greater than two, and do its first two characters spell `on`. If yes, skip. The companion test file `spread-attributes-event-handler-xss/main.svelte`, created in the same commit, declares the input the test verifies:\n\n```svelte\n\n\n
content
\n\"photo\"\n```\n\nThe expected output asserts:\n\n```html\n
content
\n\n\"photo\"\n```\n\nSix event-handler names tested. Every one starts with the literal characters `on`. Every one is longer than two characters. Every one is caught by `name.startsWith('on')`. The filter and the test describe the same syntactic object: an attribute name whose first two characters are `o` and `n`. As a description of the attacker's primitive, this is incomplete in a way the test cases could not surface, because the inputs were chosen by the same author who chose the filter.\n\n## The HTML parser does not require an attribute name to start where the JavaScript string starts\n\nInside the spread loop, `name` is a key off a plain object. After the denylist checks, the renderer hands the key to `attr()` in `packages/svelte/src/internal/shared/attributes.js`:\n\n```js\nexport function attr(name, value, is_boolean = false) {\n\tif (value == null || (!value && is_boolean)) return '';\n\tconst normalized = (has_own_property.call(replacements, name) && replacements[name].get(value)) || value;\n\tconst assignment = is_boolean ? `=\"\"` : `=\"${escape_html(normalized, true)}\"`;\n\treturn ` ${name}${assignment}`;\n}\n```\n\nThe return value is a leading space, then the key, then the assignment. The leading space the function prepends is a separator between this attribute and whatever came before it. The key itself is interpolated verbatim, with no further inspection.\n\nFor an object key whose JavaScript representation is `' onload'`, the emitted text becomes ` onload=\"alert(1)\"`. The space `attr()` prepended is one character; the leading space of the key is the next character. Concatenated onto the open tag, the HTML the browser receives reads:\n\n```html\n
content
\n```\n\nThe HTML5 tokenization specification handles whitespace between attributes by consuming one or more whitespace characters before each attribute name. Two spaces, a tab, a non-breaking space all collapse into the same \"this is where the next attribute begins\" state. When the parser advances past the leading whitespace, the next attribute name is `onload`. The element's event-handler set picks up `onload`, and a click, mouseover, or initial layout event triggers the inline handler.\n\nThe JavaScript filter inspected the key as a string and asked \"does this string begin with the characters `o` then `n`\". The HTML parser inspected the same characters as a token stream and asked \"where, past any whitespace separators, does the next attribute name begin\". The two grammars describe the same syntactic object, an event-handler attribute name, and they do not agree about where the name starts. This is the [gate-narrower-than-sink](/patterns/gate-narrower-than-sink) shape the catalog has accumulated across [shell-quote's regex character class against POSIX sh](/posts/shell-quote-cve-2026-9277-dot-was-not-every-character) and [Starlette's `request.url.path` against the ASGI router](/posts/starlette-cve-2026-48710-request-url-path-is-not-the-requests-path). One grammar checks; one grammar runs. The bypass is the gap.\n\n## The 5.55.7 patch enumerates five more shapes\n\nThe May 14, 2026 commit (`547853e2`), addressed in CVE-2026-42599 and GHSA-pr6f-5x2q-rwfp, carries the changeset title \"fix: disallow empty attribute names during SSR\". The diff inside the same `attributes()` function changes one line:\n\n```diff\n-\t\tif (INVALID_ATTR_NAME_CHAR_REGEX.test(name)) continue;\n+\t\tif (name === '' || INVALID_ATTR_NAME_CHAR_REGEX.test(name)) continue;\n```\n\nThe companion change is in the test file. The original four event-handler keys are kept. Five new keys are added:\n\n```svelte\nconst userdata = {\n\tid: 'profile-123',\n\tclass: 'card',\n\tonclick: 'alert(1)',\n\tonerror: 'alert(1)',\n\tonfocus: 'alert(1)',\n\tonmouseover: 'alert(1)',\n\t' onload': 'alert(1)',\n\t'\\tonload': 'alert(1)',\n\t'\\u00a0onload': 'alert(1)',\n\t'\\t': '/onmouseover=alert(1)//',\n\t'': '/onmouseover=alert(1)//'\n};\n```\n\nEach addition is a shape the 5.51.5 filter passed through.\n\n- `' onload'`, leading ASCII space. `' onload'.startsWith('on')` returns false. The browser's whitespace consumption strips the space and registers `onload`.\n- `'\\tonload'`, leading horizontal tab. `'\\tonload'.startsWith('on')` returns false. The browser strips the tab and registers `onload`.\n- `'\\u00a0onload'`, leading non-breaking space. `'\\u00a0onload'.startsWith('on')` returns false. The HTML tokenizer treats U+00A0 as ASCII whitespace for attribute-list parsing in the lenient browsers the framework supports, and registers `onload`.\n- `'\\t'`, a key whose entire string content is a tab. `'\\t'.startsWith('on')` is false; length is one. Before the patch, the renderer would emit ` \\t=\"/onmouseover=alert(1)//\"`. The browser sees a malformed attribute whose value the lenient parser extracts `onmouseover=alert(1)` from.\n- `''`, the empty string. Length zero. Before the patch, the renderer emitted ` =\"/onmouseover=alert(1)//\"`. Same lenient-parser extraction of `onmouseover` from the value side of the malformed attribute.\n\nThe new condition catches all five. `INVALID_ATTR_NAME_CHAR_REGEX` is `/[\\s'\">/=\\u{FDD0}-\\u{FDEF}...]/u`, with the `u` flag. In Unicode-flag regex, `\\s` matches U+00A0 along with every other whitespace code point the HTML tokenizer's separator class covers. Names containing whitespace are rejected. Names containing `=`, `>`, `/`, or `\"` are rejected. The empty-string case earns its own equality check because the regex character class does not match against the empty string. Eighty-five days after the first patch, the filter has been widened to describe approximately what the HTML parser was already doing in 5.51.5.\n\n## What the patch still does not enumerate\n\nThe full post-5.55.7 filter chain inside `attributes()` reads, in order:\n\n```js\nfor (name of Object.keys(attrs)) {\n\tif (typeof attrs[name] === 'function') continue;\n\tif (name[0] === '$' && name[1] === '$') continue;\n\tif (name === '' || INVALID_ATTR_NAME_CHAR_REGEX.test(name)) continue;\n\n\tvar value = attrs[name];\n\tvar lower = name.toLowerCase();\n\n\tif (lowercase) name = lower;\n\n\t// omit event handler attributes\n\tif (lower.length > 2 && lower.startsWith('on')) continue;\n\t// ...\n\tattr_str += attr(name, value, is_html && is_boolean_attribute(name));\n}\n```\n\nIt is a denylist. Functions are denied because Svelte's reactivity puts function values on attribute objects. Keys with the `$$` prefix are denied because the compiler uses double-dollar as an internal marker. Empty and invalid-character names are denied because the HTML parser tolerates them as bypasses to the next clause. Names that lowercase to begin with `on` are denied because they map to event handlers. Everything else is emitted to the HTML output verbatim, with the value escaped only for double quotes and angle brackets.\n\n`