Mr. Robot: Self Xss from Informative to high 1200$ ,csrf, open redirect,self xss to stored
A profile name field lacked a CSRF token, and a separate demo panel reflected the same name value without sanitising it. By chaining two CSRF requests, an attacker could change a victim's name to a script payload and then redirect them to the demo panel, turning a self-XSS into a stored XSS.
Published on ahmadaabdulla.medium.com
Bug Bounty
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 describes a chain built from three issues found on a private program: a CSRF on the profile first name and last name fields, a self-XSS that could be injected through that same field, and a button on the main site that redirects to a demo panel. The names of the website, the panel and the screenshots have been changed, so the target is referred to here as xxx.com and the demo panel as the demo website.
The feature at the centre of the chain is the profile editor: a user can change their first name and last name, and the same information is displayed on a separate demo panel. The demo panel mirrors the profile data, so a value written into the profile appears on the demo page as well.
Setup
No specific accounts, roles, tools or versions are given. The work was done against a private program, and the researcher notes that the site name, panel name and photos were altered before publication. The only precondition that matters for the chain is that the profile form accepts a change of first name and last name without a CSRF token, and that a demo panel exists which displays the same profile information.
Finding it
The first observation was that the first name and last name fields had no CSRF token. The researcher built a CSRF request to change the name, but the website did not accept it. Through the same CSRF it was possible to set the name to any word or XSS payload, but this had no impact and was not accepted by the website either. A self-XSS on its own is not a finding, so at that point the work was, in the researcher's words, too boring.
After two or three hours of further looking, a demo panel was found that carried the same information: when the first name is changed, the change appears in the demo. The first name was set to an XSS payload and the last name was filled in as well, and the XSS worked on the demo panel. The website still did not accept self-XSS, so the next question was how to turn it into stored XSS.
The reasoning that followed was: there is a CSRF that changes the profile name to an XSS payload, and there is a demo website that reflects that XSS. What was missing was a way to move a victim from the normal website to the demo. A button was found on the normal website that creates this redirection to the demo website, where the XSS is reflected.
Exploitation
The chain uses two CSRF requests: one to change the profile name to the XSS payload, and one to redirect the user to the demo panel where the payload is rendered.
Step 1: capture the profile change and build the first CSRF
Go to xxx.com, change the profile name, capture the request and create a CSRF from it. This request writes the XSS payload into the first name (and the last name) of the victim's profile. The report does not include the captured request itself.
Step 2: capture the redirect button and build the second CSRF
Capture the request made by the button that redirects the user to the demo website, and create a second CSRF from it. This request moves the victim from the normal website to the demo panel, where the value stored in step 1 is reflected and the XSS executes. The report does not include this captured request either.
Result
With both requests delivered to a logged-in victim, the profile name is set to the payload and the victim is sent to the demo panel, where the payload runs. The researcher describes the outcome as self-XSS turned into stored XSS through the combination of the two CSRF requests and the redirect button.
Root cause
The profile form does not use a CSRF token on the first name and last name fields, so a cross-site request can change them. The demo panel displays the same profile values, and the payload set in the name executed there. A second CSRF was created from the button request, which supplies the missing step of getting the victim onto the demo panel. The report does not describe the server-side code, so the exact reason the demo panel fails to encode the value is not stated; likely it reflects the profile fields as HTML.
Impact
The impact depends on a logged-in victim visiting an attacker-controlled page that fires both requests. Under those conditions an attacker can change the victim's profile name and execute JavaScript in the context of the demo panel. The report does not describe what data or actions the demo panel exposes, so the practical consequences beyond script execution in that panel are not stated. The researcher notes that the self-XSS alone was not accepted by the program and that the chain was what made it a valid finding.
Fix
The measures that follow from the described behaviour are a CSRF token (or equivalent same-site protection) on the profile update form, output encoding of the profile fields on the demo panel so the stored value is rendered as text, and validation of the redirect target used by the button so it cannot be pointed at an arbitrary destination.
Variants to test
-
Profile fields without a CSRF token: capture the update request and replay it from another origin. A positive result is the name changing on the victim's account.
-
Secondary panels that mirror profile data: set a benign marker in the name and check whether it appears unencoded on any other page. A positive result is the marker rendering as HTML rather than text.
-
Chaining a self-XSS with a CSRF and a redirect: if each piece is rejected on its own, check whether the combination produces script execution in a panel the program considers in scope.
What happened, in plain words
A security researcher found three small weaknesses on a private bug bounty program and joined them together into one attack that paid 1,200 USD. The CSRF and the self-XSS on their own were not accepted by the program. Together they allowed an attacker to run JavaScript in another user's browser on a demo panel.
The three pieces were:
- A CSRF on the profile form. CSRF stands for Cross-Site Request Forgery. It means another website can make your browser send a request to a site you are logged in to, without you meaning to. Think of it like someone writing a letter in your handwriting and posting it for you: the site sees a request coming from your browser with your session, so it believes you sent it.
- A self-XSS in the first name field. XSS stands for Cross-Site Scripting: getting a website to run JavaScript that the attacker wrote. "Self-XSS" means the script only runs in your own browser when you paste it in yourself, so it does not harm anyone else. That is why programs usually reject it.
- A redirect from the main site to a demo panel. A redirect is when a site sends your browser to another address. The report describes a button on the main site that sends the user to the demo website.
The researcher combined the first two to store a script in the victim's profile name, and used the third to send the victim to the demo panel where that stored name is displayed and the script runs. That turns a harmless self-XSS into a stored XSS, which is a real finding.
The researcher changed the site name, the panel name and the screenshots before publishing, so the target is called xxx.com here and the second page is called the demo website. The report does not give the real names, the tools used, or the exact captured requests.
The feature involved
The centre of the story is the profile editor. When you sign up on a website, you usually have a profile page where you can set your first name and last name. The site saves those values and shows them back to you, for example in a greeting or on your account page.
On this target there was also a separate demo panel: a second page that displays the same profile information. The report says that when the first name is changed, the change appears in the demo as well. So the demo panel is a mirror of the profile data. That mirror is what makes the chain possible, because a value written into the profile ends up being displayed on a second page.
Finding it
Step 1: a form without a CSRF token
The first observation was simple: the first name and last name fields had no CSRF token. A CSRF token is a secret, random value that a site puts inside each form. When you submit the form, the site checks that the token matches the one it gave your browser. Another website cannot guess that value, so it cannot forge a valid request. Without a token, a form can be submitted from any other site.
The researcher built a CSRF request to change the name. The website did not accept it. Through the same CSRF it was possible to set the name to any word or XSS payload, but this had no impact and was not accepted by the website either. A self-XSS on its own is not a finding, so at that point the work was, in the researcher's words, too boring.
An XSS payload is just a piece of text that, if a page inserts it into the HTML without cleaning it, becomes a script. The classic example is a <script> tag, but the report does not show the exact payload used.
Step 2: a demo panel that mirrors the name
After two or three hours of further looking, a demo panel was found that carried the same information: when the first name is changed, the change appears in the demo. The first name was set to an XSS payload and the last name was filled in as well, and the XSS worked on the demo panel.
The website still did not accept self-XSS, so the next question was how to turn it into stored XSS. Stored XSS means the malicious value is saved on the server and shown to whoever views the page, not just to the person who typed it. That is far more serious, because the attacker does not need the victim to paste anything.
Step 3: the reasoning
The researcher's reasoning was: there is a CSRF that changes the profile name to an XSS payload, and there is a demo website that reflects that XSS. What was missing was a way to move a victim from the normal website to the demo. A button was found on the normal website that creates this redirection to the demo website, where the XSS is reflected.
That button is the redirect. A CSRF was created from its request so the victim is sent to the demo panel, which is exactly where the stored payload will run.
Exploitation
The chain uses two CSRF requests: one to change the profile name to the XSS payload, and one to redirect the user to the demo panel where the payload is rendered.
Step 1: capture the profile change and build the first CSRF
Go to xxx.com, change the profile name, capture the request and create a CSRF from it. This request writes the XSS payload into the first name (and the last name) of the victim's profile. The report does not include the captured request itself.
To capture a request, you open your browser's developer tools, go to the Network tab, submit the form, and look at the request that was sent. You then copy that request into an HTML page that you host, so that when a victim opens your page, their browser sends the same request to xxx.com with their own session. That is the CSRF.
Step 2: capture the redirect button and build the second CSRF
Capture the request made by the button that redirects the user to the demo website, and create a second CSRF from it. This request moves the victim from the normal website to the demo panel, where the value stored in step 1 is reflected and the XSS executes. The report does not include this captured request either.
Result
With both requests delivered to a logged-in victim, the profile name is set to the payload and the victim is sent to the demo panel, where the payload runs. The researcher describes the outcome as self-XSS turned into stored XSS through the combination of the two CSRF requests and the open redirect.
Root cause
The profile form does not use a CSRF token on the first name and last name fields, so a cross-site request can change them. The demo panel displays the same profile values, and the payload set in the name executed there. Output encoding means converting special characters like < and > into harmless text before putting them into a page, so the browser shows them instead of treating them as HTML. The redirect button on the main site can be driven cross-site as well, which supplies the missing step of getting the victim onto the demo panel.
Impact
The impact depends on a logged-in victim visiting an attacker-controlled page that fires both requests. Under those conditions an attacker can change the victim's profile name and execute JavaScript in the context of the demo panel. The researcher notes that the self-XSS alone was not accepted by the program and that the chain was what made it a valid finding.
Fix
The measures that follow from the described behaviour are a CSRF token (or equivalent same-site protection) on the profile update form, output encoding of the profile fields on the demo panel so the stored value is rendered as text, and validation of the redirect target used by the button so it cannot be pointed at an arbitrary destination.
Variants to test
-
Profile fields without a CSRF token: capture the update request and replay it from another origin. A positive result is the name changing on the victim's account.
-
Secondary panels that mirror profile data: set a benign marker in the name and check whether it appears unencoded on any other page. A positive result is the marker rendering as HTML rather than text.
-
Chaining a self-XSS with a CSRF and a redirect: if each piece is rejected on its own, check whether the combination produces script execution in a panel the program considers in scope.
Glossary
- Bug bounty program: a scheme where a company pays researchers for reporting security problems in its systems.
- Private program: a bug bounty program that only invited researchers can see and report to.
- CSRF (Cross-Site Request Forgery): an attack where another website makes your browser send a request to a site you are logged in to, without your intent.
- CSRF token: a secret random value placed in a form and checked on submit, so another site cannot forge a valid request.
- XSS (Cross-Site Scripting): getting a website to run JavaScript written by an attacker in someone's browser.
- Self-XSS: an XSS that only runs when the victim pastes the payload themselves, so it does not affect other users.
- Stored XSS: an XSS where the malicious value is saved on the server and shown to other users who view the page.
- Payload: the piece of text or code an attacker sends to trigger a vulnerability.
- Open redirect: a redirect whose destination can be chosen by whoever makes the request, so it can point anywhere.
- Redirect: a response that tells the browser to go to another address.
- Output encoding: converting special characters into harmless text before inserting them into a page, so the browser displays them instead of interpreting them as HTML.
- Session: the state a site keeps for you after you log in, usually tied to a cookie, so it knows who you are on each request.
- Cookie: a small piece of data a site stores in your browser and sends back with each request, often used to identify your session.
- Developer tools / Network tab: the built-in browser panel that shows the requests a page makes, used to capture a request for a CSRF.
- Origin: the combination of scheme, host and port that a page comes from; requests from a different origin are cross-site.
- Demo panel: in this report, a second page that displays the same profile information as the main site.
xxx.com: the placeholder name used in the report for the real target website.