Low

Astro: Arbitrary CSS injection in Astro View Transitions

  • Disclosed: 22.10.2026
  • Updated: 22.10.2026 20:17

Summary

Astro's server-side View Transition CSS generator did not keep string animation properties within their generated CSS declarations. In an application that passes attacker-controlled data into an animation property such as duration, a value containing CSS delimiters could terminate the declaration and rule, then add attacker-selected CSS to the server-rendered page.

The injected content remains inside the generated <style> element. It cannot terminate that element or inject HTML or JavaScript because Astro escapes < before emitting the stylesheet.

Severity

Exploitation requires an application to pass untrusted, request-derived, or user-controlled content directly into a transition animation value. This is an uncommon application pattern, and applications using static or otherwise trusted transition values are unaffected.

The resulting capability is limited to CSS in the rendered document. The proof of concept does not demonstrate JavaScript execution, HTML injection, an origin-boundary bypass, or access to server-only data.

Details

Animation values are collected by stringifyAnimations() in packages/astro/src/runtime/server/transition.ts and passed to addAnimationProperty(). String values were converted directly with toString():

ts
function addAnimationProperty(builder: AnimationBuilder, prop: string, value: string | number) {
  let arr = builder[prop];
  if (Array.isArray(arr)) {
    arr.push(value.toString());
  } else {
    builder[prop] = [value.toString()];
  }
}

The animation builder then interpolated each value into a declaration:

ts
out += `\n\t${k}: ${value.join(', ')};`;

The completed stylesheet passes through escapeStyleText(), which escapes literal < characters to keep the content inside its HTML <style> element. CSS delimiters such as ;, {, and } remained active, allowing a value to escape its intended declaration and add another rule.

The shared serializer handles duration, delay, easing, direction, fillMode, and animation names, so custom transition objects using those string properties followed the same path.

The fix encodes CSS declaration delimiters while serializing each animation value. Supported CSS functions and strings, including calc() and var(), remain unchanged.

Proof of Concept

Using astro@7.3.2, create an on-demand rendered page:

astro
---
import { fade } from "astro:transitions";
const duration = Astro.url.searchParams.get("duration") ?? "1ms";
---
<div id="target" transition:animate={fade({ duration })}>SAFE</div>

Request the page with:

/?duration=1ms%3B%7D%23target%7Bcolor%3Argb(1%2C2%2C3)%3Bfont-size%3A37px%7Dx%7Banimation-duration%3A1ms

Before the fix, the generated stylesheet contains an active rule equivalent to:

css
#target {
  color: rgb(1, 2, 3);
  font-size: 37px;
}

In Chromium, the target's computed styles change to rgb(1, 2, 3) and 37px. This behavior is reproducible in a production standalone SSR build, not only in the development server.

Impact

An attacker can inject CSS into the affected application's rendered page when the application places attacker-controlled data into a transition animation value. The CSS can restyle or conceal content, reposition existing controls, add generated text, or otherwise misrepresent the page's UI.

CSS selectors and conditional resource loads may expose data already present in selectable DOM attributes in some applications, depending on the page and its Content Security Policy. The issue does not expose cookies, server-only values, arbitrary DOM text, or cross-origin response data by itself.

Affected Versions

astro >= 7.1.0, <= 7.3.2.

Versions through 7.0.9 are covered by GHSA-4g3v-8h47-v7g6 / CVE-2026-73422, which had the stronger impact of escaping the <style> element and injecting HTML or JavaScript.

Patched Versions

This issue is patched in astro@7.3.3. Fix: https://github.com/withastro/astro/pull/17970

Workarounds

Do not pass untrusted or request-derived values into View Transition animation properties. If dynamic values are required, validate them according to the expected CSS grammar before constructing the transition. For duration and delay, prefer finite numbers or strictly validated CSS time values.

Credits

Reported by @avrlab233.

Affected software

Click a technology to see all vulnerabilities affecting it.

PlatformPackageVulnerable versionsFixed in
npm package astro >= 7.1.0, < 7.3.3 7.3.3

References

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

Sources and licenses

OSV / GitHub Advisory Database - GHSA-mpr7-6m5w-76rw - 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 (29) in the archive
Total entries
29
First → latest
10.2024 10.2026
Without a fix
0
Exploited in attacks
0

Severity breakdown

  • Critical 1
  • High 6
  • Medium 16
  • Low 6

Disclosures per year

  1. 2024: 3
  2. 2025: 11
  3. 2026: 15
Severity:
  1. Astro: Arbitrary CSS injection in Astro View Transitions this entry
    Low CVE-2026-114127 >= 7.1.0, < 7.3.3 7.3.3
  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.