Cache Me If You Can Xss In Cloudflares Cdn Cgi Image
Cloudflare's /cdn-cgi/image/ endpoint could be abused to achieve XSS because its SVG sanitizer (svg-hush) failed to escape namespace URIs during serialization, and Chromium's handling of the qualified no-cache directive allowed the Content-Security-Policy header to be stripped from cached responses. An attacker could craft a malicious SVG that, when loaded through the image transformation endpoint on a victim domain, executed JavaScript in the context of that domain.
slcyber.io
Published on slcyber.io
Nowadays, Cloudflare is the dominant CDN and reverse-proxy provider on the web. At the time of writing, it sits in front of 24.3% of all websites and represents more than 84% of the measured reverse-proxy market.
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
Impact
An attacker could execute arbitrary JavaScript in the context of any Cloudflare-proxied domain using the image transformation endpoint, potentially leading to account takeover or data theft, though the attack required specific conditions such as Cloudflare Access being enabled or an open redirect being available.
What the attacker needed
Cloudflare Image Transformations enabled; Victim uses Chromium browser; Victim visits attacker-controlled page; Cloudflare Access enabled (for restricted configs)
How it was found
- Craft an SVG that passes the svg-hush sanitizer but contains a namespace declaration with an unescaped payload.
- Serve the SVG with a Cache-Control header that excludes Content-Security-Policy from Chromium's cache.
- Open the target page in a new window, navigate away, then call history.back() to load the cached response without CSP.
- The script in the SVG executes in the context of the target domain.
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.
A website can ask a browser to remember a page for a while (caching). The report found that a special instruction in the caching rules could tell the browser to forget the security policy that normally stops scripts from running. Separately, a tool that cleans SVG images had a bug that let a script slip through. Together, these let an attacker run their own code on a victim's website.
What is XSS?
Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.