All vulnerabilities

Servers and applications

CVE-2026-41067

XSS via incomplete `</script>` sanitization in `define:vars` allows case-insensitive and whitespace-based bypass

Severity
Medium 6.1
Published
20 Apr 2026
Last changed
20 Apr 2026
Added to UpHeron
3 Nov 2026
Fixed in
6.1.6
Exploit chance
0.2% in the next 30 daysHigher than 8% of CVEs. EPSS by FIRST, 18 Nov 2026
Weakness
Cross-site scripting (CWE-79)
Attack
Over the network · No login needed · Needs someone to click or open something
Attacker can
Read some data · Change some data
CVSS vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
Also known as
GHSA-j687-52p2-xcff
Sources
Project advisories (GitHub)

Description

The defineScriptVars function in Astro's server-side rendering pipeline uses a case-sensitive regex /<\/script>/g to sanitize values injected into inline `

, , or and inject arbitrary HTML/JavaScript.

The vulnerable function is defineScriptVars at packages/astro/src/runtime/server/render/util.ts:42-53:

This function is called from renderElement at util.ts:172-174 when a `

, , — HTML tag names are case-insensitive but the regex has no i` flag.

  • Whitespace before >: , , — after the tag name, the HTML tokenizer enters the "before attribute name" state on ASCII whitespace.
  • Self-closing slash: — the tokenizer enters "self-closing start tag" state on /`.

JSON.stringify() does not escape <, >, or / characters, so all these payloads pass through serialization unchanged.

Execution flow: User-controlled input (e.g., Astro.url.searchParams) → assigned to a variable → passed via define:vars on a `

From withastro/astro's security advisory. Shortened; the full text is there.

Affected software

SoftwareAffected versions
AstroServers and applications · github:withastro/astro
  • Every version before 6.1.6

About Astro

The web framework for content-driven websites.

From its GitHub repository.
Developers who used it in the past year
4.5%Stack Overflow Developer Survey 2025, 2025
Weekly downloads (npm)
11,910,147npm, 15 Nov 2026
GitHub stars
63,954GitHub, 15 Nov 2026
Forks
3,922GitHub, 15 Nov 2026
Latest release
@astrojs/[email protected]GitHub, 15 Nov 2026
Released
13 Nov 2026GitHub
First published on GitHub
15 Mar 2021GitHub

References