Astro: XSS via unescaped spread attribute names in renderHTMLElement (incomplete fix for CVE-2026-54298)
위협 신호 · CVSS · EPSS · KEV
이론적 심각도 점수
예측 데이터 없음
실측 악용 기록 없음
계획된 패치 주기 내 조치(60일 이내)
CVSS 벡터 · 메트릭
CVSS 벡터 정보 없음
상세 설명
Summary
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:
1for (const attr in props) { 2 attrHTML += ` ${attr}="${toAttributeString(await props[attr])}"`; 3}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:
1if (INVALID_ATTR_NAME_CHAR.test(key)) { return ''; } // /[\s"'>/=]/renderHTMLElement is reached from component.ts when the component is a native HTMLElement subclass:
1if (!renderer && typeof HTMLElement === 'function' && componentIsHTMLElement(Component)) { 2 const output = await renderHTMLElement(result, Component, _props, slots); 3}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:
1const maliciousProps = { 2 'onmouseover=alert(document.domain) x': 'y', 3 'x><script>alert(1)</script>': 'z', 4};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:
1--- 2import MyElement from '../MyElement.js'; // class MyElement extends HTMLElement {} 3const userInput = Astro.url.searchParams; // untrusted keys 4--- 5<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.
AI 심층 분석
공격 시나리오 · 재현 가능한 PoC 페이로드 · 즉시 적용 가능한 차단 패치를 한 번에 받아 보세요. 보안 운영팀이 그대로 점검·티켓팅에 쓸 수 있는 형태로 정리해 드립니다.
참고 자료 5
링크 내용 불러오는 중…