{"id":"CVE-2026-59729","aliases":["CVE-2026-59729","GHSA-f48w-9m4c-m7f5"],"related":[],"kind":"vulnerability","state":"published","title":"Astro: XSS via unescaped spread attribute names in renderHTMLElement (incomplete fix for CVE-2026-54298)","summary":"Astro is a web framework for content-driven websites. Versions prior to 7.0.6 are vulnerable to XSS through unescaped spread attribute names in renderHTMLElement. 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. This issue has been fixed in version 7.0.6.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Astro is a web framework for content-driven websites. Versions prior to 7.0.6 are vulnerable to XSS through unescaped spread attribute names in renderHTMLElement. 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. This issue has been fixed in version 7.0.6.","source":"cvelist"},{"lang":"en","text":"## 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 `\"' >/=` 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 ''; } // /[\\s\"'>/=]/\n```\n\n`renderHTMLElement` is reached from `component.ts` when the component is a native `HTMLElement` subclass:\n\n```js\nif (!renderer && typeof HTMLElement === 'function' && 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 === '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.\n\n## Proof of Concept\n\nGiven malicious spread props:\n\n```js\nconst maliciousProps = {\n  'onmouseover=alert(document.domain) x': 'y',\n  'x><script>alert(1)</script>': 'z',\n};\n```\n\n- `addAttribute` (post-fix) → `<my-el></my-el>` (key stripped — safe)\n- `renderHTMLElement` → `<my-el onmouseover=alert(document.domain) x=\"y\" x><script>alert(1)</script>=\"z\"></my-el>` (handler + `<script>` injected — XSS)\n\nEquivalent Astro template, served by an SSR runtime that defines a global `HTMLElement`:\n\n```astro\n---\nimport MyElement from '../MyElement.js'; // class MyElement extends HTMLElement {}\nconst userInput = Astro.url.searchParams;  // untrusted keys\n---\n<MyElement {...Object.fromEntries(userInput)} />\n```\n\n## Impact\n\nCross-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.","format":"markdown","source":"ghsa"},{"lang":"es","text":"Astro es un framework web para sitios web basados en contenido. Las versiones anteriores a la 7.0.6 son vulnerables a XSS a través de nombres de atributos de propagación sin escapar en renderHTMLElement. La corrección para CVE-2026-54298 (GHSA-jrpj-wcv7-9fh9) añadió una protección INVALID_ATTR_NAME_CHAR a addAttribute() para que los nombres de atributos de propiedades de propagación que contengan ’ >/= o espacios en blanco sean descartados. Una segunda ruta de renderizado de atributos, renderHTMLElement() en packages/astro/src/runtime/server/render/dom.ts, tiene su propio bucle de atributos en línea que no pasa por addAttribute() y no fue actualizada. Interpola el nombre del atributo sin escapar y solo escapa el valor, por lo que las claves de propiedades no confiables propagadas a un componente de subclase de HTMLElement nativo aún pueden salirse del contexto del atributo. Este problema ha sido corregido en la versión 7.0.6.","source":"nvd"}],"published":"2026-07-20T23:21:58.000Z","modified":"2026-10-24T13:10:00.147Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"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","score":5.1,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"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","score":5.1,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"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","rating":"MEDIUM"}],"cwes":["CWE-79"],"affected":[{"ranges":[{"version":"< 7.0.6","status":"affected"}],"vendor":"withastro","product":"astro","source":"cvelist"},{"ranges":[{"type":"semver","introduced":"0","status":"affected","fixed":"7.0.6"}],"ecosystem":"npm","package":"astro","purl":"pkg:npm/astro","source":"ghsa"}],"references":[{"url":"https://github.com/withastro/astro/security/advisories/GHSA-f48w-9m4c-m7f5","tags":["exploit","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/withastro/astro/pull/17251","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/withastro/astro/commit/5240e26c9dd91f9bc7140dcfacdb48d5a132830d","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/withastro/astro/releases/tag/astro@7.0.6","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-59729","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/withastro/astro","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"partial","date":"2026-07-28T13:48:15.250Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-59729","url":"https://www.cve.org/CVERecord?id=CVE-2026-59729","licence":"CVE Terms of Use","modified":"2026-07-28T13:48:46.640Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-f48w-9m4c-m7f5","url":"https://github.com/advisories/GHSA-f48w-9m4c-m7f5","licence":"CC-BY-4.0","modified":"2026-08-12T20:45:07.686Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-59729","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-59729","licence":"Public domain","modified":"2026-10-24T13:10:00.147Z"}],"updatedAt":"2026-11-25T22:59:30.233Z","epss":{"score":0.00473,"percentile":0.42567,"date":"2026-12-01T12:00:22.000Z"}}