Headline
GHSA-fvmw-cj7j-j39q: Astro Cloudflare adapter has Stored Cross Site Scripting vulnerability in /_image endpoint
Summary
When using Astro’s Cloudflare adapter (@astrojs/cloudflare) with output: 'server', the image optimization endpoint (/_image) contains a critical vulnerability in the isRemoteAllowed() function that unconditionally allows data: protocol URLs. This enables Cross-Site Scripting (XSS) attacks through malicious SVG payloads, bypassing domain restrictions and Content Security Policy protections.
Details
On-demand rendered sites built with Astro include an /_image endpoint for image optimization. While this endpoint is designed to restrict processing to local images and authorized remote domains (configured via image.domains or image.remotePatterns), a critical vulnerability exists in the underlying validation logic.
The isRemoteAllowed() function in packages/internal-helpers/src/remote.ts (lines 128-131) unconditionally allows ALL data: protocol URLs without any validation or sanitization. When combined with SVG images containing JavaScript, this creates a vector for XSS attacks.
Vulnerable Code:
/packages/ packages/internal-helpers/src/remote.ts lines 128-131
if (url.protocol === 'data:') {
return true; // ← Unconditionally allows ALL data: URLs!
}
The vulnerability manifests differently depending on the image endpoint implementation:
- Safe implementation: Server processes SVG and converts to raster format (PNG/JPEG), removing JavaScript
- Vulnerable implementation: Server redirects browser to raw SVG data URL, allowing JavaScript execution
PoC
Create a new minimal Astro project (astro@latest)
Configure it to use the Cloudflare adapter (@astrojs/cloudflare@12.6.10)
Deploy to Cloudflare Pages or Workers.
Write page to load SVG Image like : SVG XSS Payload
Open directly the SVG file to show an alert (in read scenarios, the apps that use the framework will use CDN for example, to load SVG, depending that the framework is secure)
Impact
- Stored XSS: Malicious URLs can be crafted to execute JavaScript in victim’s browser
- Session Hijacking: JavaScript can access cookies and session tokens
- Account Takeover: Combined with CSRF, can perform unauthorized actions
- Data Exfiltration: Sensitive information can be stolen and sent to attacker-controlled servers
References
- Vulnerable Function: packages/internal-helpers/src/remote.ts lines 128-131
- Similar Vulnerability:: https://dailycve.com/wordpress-stored-xss-via-svg-upload-cve-2025-2575-medium/
Summary
When using Astro’s Cloudflare adapter (@astrojs/cloudflare) with output: 'server’, the image optimization endpoint (/_image) contains a critical vulnerability in the isRemoteAllowed() function that unconditionally allows data: protocol URLs. This enables Cross-Site Scripting (XSS) attacks through malicious SVG payloads, bypassing domain restrictions and Content Security Policy protections.
Details
On-demand rendered sites built with Astro include an /_image endpoint for image optimization. While this endpoint is designed to restrict processing to local images and authorized remote domains (configured via image.domains or image.remotePatterns), a critical vulnerability exists in the underlying validation logic.
The isRemoteAllowed() function in packages/internal-helpers/src/remote.ts (lines 128-131) unconditionally allows ALL data: protocol URLs without any validation or sanitization. When combined with SVG images containing JavaScript, this creates a vector for XSS attacks.
Vulnerable Code:
/packages/ packages/internal-helpers/src/remote.ts lines 128-131 if (url.protocol === ‘data:’) { return true; // ← Unconditionally allows ALL data: URLs! }
The vulnerability manifests differently depending on the image endpoint implementation:
- Safe implementation: Server processes SVG and converts to raster format (PNG/JPEG), removing JavaScript
- Vulnerable implementation: Server redirects browser to raw SVG data URL, allowing JavaScript execution
PoC
Create a new minimal Astro project (astro@latest)
Configure it to use the Cloudflare adapter (@astrojs/cloudflare@12.6.10)
Deploy to Cloudflare Pages or Workers.
Write page to load SVG Image like : SVG XSS Payload
Open directly the SVG file to show an alert (in read scenarios, the apps that use the framework will use CDN for example, to load SVG, depending that the framework is secure)
Impact
- Stored XSS: Malicious URLs can be crafted to execute JavaScript in victim’s browser
- Session Hijacking: JavaScript can access cookies and session tokens
- Account Takeover: Combined with CSRF, can perform unauthorized actions
- Data Exfiltration: Sensitive information can be stolen and sent to attacker-controlled servers
References
- Vulnerable Function: packages/internal-helpers/src/remote.ts lines 128-131
- Similar Vulnerability:: https://dailycve.com/wordpress-stored-xss-via-svg-upload-cve-2025-2575-medium/
References
- GHSA-fvmw-cj7j-j39q
- https://nvd.nist.gov/vuln/detail/CVE-2025-65019
- withastro/astro@9e9c528