Skip to content
Path traversal Write-up Advanced

Cloudflare Image Proxy as a CSPT Gadget: A Cross-Origin CSPT Exploit

The article describes how a client-side path traversal (CSPT) vulnerability can be escalated to cross-origin requests by chaining it with a 307/308 redirect gadget, such as Cloudflare's image transformation endpoint. An attacker could then send requests to a more sensitive subdomain, potentially enabling forced actions or data exfiltration, though CORS and authentication header limitations apply.

Amirmohammad Safari Follow

Published on blog.voorivex.team

When that input can alter the request path, an attacker may be able to change the request path to sensitive endpoints, leading to attacks such as forced actions, or cross-site request forgery.

Amirmohammad Safari, on blog.voorivex.team

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.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 5 min read.

Context

Client-side path traversal (CSPT) is a class of bug where attacker-controlled input is placed into a request path that the browser then requests. When that input can alter the path, an attacker may be able to move the request to sensitive endpoints, which opens the door to forced actions or cross-site request forgery. This write-up looks at a specific question that decides whether a CSPT finding is worth anything: can CSPT change the host, or send the request to a different subdomain?

The gadget used to demonstrate the mechanics is Cloudflare's Image Transformation redirect behaviour. The image transform endpoint can be abused to issue a 307 redirect to another subdomain, including a custom path, which makes it a good way to hop between subdomains inside the same domain.

Setup

No accounts, roles, tool versions or specific target application are described. The write-up is a general technique: it assumes you have found, or are looking for, a client-side request that inserts attacker-controlled input into a request path, for example fetch(baseUrl + userInput) or code that builds a URL from user input and then requests it. The examples use company.tld and api.company.tld as placeholders.

Finding it

The starting observation is that CSPT on its own is often low value. If you find a CSPT on company.tld and can send a PUT request to that domain, but there are no sensitive endpoints there, the exploit has little real effect. The same organisation may, however, run a more sensitive origin such as api.company.tld that hosts endpoints for changing user data, managing tokens and similar. If you can change the host from company.tld to api.company.tld and send the request there, the CSPT becomes useful and can have real impact. The same applies when the CSPT sits on a low-value subdomain and the goal is to jump to a more sensitive one.

So the operational question is whether a CSPT can send requests to other origins. Only then does an apparently harmless gadget turn into a real, impactful exploit.

Exploitation

Step 1: Understand which redirects preserve the request

Browsers handle redirects differently. For this purpose only 307 Temporary Redirect and 308 Permanent Redirect are useful, because they preserve the original HTTP method, body and headers. When the browser receives one of these, it follows it without changing the request. Other redirect types such as 301 or 302 may change a POST into a GET, which can break the intended behaviour.

Browser redirect handling — which status codes preserve method and body
Browser redirect handling — which status codes preserve method and body From the original on blog.voorivex.team

The image shows how browsers handle redirects and which status codes preserve method and body.

There are important caveats before relying on this:

  • Cookies and SameSite: if the destination relies on cookie-based authentication, cookies are forwarded according to their SameSite policies.
  • Authorization header: browsers do not forward the Authorization header automatically during cross-origin redirects. If a target API authenticates exclusively via Authorization: Bearer ... headers, this redirect method will not work.
  • CORS: even if a redirected request reaches another origin, the destination must allow the request via CORS.

Step 2: Use the Cloudflare Image Transform gadget

Cloudflare's Image Transformation redirect behaviour is the practical gadget. The image transform endpoint can be abused to issue a 307 redirect to another subdomain, including a custom path:

Text
https://company.tld/cdn-cgi/image/onerror=redirect/https://subdomain.company.tld/<path>

The report gives the following URL form for the gadget: Because it is a 307, the method, body and headers survive the hop.

Cloudflare Image Transformation issuing a 307 redirect to a chosen subdomain path
Cloudflare Image Transformation issuing a 307 redirect to a chosen subdomain path From the original on blog.voorivex.team

The image shows the Cloudflare Image Transformation endpoint issuing a 307 redirect to a chosen subdomain path.

Step 3: Chain the redirect to the sink

The workflow, as laid out in the write-up:

  1. Identify the CSPT vulnerability. Find a client-side request that inserts attacker-controlled input into a request path, for example fetch(baseUrl + userInput) or code that builds a URL from user input and then requests it.
  2. Target gadget. Cloudflare Image Transformation, or any open-redirect vulnerability that can issue a 307/308 redirect.
  3. Chain the redirect to the sink. Build a URL that, when the sink requests it, triggers the open-redirect gadget and returns a 307/308 pointing to your target host or subdomain.
  4. Exploit CSPT cross-origin. Because the redirect preserves method and body, the sink's request is forwarded to the chosen host, enabling cross-origin actions (CSRF, data exfiltration and so on) depending on the target and the request details.
End-to-end exploitation workflow chaining CSPT with the Cloudflare image-transform redirect
End-to-end exploitation workflow chaining CSPT with the Cloudflare image-transform redirect From the original on blog.voorivex.team

The image shows the end-to-end exploitation workflow, chaining CSPT with the Cloudflare image-transform redirect.

Root cause

Two design behaviours combine. First, the application builds a request path from attacker-controlled input, so the attacker can move the request to a different path. Second, the Cloudflare image transform endpoint will issue a 307 redirect to a URL supplied in its path, so a request that lands there is forwarded to another host with method, body and headers intact. The CSPT alone only changes the path; the redirect gadget is what changes the host.

Several conditions still apply. SameSite policies govern cookies, the Authorization header is not forwarded on cross-origin redirects, and the destination must allow the request via CORS.

Impact

When the conditions hold, the sink's request is forwarded to the chosen host, which enables cross-origin actions such as CSRF or data exfiltration, depending on the target and the request details. The write-up notes that not every CSPT finding leads to a high-impact exploit. Successful cross-origin requests usually depend on CORS being permissive for the target domain or subdomain, which is common but not guaranteed. Browsers do not forward Authorization headers on 307/308 redirects, which can prevent some attack flows; the approach is mainly recommended for web applications vulnerable to CSPT that rely on cookie-based or custom-header authentication.

Fix

The write-up does not describe a fix or a change made to any product. It presents the technique and its limits.

Variants to test

  • Other 307/308 open redirects. Look for any endpoint that issues a 307 or 308 to an attacker-chosen location. A positive result is a redirect that preserves method, body and headers to a host you control.
  • Cloudflare Image Transformation on other hosts. Try the onerror=redirect form against other domains behind Cloudflare.
  • CSPT on low-value subdomains. Look for a sink that builds a request path from user input on a subdomain with no sensitive endpoints, then chain it to a sensitive sibling.
  • Cookie-authenticated APIs. Prefer targets that authenticate with cookies or custom headers rather than Authorization: Bearer, since the latter is dropped on cross-origin redirects.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 11 min read.

What happened, in plain words

This write-up is about a bug class called client-side path traversal, or CSPT for short. To understand it, start with how a website talks to its own servers. When you click a button, the page in your browser often sends a request to a server behind the scenes, without reloading the page. That request goes to an address, called a URL, which has a few parts: the host (the domain name, like company.tld), the path (the part after the slash, like /profile/settings), and sometimes a method (a word like GET to read something or PUT to change something).

A CSPT bug happens when a website takes something an attacker can influence, such as part of a URL, and glues it into the path of a request the browser then makes. If the attacker can alter that input, they may be able to steer the request to a different path than the developer intended. That can lead to actions the user never meant to take, or to a classic attack called cross-site request forgery (CSRF), where a malicious page makes your browser send a request you did not intend.

The question this write-up answers is bigger than just changing the path. Can CSPT also change the host, meaning send the request to a completely different subdomain? That matters because a low-value subdomain may have nothing interesting, while a sibling subdomain like api.company.tld may hold the sensitive stuff: endpoints that change user data or manage tokens. If you can move the request there, a harmless-looking bug becomes a real attack.

The trick used to demonstrate this is a feature of Cloudflare, a company that sits in front of many websites and provides services like caching and image processing. Cloudflare's image transformation endpoint can be made to answer a request with a redirect, which is a server saying "not here, go to this other address instead". A particular kind of redirect, the 307, tells the browser to go to the new address while keeping the original request exactly as it was: same method, same body, same headers. That is what lets a request hop from one subdomain to another.

So the story is: find a place where the page builds a request path from user input, point that path at the Cloudflare image endpoint, make Cloudflare redirect to the sensitive subdomain, and the browser carries the original request there. The rest of this article walks through that idea from the ground up.

Why cross-origin CSPT matters

First, some vocabulary. An origin in web security is the combination of protocol (http or https), host and port. Two pages on the same host share an origin; two different subdomains do not. Browsers use origins to decide what one page is allowed to read from another. When a request goes from one origin to another, that is a cross-origin request.

An API (application programming interface) is the set of addresses a website's front end uses to talk to its back end. Think of it as a service counter: you hand over a request at a specific window (an endpoint, a specific URL path), and you get data or an action back. Some counters are harmless, like "show my profile picture". Others are sensitive, like "change my email address" or "create a new access token".

A token is a short string that proves who you are, a bit like a wristband at an event. A cookie is a small piece of data the browser stores for a site and sends back automatically with every request to that site. Cookies are how most sites remember that you are logged in. Because the browser attaches them automatically, a request forged by a malicious page can still carry your login, which is why CSRF is possible at all.

Now the core argument. Suppose you find a CSPT on company.tld and you can make the browser send a PUT request there. A PUT is a method used to update or replace something on the server. But if company.tld has no sensitive endpoints, the bug does nothing useful. Meanwhile the same organisation may run api.company.tld, which hosts endpoints for changing user data, managing tokens and similar. If you can change the host from company.tld to api.company.tld and send the request there, the CSPT suddenly has real impact.

The same logic applies when the CSPT sits on a low-value subdomain and your goal is to jump to a more sensitive sibling. So the operational question is simple: can this CSPT send requests to other origins? Only then does an apparently harmless gadget turn into a real, impactful exploit. A gadget, in this context, is an existing feature of a website or service that you can reuse for your own purpose, like using a chair to reach a high shelf.

How to change the origin: 307 and 308 redirects

A redirect is a server's way of saying "the thing you asked for is elsewhere, go there". It comes with a status code, a three-digit number that tells the browser what kind of answer it got. Browsers treat different redirect codes differently.

For this technique, only 307 Temporary Redirect and 308 Permanent Redirect are useful, because they preserve the original HTTP method, body and headers. When the browser receives one of these, it follows it without changing the request. Other redirect types such as 301 or 302 may change a POST into a GET, which can break the intended behaviour. A POST is a method used to submit data, for example a form. If the browser turns it into a GET, the request may no longer do what was intended.

Browser redirect handling — which status codes preserve method and body
Browser redirect handling — which status codes preserve method and body From the original on blog.voorivex.team

The image shows how browsers handle redirects and which status codes preserve method and body.

Before relying on this, there are important caveats:

  • Cookies and SameSite: if the destination relies on cookie-based authentication, cookies are forwarded according to their SameSite policies. SameSite is a cookie setting that controls whether the browser sends the cookie on cross-site requests. Some settings block it entirely, some allow it only for top-level navigation, and some allow it everywhere.
  • Authorization header: browsers do not forward the Authorization header automatically during cross-origin redirects. A header is extra information attached to a request, like a label on a parcel. The Authorization header is where a token like Authorization: Bearer ... is usually placed. If a target API authenticates exclusively via that header, this redirect method will not work.
  • CORS: even if a redirected request reaches another origin, the destination must allow the request via CORS. CORS (Cross-Origin Resource Sharing) is a set of rules a server uses to say which other origins may talk to it from a browser. If the destination does not allow your origin, the browser blocks the response.

A practical gadget: Cloudflare Image Transform

Cloudflare offers an image transformation service. Websites use it to resize, crop or convert images on the fly by putting special instructions in the URL. The URL form given in the write-up includes the parameter onerror=redirect.

The image transform endpoint can be abused to issue a 307 redirect to another subdomain, including a custom path. That makes it an excellent way to hop between subdomains inside the same domain:

Text
https://company.tld/cdn-cgi/image/onerror=redirect/https://subdomain.company.tld/<path>

Reading this URL piece by piece:

  • https://company.tld is the host you are already allowed to talk to.
  • /cdn-cgi/image/ is the Cloudflare image transformation endpoint. cdn-cgi is a path Cloudflare reserves for its own features.
  • onerror=redirect is the instruction that turns an image error into a redirect.
  • https://subdomain.company.tld/<path> is the address the service will redirect to. The <path> part is a placeholder for whatever path you want on the destination.

So a request that reaches this endpoint is bounced to subdomain.company.tld with the chosen <path>. Because it is a 307, the method, body and headers survive the hop.

Cloudflare Image Transformation issuing a 307 redirect to a chosen subdomain path
Cloudflare Image Transformation issuing a 307 redirect to a chosen subdomain path From the original on blog.voorivex.team

The image shows the Cloudflare Image Transformation endpoint issuing a 307 redirect to a chosen subdomain path.

Exploitation workflow (Cloudflare gadget)

End-to-end exploitation workflow chaining CSPT with the Cloudflare image-transform redirect
End-to-end exploitation workflow chaining CSPT with the Cloudflare image-transform redirect From the original on blog.voorivex.team

The image shows the end-to-end exploitation workflow, chaining CSPT with the Cloudflare image-transform redirect.

The workflow, as laid out in the write-up:

  1. Identify the CSPT vulnerability. Find a client-side request that inserts attacker-controlled input into a request path, for example fetch(baseUrl + userInput) or code that builds a URL from user input and then requests it. fetch is the browser function a page uses to send requests in the background. If userInput is not checked, the attacker can put path tricks or a full URL into it.
  2. Target gadget. Cloudflare Image Transformation, or any open-redirect vulnerability that can issue a 307/308 redirect. An open redirect is a redirect where the destination is taken from user input, so anyone can choose where the browser goes.
  3. Chain the redirect to the sink. Build a URL that, when the sink requests it, triggers the open-redirect gadget and returns a 307/308 pointing to your target host or subdomain. The sink is the place in the application where the dangerous request is finally made, the point where the attacker's input turns into an actual network request.
  4. Exploit CSPT cross-origin. Because the redirect preserves method and body, the sink's request is forwarded to the chosen host, enabling cross-origin actions (CSRF, data exfiltration and so on) depending on the target and the request details. Data exfiltration means getting data out of a place it should stay, for example reading a response and sending it to a server the attacker controls.

Root cause

Two design behaviours combine. First, the application builds a request path from attacker-controlled input, so the attacker can move the request to a different path. Second, the Cloudflare image transform endpoint will issue a 307 redirect to a URL supplied in its path, so a request that lands there is forwarded to another host with method, body and headers intact. The CSPT alone only changes the path; the redirect gadget is what changes the host.

Several conditions still apply. SameSite policies govern cookies, the Authorization header is not forwarded on cross-origin redirects, and the destination must allow the request via CORS.

Impact

When the conditions hold, the sink's request is forwarded to the chosen host, which enables cross-origin actions such as CSRF or data exfiltration, depending on the target and the request details. The write-up is explicit that not every CSPT finding leads to a high-impact exploit. Successful cross-origin requests usually depend on CORS being permissive for the target domain or subdomain, which is common but not guaranteed. Browsers do not forward Authorization headers on 307/308 redirects, which can prevent some attack flows; the approach is mainly recommended for web applications vulnerable to CSPT that rely on cookie-based or custom-header authentication. A custom header is simply a header the application defines itself, rather than one of the standard ones like Authorization.

Fix

The write-up does not describe a fix or a change made to any product. It presents the technique and its limits.

Variants to test

  • Other 307/308 open redirects. Look for any endpoint that issues a 307 or 308 to an attacker-chosen location. A positive result is a redirect that preserves method, body and headers to a host you control.
  • Cloudflare Image Transformation on other hosts. Try the onerror=redirect form against other domains behind Cloudflare.
  • CSPT on low-value subdomains. Look for a sink that builds a request path from user input on a subdomain with no sensitive endpoints, then chain it to a sensitive sibling.
  • Cookie-authenticated APIs. Prefer targets that authenticate with cookies or custom headers rather than Authorization: Bearer, since the latter is dropped on cross-origin redirects.

Glossary

  • API: the set of addresses a website's front end uses to talk to its back end, like a service counter with different windows for different jobs.
  • Authorization header: a request header where a token such as Authorization: Bearer ... is placed to prove identity.
  • Body: the part of a request that carries data, for example the contents of a form.
  • Cookie: a small piece of data the browser stores for a site and sends back automatically with requests to that site.
  • CORS: Cross-Origin Resource Sharing, the rules a server uses to say which other origins may talk to it from a browser.
  • Cross-origin: a request or interaction between two different origins (different protocol, host or port).
  • CSRF: cross-site request forgery, an attack where a malicious page makes your browser send a request you did not intend.
  • CSPT: client-side path traversal, a bug where attacker-controlled input is placed into a request path the browser then requests.
  • Custom header: a header defined by the application itself rather than one of the standard ones.
  • Data exfiltration: getting data out of a place it should stay, for example sending it to a server the attacker controls.
  • Endpoint: a specific URL path on a server that performs a particular action or returns particular data.
  • fetch: the browser function a page uses to send requests in the background.
  • Gadget: an existing feature of a website or service that can be reused for an attacker's purpose.
  • GET: an HTTP method used to read something.
  • Header: extra information attached to a request or response, like a label on a parcel.
  • Host: the domain name part of a URL, such as company.tld.
  • HTTP method: the word in a request that says what kind of action it is, such as GET, POST or PUT.
  • Open redirect: a redirect where the destination is taken from user input, so anyone can choose where the browser goes.
  • Origin: the combination of protocol, host and port that browsers use to decide what one page may read from another.
  • Path: the part of a URL after the host, such as /profile/settings.
  • POST: an HTTP method used to submit data, for example a form.
  • PUT: an HTTP method used to update or replace something on the server.
  • Redirect: a server response telling the browser to go to a different address instead.
  • SameSite: a cookie setting that controls whether the browser sends the cookie on cross-site requests.
  • Sink: the place in an application where a dangerous request is finally made.
  • Status code: a three-digit number in a response that says what kind of answer it is.
  • 307 Temporary Redirect: a redirect that preserves the original method, body and headers.
  • 308 Permanent Redirect: a redirect that preserves the original method, body and headers.
  • Token: a short string that proves who you are, like a wristband at an event.
  • URL: the address of something on the web, made of protocol, host and path.

More by Amirmohammad Safari

View all

5 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Path traversal and file inclusion

The lesson behind this report.

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.