Low

Astro: XSS via attribute injection in dynamic tag names

  • Disclosed: 13.11.2026
  • Updated: 13.11.2026 21:17

Summary

When a dynamic tag (const Tag = ...; <Tag />) resolves to a string, Astro renders it as a raw HTML element name. The name was filtered to remove characters that could inject attributes, but the filter did not handle /. Because HTML parsers treat / inside a tag as an attribute separator, a tag name such as img/src/onerror=alert(1) was rendered as an <img> element with an onerror attribute. The JSX renderer used for MDX did not filter string tag names at all.

For example:

astro
---
const Tag = Astro.url.searchParams.get('as') ?? 'div';
---
<Tag>hello</Tag>

rendered ?as=img/src/onerror=alert(1) as live HTML.

Impact

Reflected or stored cross-site scripting, but only in applications that use untrusted input (such as a request parameter or an uncontrolled CMS field) as all or part of an element name. Astro itself never derives element names from request data.

Applications that let content choose an element should map that input to a fixed set of known tags. Letting untrusted input choose an element name is unsafe even with a correct filter, because it can still select elements such as script or iframe.

Affected versions

astro <= 7.4.4.

Patches

Fixed in astro 7.4.5. String tag names in .astro dynamic tags, JSX, and MDX now render only the leading valid element name, so characters such as / or = can no longer change the generated markup. Strings that do not start with a valid element name now throw an error.

Workarounds

Upgrade to astro 7.4.5 or later. Before upgrading, do not use untrusted input as an element name, or map it to a fixed set of known tags.

Credits

Reported by @uttej-badwane.

Affected software

Click a technology to see all vulnerabilities affecting it.

PlatformPackageVulnerable versionsFixed in
npm package astro < 7.4.5 7.4.5

References

CVSS score -
CVSS vector
CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:P/VC:L/VI:L/VA:N/SC:L/SI:L/SA:N
Weakness (CWE)
CWE-184, CWE-79
Platform
npm
Package
astro
Disclosed
13.11.2026
Updated
13.11.2026 21:17

Sources and licenses

OSV / GitHub Advisory Database - GHSA-mh32-jxcr-mh9f - CC BY 4.0

Vulnerability history: astro

All published vulnerabilities of this package (npm package), newest first. Shows whether this is a one-off slip or a package that needs watching.

All (31) in the archive
Total entries
31
First → latest
10.2024 11.2026
Without a fix
0
Exploited in attacks
0

Severity breakdown

  • Critical 1
  • High 6
  • Medium 17
  • Low 7

Disclosures per year

  1. 2024: 3
  2. 2025: 11
  3. 2026: 17
Severity:
  1. Astro: XSS via attribute injection in dynamic tag names this entry
    Low CVE-2026-126361 < 7.4.5 7.4.5
  2. Critical · 9.8 ghsa-26w7-cxv4-gfx2 < 7.2.8 7.2.8
  3. High · 7.5 CVE-2026-54299 < 6.4.6 6.4.6
  4. High · 7.1 CVE-2026-50146 < 6.3.3 6.3.3
  5. High · 7.1 CVE-2025-64764 < 5.15.8 5.15.8
  6. High · 7.2 CVE-2025-59837 >= 5.13.4, < 5.13.10 5.13.10
  7. High CVE-2024-56159 >= 5.0.0-alpha.0, < 5.0.8, < 4.16.18 5.0.8, 4.16.18

Know which vulnerabilities affect your application

With the DockRay integration and software inventory enabled, DockRay checks reported component versions against known vulnerabilities and notifies you about confirmed matches. Coverage depends on the supported technology and available advisory data.

Connect your application
DockRay newsletter

Application security in your inbox

Important vulnerabilities, actionable guidance and practical advice for your applications. Choose your technologies and follow what matters to your project.

  • A daily digest of new vulnerabilities, critical ones included.
  • Notifications about important updates.
  • Practical advice on application security and monitoring.

Leave empty to receive updates for every technology.

Free to subscribe. Unsubscribe with one click in any email.