Summary
Astro: XSS via unescaped spread attribute names in renderHTMLElement (incomplete fix for CVE-2026-54298)
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.
Untrusted input is rendered as active markup in a victim's browser, which can run script in their session. Typical impact: session or credential theft, and actions taken as the user.
Affected versions
Security releases
Kodem intelligence
Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.
Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.
Already deployed Kodem?
See it in your environmentNew to Kodem? Get a demo →Remediation advice
Kodem Kai can prioritize this vulnerability in your dependency tree and generate a fix recommendation.
Frequently Asked Questions
- What is CVE-2026-59729? CVE-2026-59729 is a medium-severity cross-site scripting (XSS) vulnerability in astro (npm), affecting versions < 7.0.6. It is fixed in 7.0.6. Untrusted input is rendered as active markup in a victim's browser, which can run script in their session.
- Which versions of astro are affected by CVE-2026-59729? astro (npm) versions < 7.0.6 is affected.
- Is there a fix for CVE-2026-59729? Yes. CVE-2026-59729 is fixed in 7.0.6. Upgrade to this version or later.
- Is CVE-2026-59729 exploitable, and should I be worried? Whether CVE-2026-59729 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
- What actually determines whether CVE-2026-59729 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
- How do I fix CVE-2026-59729? Upgrade
astroto 7.0.6 or later.