Packages / @astrojs/cloudflare / Security
Server-Side Request Forgery via /_image endpoint in Astro Cloudflare adapter
Affected releases · @astrojs/cloudflare
- 12.x12.0.0 – 12.6.5Fixed in 12.6.6
- 11.x11.0.3 – 11.2.0No fix on this line yet
On 12.x, the newest line:
npm install @astrojs/cloudflare@12.6.6Not affected
14.0.0 – 14.4.1
25 releases, latest
Affected
12.0.0 – 12.6.5
24 releases
Fixed
12.6.6 – 12.6.13
8 releases
Not affected
11.0.0 – 11.0.2
3 releases
Affected
11.0.3 – 11.2.0
5 releases
Is your project affected?
Paste your package.json, or type the range you declare for @astrojs/cloudflare. It is read in your browser and sent nowhere.
What happens
Summary
When using Astro's Cloudflare adapter (@astrojs/cloudflare) 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.
Details
On-demand rendered sites built with Astro include an /_image endpoint, which returns optimized versions of images.
The /_image endpoint is restricted to processing local images bundled with the site and also supports remote images from domains the site developer has manually authorized (using the image.domains or image.remotePatterns options).
However, 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.
PoC
Create a new minimal Astro project (
astro@5.13.3)Configure it to use the Cloudflare adapter (
@astrojs/cloudflare@12.6.5) and server output:// astro.config.mjs import { defineConfig } from 'astro/config'; import cloudflare from '@astrojs/cloudflare'; export default defineConfig({ output: 'server', adapter: cloudflare(), });Deploy to Cloudflare Pages or Workers
Append
/_image?href=https://placehold.co/600x400to the deployment URL.This will serve the placeholder image from the unauthorised
placehold.codomain.
Impact
Allows a non-authorized third-party to create URLs on an impacted site’s origin that serve unauthorized content. This includes the risk of server-side request forgery (SSRF) and by extension cross-site scripting (XSS) if a user follows a link to a maliciously crafted URL.