Skip to content
SSRF Write-up Intermediate

Open Source Hacking — Breaking AstroJs

The Astro image optimisation endpoint at /_image failed to validate the requested URL in two code paths. On Cloudflare deployments the adapter fetched any remote URL, allowing server-side request forgery, and in development mode absolute file paths were read from disk and returned as images.

medium.com

Published on medium.com

That was the thought when I started looking into Astro’s /image route. It is one of those features developers rarely question.

Monish, on medium.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the image endpoint's validation logic was duplicated across adapters and environments, so the Cloudflare adapter and the development path each skipped the checks the shared implementation performed.

Impact

The Cloudflare issue allowed unrestricted server-side request forgery reaching metadata services, internal APIs and private networks, while the development issue allowed unauthenticated reads of image files on the developer's machine, though only when a dev server was exposed.

What the attacker needed

Astro on Cloudflare adapter (SSRF); Astro dev server exposed (file read); No authentication required

The fix

The image endpoint logic should be centralised so every adapter and environment uses the same hardened validation instead of reimplementing or skipping it.

How it was found

  1. Deploy an Astro site in server output mode using the official Cloudflare adapter.
  2. Send a request to the /_image endpoint with a remote image URL from a domain that was never whitelisted.
  3. Observe that the adapter fetches and returns the remote image instead of rejecting the request.
  4. Run an Astro development server locally.
  5. Request the /_image endpoint with an absolute file path as the href parameter.
  6. Observe that the file is read from disk, processed and returned as an image.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

Astro is a framework for building websites, and it has a feature that fetches and resizes images for you. The code that did this fetching did not check where the image came from, so an attacker could make the server fetch internal addresses or read files from the machine. This is called server-side request forgery when the server is tricked into making requests on the attacker's behalf.

What is SSRF?

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.

Similar reports

View all

Same bug class and techniques, clearest first.

Server-side request forgery (SSRF)

The lesson behind this report.

The server can be made to fetch an address the attacker chooses, reaching internal services, cloud metadata or other customers' data.