Override, mutation and (S)XSS
Request headers were reflected into response headers, allowing an attacker to override the Content-Type of a Next.js RSC response and turn reflected URL parameters into HTML, leading to stored XSS via cache poisoning. A two-stage cache poisoning chain using the Refresh header achieved zero-click execution.
zhero-web-sec.github.io
Published on zhero-web-sec.github.io
Unlike our usual publications, this one is shorter and focuses on a real-world exploitation case rather than pure research. Although the vulnerability was exploited in Next.js, which, as we will see, met all the conditions for reliable exploitation, it stems from an unusual mistake: mirroring request headers into…
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 application mirrors incoming request headers into response headers without filtering, and Next.js only sets a default Content-Type if one is not already present, so an attacker-supplied Content-Type overrides the RSC content type.
Impact
An attacker could achieve zero-click stored XSS on the latest versions of Next.js, even if not vulnerable to SSRF, but only when request headers are reflected and an external cache stores the RSC payload.
What the attacker needed
Request headers reflected in response headers; external cache storing RSC payloads; victim visits poisoned page
How it was found
- Send a request with the Rsc header to obtain the React Server Component payload.
- Include a Content-Type header set to text/html to override the default text/x-component.
- Embed an XSS payload in a URL parameter that is reflected in the RSC payload.
- Poison the cache for the target path with the crafted request.
- Poison the home page by adding a Refresh header pointing to the poisoned path with the same payload.
- A victim visiting the home page is redirected via the Refresh header to the poisoned page, executing the XSS.
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.
The website copied certain request headers back into its response headers. By sending a header that changes the response type to HTML, the attacker made the site treat a URL parameter as HTML code, which the browser then ran as a script. Because the response was cached, other visitors could be attacked without clicking anything.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.