CVE-2025-64745
Executive Summary
CVE-2025-64745 is a Reflected Cross-Site Scripting (XSS) vulnerability affecting Astro, a popular web framework. The flaw exists in the development server's error pages when the trailingSlash configuration option is enabled. An attacker can craft a malicious URL that, when visited by a developer, executes arbitrary JavaScript in the context of the developer's browser. This vulnerability is limited to the development server and does not impact production builds. However, it poses a significant risk to developer environments through social engineering attacks. The vulnerability has been patched in Astro version 5.15.6.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
Astro is distributed via the npm registry. Developers should ensure their package.json and lock files are updated to version 5.15.6 or later. The vulnerability does not affect the production build output, but the development server is a critical part of the development workflow. Compromise of a developer's environment could lead to supply chain attacks, such as code injection or credential theft.
CVSS Breakdown & Threat Level
- CVSS Score: 2.7 (Low)
- Vector: CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:N/A:N
- Attack Vector (AV): Network – The vulnerability can be exploited remotely.
- Attack Complexity (AC): High – Exploitation requires the
trailingSlashoption to be enabled and the victim to interact with a malicious link. - Privileges Required (PR): None – No authentication is needed.
- User Interaction (UI): Required – The victim must click a crafted link.
- Scope (S): Unchanged – The vulnerability does not affect other components.
- Confidentiality (C): Low – Limited information disclosure is possible.
- Integrity (I): None – No data modification.
- Availability (A): None – No denial of service.
Threat Level: Low. The vulnerability is confined to the development server and requires user interaction. However, it can be leveraged in targeted attacks against developers.
Deep Dive & Mechanics
The vulnerability resides in Astro's development server error handling. When the trailingSlash configuration option is set (e.g., trailingSlash: 'always' or trailingSlash: 'never'), the server may reflect user-supplied input in error pages without proper sanitization. Specifically, a crafted URL containing malicious JavaScript can be injected into the error response. The browser then executes the script in the context of the development server's origin.
Root Cause: Insufficient output encoding of URL parameters in error page templates when trailingSlash is active.
Attack Scenario:
- An attacker identifies a developer using Astro with
trailingSlashenabled. - The attacker crafts a URL like:
http://localhost:4321/%3Cscript%3Ealert('XSS')%3C/script%3E - The developer clicks the link (e.g., via phishing email or chat message).
- The Astro dev server returns an error page reflecting the malicious payload.
- The browser executes the script, potentially stealing session cookies, tokens, or performing actions on behalf of the developer.
Vulnerable vs. Patched Code
Vulnerable Code (Astro < 5.15.6): The error page template likely used a raw interpolation of the URL path without escaping.
// Vulnerable: Direct interpolation
const errorMessage = `Path not found: ${url.pathname}`;
Patched Code (Astro >= 5.15.6): The fix introduces proper HTML encoding of user input before rendering.
// Patched: Escaped output
import { escapeHtml } from 'astro/utils';
const errorMessage = `Path not found: ${escapeHtml(url.pathname)}`;
Exploitation & Lab Setup
Red Team (Exploitation)
Prerequisites:
- Astro project with
trailingSlashenabled (e.g.,trailingSlash: 'always'inastro.config.mjs). - Development server running on
localhost:4321.
Exploit Steps:
- Start the Astro dev server.
- Craft a malicious URL:
http://localhost:4321/%3Cimg%20src=x%20onerror=alert(1)%3E - Send the link to the victim developer.
- When the victim visits the URL, the XSS payload executes.
Proof-of-Concept (PoC) URL:
http://localhost:4321/%3Cscript%3Ealert('CVE-2025-64745')%3C/script%3E
Blue Team (Detection & Prevention)
Detection:
- Monitor for unusual URLs containing script tags or event handlers in development server logs.
- Use browser-based XSS filters (e.g., X-XSS-Protection header).
- Implement Content Security Policy (CSP) headers in development mode.
Prevention:
- Upgrade to Astro 5.15.6 or later.
- Disable
trailingSlashin development if not required. - Use a web application firewall (WAF) to block malicious payloads.
- Educate developers about phishing risks.
Indicators of Compromise (IOCs)
- URL Patterns:
http://localhost:4321/*<script>*http://localhost:4321/*<img onerror=*http://localhost:4321/*%3Cscript%3E*
- Log Entries:
GET /<script>alert(1)</script>in Astro dev server logs.
- Network Traffic:
- Outbound connections from developer machine to attacker-controlled domains (if payload exfiltrates data).
Detection Engineering
YARA Rule
rule CVE_2025_64745_Astro_XSS {
meta:
description = "Detects Astro dev server error pages with XSS payloads"
author = "Valters IT"
date = "2025-04-10"
reference = "CVE-2025-64745"
strings:
$xss_payload = /<script[^>]*>.*<\/script>/i
$img_onerror = /<img[^>]+onerror=/i
$svg_onload = /<svg[^>]+onload=/i
condition:
any of them
}
Sigma Rule
title: Astro Dev Server Reflected XSS
id: 8a9b7c6d-5e4f-3a2b-1c0d-9e8f7a6b5c4d
status: experimental
description: Detects reflected XSS attempts against Astro development server
author: Valters IT
date: 2025-04-10
logsource:
category: webserver
product: astro
detection:
selection:
cs-method: 'GET'
cs-uri-query|contains:
- '<script'
- '<img'
- '<svg'
- 'onerror='
- 'onload='
- 'onclick='
condition: selection
falsepositives:
- Legitimate use of script tags in development (unlikely)
level: high
Suricata Rule
alert http any any -> any any (msg:"CVE-2025-64745 Astro Dev Server XSS Attempt"; flow:to_server,established; content:"GET"; http_method; content:"<script"; http_uri; nocase; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate:
- Upgrade Astro to version 5.15.6 or later:
npm install astro@latest - Verify the update:
npm list astro
Long-term:
- Implement strict Content Security Policy (CSP) headers in development.
- Use input validation and output encoding for all user-supplied data.
- Regularly update dependencies and monitor for security advisories.
- Conduct security training for developers on XSS risks.
Workaround:
- Disable
trailingSlashinastro.config.mjs:export default defineConfig({ trailingSlash: 'ignore' // or remove the option });
Report generated by Valters IT DevSecOps Intelligence Unit