GHSA-F48W-9M4C-M7F5
Vulnerability from github – Published: 2026-07-20 23:21 – Updated: 2026-07-20 23:21Summary
The fix for CVE-2026-54298 (GHSA-jrpj-wcv7-9fh9) added an INVALID_ATTR_NAME_CHAR guard to addAttribute() so that spread-prop attribute names containing "' >/= or whitespace are dropped. A second attribute-rendering path, renderHTMLElement() in packages/astro/src/runtime/server/render/dom.ts, has its own inline attribute loop that does not go through addAttribute() and was not updated. It interpolates the attribute name unescaped and only escapes the value, so untrusted prop keys spread onto a native-HTMLElement-subclass component can still break out of the attribute context, resulting in XSS.
Details
renderHTMLElement builds attributes directly:
for (const attr in props) {
attrHTML += ` ${attr}="${toAttributeString(await props[attr])}"`;
}
The attribute name (attr) is interpolated raw; only the value is escaped via toAttributeString. By contrast, the hardened addAttribute in util.ts rejects invalid names:
if (INVALID_ATTR_NAME_CHAR.test(key)) { return ''; } // /[\s"'>/=]/
renderHTMLElement is reached from component.ts when the component is a native HTMLElement subclass:
if (!renderer && typeof HTMLElement === 'function' && componentIsHTMLElement(Component)) {
const output = await renderHTMLElement(result, Component, _props, slots);
}
where _props carries spread props verbatim.
Reachability
The branch only runs when typeof HTMLElement === 'function' at SSR time. In default Node SSR HTMLElement is undefined, so the branch is dead. It becomes reachable when the SSR runtime exposes a global HTMLElement (Deno, Bun with a DOM shim, or jsdom/happy-dom in Node) and a class extending HTMLElement is used directly as an Astro component that receives untrusted-keyed spread props.
Proof of Concept
Given malicious spread props:
const maliciousProps = {
'onmouseover=alert(document.domain) x': 'y',
'x><script>alert(1)</script>': 'z',
};
addAttribute(post-fix) →<my-el></my-el>(key stripped — safe)renderHTMLElement→<my-el onmouseover=alert(document.domain) x="y" x><script>alert(1)</script>="z"></my-el>(handler +<script>injected — XSS)
Equivalent Astro template, served by an SSR runtime that defines a global HTMLElement:
---
import MyElement from '../MyElement.js'; // class MyElement extends HTMLElement {}
const userInput = Astro.url.searchParams; // untrusted keys
---
<MyElement {...Object.fromEntries(userInput)} />
Impact
Cross-site scripting (CWE-79) via attribute-name breakout — the same vulnerability class as CVE-2026-54298, in a code path its fix did not cover. An attacker who controls the keys of an object spread onto a native-HTMLElement-subclass component can inject arbitrary event-handler attributes or sibling elements (including <script>) into the SSR output. Reachability is constrained by the runtime and component preconditions described above.
{
"affected": [
{
"package": {
"ecosystem": "npm",
"name": "astro"
},
"ranges": [
{
"events": [
{
"introduced": "0"
},
{
"fixed": "7.0.6"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-59729"
],
"database_specific": {
"cwe_ids": [
"CWE-79"
],
"github_reviewed": true,
"github_reviewed_at": "2026-07-20T23:21:58Z",
"nvd_published_at": null,
"severity": "MODERATE"
},
"details": "## Summary\n\nThe fix for CVE-2026-54298 (GHSA-jrpj-wcv7-9fh9) added an `INVALID_ATTR_NAME_CHAR` guard to `addAttribute()` so that spread-prop attribute names containing `\"\u0027 \u003e/=` or whitespace are dropped. A second attribute-rendering path, `renderHTMLElement()` in `packages/astro/src/runtime/server/render/dom.ts`, has its own inline attribute loop that does not go through `addAttribute()` and was not updated. It interpolates the attribute name unescaped and only escapes the value, so untrusted prop keys spread onto a native-`HTMLElement`-subclass component can still break out of the attribute context, resulting in XSS.\n\n## Details\n\n`renderHTMLElement` builds attributes directly:\n\n```js\nfor (const attr in props) {\n attrHTML += ` ${attr}=\"${toAttributeString(await props[attr])}\"`;\n}\n```\n\nThe attribute name (`attr`) is interpolated raw; only the value is escaped via `toAttributeString`. By contrast, the hardened `addAttribute` in `util.ts` rejects invalid names:\n\n```js\nif (INVALID_ATTR_NAME_CHAR.test(key)) { return \u0027\u0027; } // /[\\s\"\u0027\u003e/=]/\n```\n\n`renderHTMLElement` is reached from `component.ts` when the component is a native `HTMLElement` subclass:\n\n```js\nif (!renderer \u0026\u0026 typeof HTMLElement === \u0027function\u0027 \u0026\u0026 componentIsHTMLElement(Component)) {\n const output = await renderHTMLElement(result, Component, _props, slots);\n}\n```\n\nwhere `_props` carries spread props verbatim.\n\n### Reachability\n\nThe branch only runs when `typeof HTMLElement === \u0027function\u0027` at SSR time. In default Node SSR `HTMLElement` is `undefined`, so the branch is dead. It becomes reachable when the SSR runtime exposes a global `HTMLElement` (Deno, Bun with a DOM shim, or jsdom/happy-dom in Node) **and** a class extending `HTMLElement` is used directly as an Astro component that receives untrusted-keyed spread props.\n\n## Proof of Concept\n\nGiven malicious spread props:\n\n```js\nconst maliciousProps = {\n \u0027onmouseover=alert(document.domain) x\u0027: \u0027y\u0027,\n \u0027x\u003e\u003cscript\u003ealert(1)\u003c/script\u003e\u0027: \u0027z\u0027,\n};\n```\n\n- `addAttribute` (post-fix) \u2192 `\u003cmy-el\u003e\u003c/my-el\u003e` (key stripped \u2014 safe)\n- `renderHTMLElement` \u2192 `\u003cmy-el onmouseover=alert(document.domain) x=\"y\" x\u003e\u003cscript\u003ealert(1)\u003c/script\u003e=\"z\"\u003e\u003c/my-el\u003e` (handler + `\u003cscript\u003e` injected \u2014 XSS)\n\nEquivalent Astro template, served by an SSR runtime that defines a global `HTMLElement`:\n\n```astro\n---\nimport MyElement from \u0027../MyElement.js\u0027; // class MyElement extends HTMLElement {}\nconst userInput = Astro.url.searchParams; // untrusted keys\n---\n\u003cMyElement {...Object.fromEntries(userInput)} /\u003e\n```\n\n## Impact\n\nCross-site scripting (CWE-79) via attribute-name breakout \u2014 the same vulnerability class as CVE-2026-54298, in a code path its fix did not cover. An attacker who controls the keys of an object spread onto a native-`HTMLElement`-subclass component can inject arbitrary event-handler attributes or sibling elements (including `\u003cscript\u003e`) into the SSR output. Reachability is constrained by the runtime and component preconditions described above.",
"id": "GHSA-f48w-9m4c-m7f5",
"modified": "2026-07-20T23:21:59Z",
"published": "2026-07-20T23:21:58Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/withastro/astro/security/advisories/GHSA-f48w-9m4c-m7f5"
},
{
"type": "WEB",
"url": "https://github.com/withastro/astro/pull/17251"
},
{
"type": "WEB",
"url": "https://github.com/withastro/astro/commit/5240e26c9dd91f9bc7140dcfacdb48d5a132830d"
},
{
"type": "PACKAGE",
"url": "https://github.com/withastro/astro"
},
{
"type": "WEB",
"url": "https://github.com/withastro/astro/releases/tag/astro@7.0.6"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:A/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N",
"type": "CVSS_V4"
}
],
"summary": "Astro: XSS via unescaped spread attribute names in renderHTMLElement (incomplete fix for CVE-2026-54298)"
}
Sightings
| Author | Source | Type | Date | Other |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.