Exploit an unexploitable XSS via an open redirect — A Real-Life Scenario from a Hacker’s Mindset
A reflected XSS on a subdomain endpoint was blocked by a Referer header check requiring the target domain. The author chained it with an open redirect on the main domain so the victim's browser would send the correct Referer and execute the payload.
When we talk about the Hacker Mindset, we mean how hackers can achieve their goals by any means and how they can leverage everything to their advantage even if it’s not a Vulnerability. This includes understanding the website and its technologies, So without further ado, let’s dive right in.
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.
Context
This write-up is about chaining two issues that are, on their own, unremarkable: an open redirect on a login page and a reflected XSS on an API endpoint that only fires under a specific header condition. The researcher, Ziad Ali, frames it as an exercise in the hacker mindset: understanding the target and its technologies well enough to combine ordinary behaviour into a working exploit.
For clarity the target is described as two domains:
www.target.comsubdomain.target.com
Both have numerous endpoints. The login page on the main domain takes a returnurl parameter, which normally tells the application where to send the user after a successful login. On the subdomain, a REST endpoint returns user profile information and reflects the command value back in an error message.
Setup
The report does not describe any special tooling beyond Burp, which the researcher mentions when comparing behaviour between the proxy and the browser. No accounts, roles or versions are given. The only precondition that matters is the one discovered later: the vulnerable endpoint requires the Referer header to be set to the target domain or one of its subdomains.
Finding it
On the login page of www.target.com, the researcher noticed a returnurl parameter.

A redirect parameter on a login page is a promising lead, but testing showed a security restriction that prevents redirection to external websites. At that point it looked useless, so the researcher moved on and logged in normally to enumerate further endpoints.
On subdomain.target.com, one endpoint stood out:
/rest/userprofile.json?command=getinfo

Exploitation
Step 1: trigger an error on the profile endpoint
After attempting various injection techniques against the command parameter, the researcher successfully triggered an error. The response echoed the supplied value:
An invalid value has been detected: getinfo' in target\UserProfileRestClient
The important part is that the value supplied in command is reflected verbatim into the error message. A reflected value in a response is a candidate for XSS, so the next step was to try a script payload.
Step 2: confirm script execution
The payload executed successfully:
An invalid value has been detected: <script>alert("ZIX")</script>' in target\UserProfileRestClient

At this point the researcher had a reflected XSS. The next idea was to build a payload that steals user cookies, send it to a victim, and have the victim open it.

Step 3: discover the Referer requirement
The cookie-stealing exploit did not work in the browser, and browser protection seemed to be the cause. The same payload worked perfectly when sent through Burp. After spending time manipulating headers, removing and replacing them, the researcher found the crucial requirement: to access the endpoint and execute the exploit, the Referer header must be set to the target domain or any of its subdomains.
That is a real obstacle. A victim who opens a link to subdomain.target.com from an attacker-controlled page will send a Referer pointing at the attacker's site, and the endpoint will not serve the payload. The open redirect found earlier on www.target.com becomes the missing piece.
Step 4: chain the open redirect with the XSS
The plan:
- Send the login page to the victim, with the
returnurlparameter set to thesubdomain.target.comendpoint. - The victim opens the link and logs in as usual.
- The login page redirects the victim to the infected page, ensuring that the
Refererheader is set to the main domainwww.target.com. - The infected page delivers the payload to the victim's browser, and the exploit executes.


The redirect from the login page supplies exactly the Referer the endpoint demands, because the navigation originates from www.target.com. The restriction that made the open redirect look harmless (no redirection to external websites) does not matter here: the redirect target is on the same target domain family, which is all the chain needs.
Root cause
Two separate weaknesses combine:
- The
returnurlparameter on the login page redirects to the subdomain endpoint, even though external websites are blocked. The report does not describe the exact validation logic, only that external websites are blocked. - The
commandparameter of/rest/userprofile.jsonis reflected unencoded into an error message, so markup supplied by the caller is rendered by the browser.
The endpoint requires the Referer header to be set to the target domain or any of its subdomains. The check is satisfied by any navigation that starts on the target itself, which is precisely what the open redirect provides. The defence therefore does not stop the XSS; it only changes the delivery path.
Impact
An attacker can execute arbitrary script in the context of subdomain.target.com for a victim who follows a crafted login link and logs in. The researcher's stated goal for the payload was to steal user cookies. The conditions are that the victim must open the link and complete the login so that the redirect, and therefore the required Referer, occurs.
Fix
The two changes that would break the chain are to encode the reflected command value in the error message so that it is rendered as text rather than markup, and to restrict returnurl to a fixed allowlist of internal paths rather than any non-external destination. Relying on the Referer check alone is not sufficient, since same-site navigations satisfy it by design.
Variants to test
- Look for redirect parameters on login and logout pages (
returnurl,next,redirect,continue) and test whether they accept paths on sibling subdomains. A positive result is a redirect that lands on a different subdomain of the same organisation. - Enumerate REST endpoints that echo a parameter into an error string, such as
command,actionorid. A positive result is your supplied value appearing verbatim in the response body. - When a payload works in a proxy but not in a browser, compare the
Referer,OriginandSec-Fetch-*headers between the two. A positive result is an endpoint that only responds with the payload when one of those headers matches the target. - Test whether an endpoint's
Referercheck accepts any subdomain, including ones with user content or open redirects of their own. A positive result is a payload delivered from a subdomain you can influence. - Check whether the reflected error page is served with a content type that allows HTML rendering, and whether any CSP is present. A positive result is execution with no CSP or a CSP that permits inline script.
What happened, in plain words
A security researcher found two small flaws on a company's website. Neither one was dangerous on its own. One was a login page that could be told where to send you after you log in, and it would send you to the subdomain endpoint. The other was a page on a subdomain that repeated back whatever you typed into it, including a small piece of code that a browser would run. The clever part of the story is that the second flaw only worked if your browser said you had arrived from the company's own site, and the first flaw was the trick used to make the browser say exactly that. Put together, the two harmless-looking behaviours became a working attack. The researcher, Ziad Ali, tells it as an example of the hacker mindset: understanding how a site works well enough to combine ordinary features into something that does damage.
To keep things clear, the write-up calls the target two domains:
www.target.comsubdomain.target.com
A domain is the name you type to reach a website, like a street address for a building. A subdomain is a named section of that same building, so subdomain.target.com belongs to the same organisation as www.target.com, just as the post room and the reception desk are in the same office. Both of these have many endpoints. An endpoint is a specific address inside a website that does one job, like a particular counter in a large office: one counter for logging in, another for fetching your profile, another for changing your password. When your browser talks to a website, it is really asking these counters for things.

The login page on the main domain has a parameter called returnurl. A parameter is a small piece of information attached to a web address, usually after a question mark, that tells the page what you want. You have seen them without perhaps noticing: a search address ending in ?q=cats is passing cats as the value of a parameter called q. The returnurl parameter normally tells the login page where to send you once you have logged in successfully, so you land back on the page you were trying to reach instead of the home page.
On the subdomain, there is a REST endpoint that returns user profile information and repeats the value of a command parameter back inside an error message. REST is simply a common style for building these counters so that different programs can talk to them in a predictable way. An API is the general name for this kind of programmable interface: a set of counters designed for software to use, not just for people clicking with a mouse. The important detail here is the word reflected: whatever you put in, the page puts back out, like a mirror. If a page repeats your input without cleaning it, and a browser treats that input as instructions rather than as plain text, you have a cross-site scripting flaw, usually shortened to XSS. Cross-site scripting means getting your own code to run inside someone else's website, in that website's context, as if the site itself had written the code.
Setup
The write-up does not describe any special tooling beyond Burp. Burp is a program that sits between your browser and a website and lets you look at, and change, every request before it is sent. Think of it as an inspector standing between you and the counter, who can read and rewrite your forms. The researcher mentions Burp when comparing how the site behaved through the inspector versus directly in the browser. No accounts, roles or software versions are given. The only precondition that matters is the one discovered later: the vulnerable endpoint requires the Referer header to be set to the target domain or one of its subdomains.
A header is a line of extra information that your browser attaches to every request, a bit like the label on a parcel. The Referer header (the spelling is a historical accident in the standard) tells the server which page you were on when you clicked the link that brought you here. If you click a link on a news site to reach a shop, the shop receives a Referer saying the news site. Servers can use this to check where visitors are coming from.
Finding it
On the login page of www.target.com, the researcher noticed a returnurl parameter.

A redirect parameter on a login page is a promising lead. A redirect is simply the server telling your browser "not here, go there instead", and if you can choose the destination, you may be able to send people somewhere they did not expect. But testing showed a security restriction that prevents redirection to external websites. In other words, the login page would only send you to places inside the company's own site, not to a stranger's site. At that point it looked useless, so the researcher moved on and logged in normally to enumerate further endpoints. Enumerating means walking around a site and listing the counters it has, the way you might wander an office building noting which doors are open.
On subdomain.target.com, one endpoint stood out:
/rest/userprofile.json?command=getinfo

Line by line, this address says:
/rest/is the section of the site where the programmable counters live, the API area.userprofile.jsonis the specific counter being asked, one that deals with a user's profile. The.jsonending is a hint that the answer will come back in JSON, a common text format for data that programs exchange, something like a structured shopping list.?command=getinfois the parameter being passed. The parameter is namedcommandand its value here isgetinfo, which presumably asks the counter to return information.
Exploitation
Step 1: trigger an error on the profile endpoint
After attempting various injection techniques against the command parameter, the researcher successfully triggered an error. Injection here means putting unexpected characters into an input to see how the page reacts, the way you might jiggle a door handle to see if it is loose. The response echoed the supplied value:
An invalid value has been detected: getinfo' in target\UserProfileRestClient
Line by line:
An invalid value has been detected:is the server's own error message, telling the caller that the value it received was not acceptable.getinfo'is the value the researcher sent, with a single quote added at the end. The quote was the jiggle: it was added to see whether the server would complain in a way that reveals how it handles input.in target\UserProfileRestClientis the server's internal note about which part of its own software produced the error. Seeing internal names like this is a sign that the error message is being built from raw input rather than a fixed template.
The important part is that the value supplied in command is reflected verbatim into the error message. Verbatim means exactly as sent, with no cleaning or escaping. Escaping is the process of turning characters that a browser would treat as instructions into harmless text, for example turning a < into something the browser displays as a character rather than reading as the start of a tag. A reflected value in a response is a candidate for XSS, so the next step was to try a script payload. A payload is the piece of content you send to make the flaw do something.
Step 2: confirm script execution
The payload executed successfully:
An invalid value has been detected: <script>alert("ZIX")</script>' in target\UserProfileRestClient

Line by line:
An invalid value has been detected:is again the server's error message.<script>alert("ZIX")</script>is the payload. In HTML, the language web pages are written in,<script>marks the start of a piece of code and</script>marks the end.alert("ZIX")is a tiny piece of JavaScript, the language browsers run, that opens a pop-up box showing the textZIX. The researcher used their own handle as the text so it was obvious the box came from their payload. If the box appears, the browser ran the code, which means the page is vulnerable to XSS.'is the stray single quote from the earlier test, still there.in target\UserProfileRestClientis the server's internal note, unchanged.
At this point the researcher had a reflected XSS. The next idea was to build a payload that steals user cookies, send it to a victim, and have the victim open it.

A cookie is a small piece of data that a website asks your browser to store and send back on every later request to that site. It is how a site remembers that you are logged in: after you sign in, the site gives your browser a cookie, and on each following request your browser shows it, like a wristband at an event that proves you already paid. If an attacker can read someone's cookie, they may be able to act as that person. That is why stealing cookies is a classic goal for an XSS payload.
Step 3: discover the Referer requirement
The cookie-stealing exploit did not work in the browser, and browser protection seemed to be the cause. The same payload worked perfectly when sent through Burp. This is a common and confusing situation: the inspector can send a request that the browser refuses to send, or sends differently, so something that works in Burp may fail in a real browser. After spending time manipulating headers, removing and replacing them, the researcher found the crucial requirement: to access the endpoint and execute the exploit, the Referer header must be set to the target domain or any of its subdomains.
That is a real obstacle. A victim who opens a link to subdomain.target.com from an attacker-controlled page will send a Referer pointing at the attacker's site, and the endpoint will not serve the payload. The open redirect found earlier on www.target.com becomes the missing piece. An open redirect is a redirect whose destination you can choose freely, within whatever limits the site sets. Here the limit was that the destination had to stay inside the company's own site, which is why it looked harmless at first.
Step 4: chain the open redirect with the XSS
The plan:
- Send the login page to the victim, with the
returnurlparameter set to thesubdomain.target.comendpoint. - The victim opens the link and logs in as usual.
- The login page redirects the victim to the infected page, ensuring that the
Refererheader is set to the main domainwww.target.com. - The infected page delivers the payload to the victim's browser, and the exploit executes.


Why each step matters:
- The link the victim receives points at the real login page, so it looks trustworthy. The
returnurlvalue is the subdomain endpoint, which is inside the company's own site, so the restriction that blocks external destinations does not block it. - The victim logs in as they normally would. The victim logs in as they normally would, and the login page then redirects them onward.
- Because the redirect comes from
www.target.com, the victim's browser sets theRefererheader towww.target.comwhen it follows the redirect to the subdomain. That is exactly the value the endpoint demands. - The endpoint now serves the page with the reflected payload, the browser runs it, and the exploit executes.
The redirect from the login page supplies exactly the Referer the endpoint demands, because the navigation originates from www.target.com. The restriction that made the open redirect look harmless (no redirection to external websites) does not matter here: the redirect target is on the same target domain family, which is all the chain needs. A chain, in security writing, means using one small flaw to unlock another, like using a bent paperclip to reach a key that opens the real door.
Root cause
Two separate weaknesses combine:
- The
returnurlparameter on the login page redirects to the subdomain endpoint, even though external websites are blocked. The write-up does not describe the exact validation logic, only that external websites are blocked. - The
commandparameter of/rest/userprofile.jsonis reflected unencoded into an error message, so markup supplied by the caller is rendered by the browser. Markup means the tags and instructions that make up a web page, as opposed to plain text.
The endpoint requires the Referer header to be set to the target domain or any of its subdomains. The check is satisfied by any navigation that starts on the target itself, which is precisely what the open redirect provides. CSRF, or cross-site request forgery, is an attack where another site quietly makes your browser send a request to a site you are logged in to, using your existing wristband without your knowledge. An origin restriction is a rule that only allows requests from certain places. The defence therefore does not stop the XSS; it only changes the delivery path.
Impact
An attacker can execute arbitrary script in the context of subdomain.target.com for a victim who follows a crafted login link and logs in. Arbitrary script means any code the attacker chooses, running with the same trust the site gives its own code. The researcher's stated goal for the payload was to steal user cookies. The conditions are that the victim must open the link and complete the login so that the redirect, and therefore the required Referer, occurs. HttpOnly is a setting on a cookie that stops JavaScript from reading it, which is a common defence against exactly this kind of theft.
Fix
The two changes that would break the chain are to encode the reflected command value in the error message so that it is rendered as text rather than markup, and to restrict returnurl to a fixed allowlist of internal paths rather than any non-external destination. An allowlist is a list of things that are explicitly permitted, as opposed to a blocklist of things that are forbidden; allowlists are safer because you only have to think of what should be allowed, not everything that should not. Relying on the Referer check alone is not sufficient, since same-site navigations satisfy it by design.
Variants to test
- Look for redirect parameters on login and logout pages (
returnurl,next,redirect,continue) and test whether they accept paths on sibling subdomains. A positive result is a redirect that lands on a different subdomain of the same organisation. - Enumerate REST endpoints that echo a parameter into an error string, such as
command,actionorid. A positive result is your supplied value appearing verbatim in the response body. - When a payload works in a proxy but not in a browser, compare the
Referer,OriginandSec-Fetch-*headers between the two. A positive result is an endpoint that only responds with the payload when one of those headers matches the target.Originis a header that says which site a request comes from, and theSec-Fetch-*family are newer headers that describe how the request was made, for example whether it was a link click or an image load. - Test whether an endpoint's
Referercheck accepts any subdomain, including ones with user content or open redirects of their own. A positive result is a payload delivered from a subdomain you can influence. - Check whether the reflected error page is served with a content type that allows HTML rendering, and whether any CSP is present. A positive result is execution with no CSP or a CSP that permits inline script. Content type is the label on a response saying what kind of thing it is, such as plain text or a web page. CSP, or Content Security Policy, is a rule the site sends telling the browser which sources of script it is allowed to run; a strict CSP can stop an XSS payload even when the page reflects it.
Glossary
- API: a set of addresses on a website designed for programs to talk to, rather than for people clicking around.
- Allowlist: a list of things that are explicitly permitted; anything not on the list is refused.
- Burp: a tool that sits between your browser and a website so you can inspect and change requests.
- Chain: using one small flaw to make another flaw work, so the combination does more than either alone.
- Cookie: a small piece of data a site asks your browser to store and send back on later requests, often used to remember that you are logged in.
- Content type: the label on a response saying what kind of content it is, such as plain text or a web page.
- CSP (Content Security Policy): a rule a site sends telling the browser which sources of script it may run.
- CSRF (cross-site request forgery): an attack where another site makes your browser send a request to a site you are logged in to, without your knowledge.
- Domain: the name you type to reach a website, such as
target.com. - Endpoint: a specific address inside a website that performs one job.
- Enumerate: to walk around a site and list the endpoints it has.
- Escaping: turning characters that a browser would treat as instructions into harmless text.
- Header: a line of extra information attached to a request or response, such as where you came from.
- HTML: the language web pages are written in.
- HttpOnly: a cookie setting that stops JavaScript from reading the cookie.
- Injection: putting unexpected characters into an input to see how the page reacts.
- JavaScript: the language browsers run to make pages interactive.
- JSON: a common text format for exchanging structured data between programs.
- Markup: the tags and instructions that make up a web page, as opposed to plain text.
- Open redirect: a redirect whose destination can be chosen by whoever supplies the link, within whatever limits the site sets.
- Origin: the combination of scheme, host and port that identifies where a request comes from; also the name of a header that reports it.
- Parameter: a small piece of information attached to a web address, usually after a question mark.
- Payload: the piece of content you send to make a flaw do something.
- Redirect: the server telling your browser to go to a different address instead.
- Referer: a header telling the server which page you were on when you followed the link that brought you here.
- Reflected: input that a page repeats back in its response.
- REST: a common style for building API endpoints in a predictable way.
- Subdomain: a named section of a domain, such as
subdomain.target.com. - Verbatim: exactly as sent, with no cleaning or escaping.
- XSS (cross-site scripting): getting your own code to run inside someone else's website, in that site's context.