Skip to content
XSS Write-up Intermediate

Story of the best vulnerability I’ve found so far…

Vedant Tekale Follow

Published on medium.com

Hello all the amazing hackers and cyber security enthusiasts. My name is Vedant and I’m an aspiring bug bounty hunter and a cyber security enthusiast.

Vedant Tekale, on 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. 4 min read.

Context

The target was a customer portal, reached at portal.target.com. The portal let a user create an account, search for products and request products. That was the whole feature set. The researcher stresses one property of the design: there was no way for a normal user to view another user's profile. The program was private, and the researcher had spent about three months focused on it alone, which gave him a good picture of the infrastructure.

Setup

No special tooling was needed beyond a browser and an account on the portal. The researcher created a normal user account, confirmed the email and logged in to the account dashboard. For the blind part of the work he used xsshunter.com, taking its simple payload and placing it in his profile. The only other precondition was the request content feature, which lets a user send free text to the other side.

Finding it

Recon started with gathering information about the technology stack. A directory brute force on the subdomain turned up nothing interesting.

The researcher then registered an account and, while doing so, put a simple HTML payload in both the first name and last name fields:

HTML
<h1>tester</h1>

After confirming the email and logging in, the dashboard rendered the payload in both parameters. He moved to the edit profile section, replaced the HTML in the first name field with an XSS payload:

HTML
<img src=x onerror=alert(1)>

He saved the changes, returned to the dashboard, and the stored XSS fired. The finding looked strong until he tried to write the impact: since no normal user could see another user's profile, cookie theft and account takeover of other users were out of reach. The stored XSS was, in effect, self-XSS against his own account.

Exploitation

Step 1: identify who can see the profile

The only person who can view any normal user's account is the admin. The problem therefore split into two: getting the admin to open the profile, and knowing whether the payload executed on the admin side.

Step 2: get the admin's attention

The request content feature was the lever. The reasoning was that if the same request content were submitted 20 to 30 times, the admin, or whoever reviews requests on the other end, would notice it.

Step 3: switch to a blind payload and confirm execution

He replaced his first name with the simple blind XSS payload from xsshunter.com and checked the dashboard to see whether it still ran. It did: xsshunter sent a mail saying the payload had triggered.

Step 4: bait the admin

He typed random characters into the request content feature and repeated that request 20 to 30 times, then waited. He went out for two to three hours. When he came back there was a mail from xsshunter saying the payload had triggered.

Step 5: read the result

The mail showed the blind XSS firing inside the admin panel, and the cookies of the admin were captured. The screenshot showed the admin attempting to ban the account at the moment the payload executed.

From the original on medium.com

The chain ran from self stored XSS to admin account takeover. The report was submitted and, after three to four weeks, a bounty was awarded.

Root cause

The profile fields (first name, last name) stored user input and rendered it back into the dashboard without encoding, so HTML and script in those fields executed in the browser of the owner and, as later seen, in the admin panel. The design assumption that only the owner ever sees the profile was wrong: the payload executed in the admin's session when the admin viewed the account. The request content feature provided the notification channel that brought the admin to the profile. The report does not describe the server-side filtering or output encoding in place.

Impact

Under the conditions described, an ordinary authenticated user could store script that executed in the admin's browser session and capture the admin's cookies, which the researcher describes as leading to admin account takeover. The precondition is that an admin views the affected profile, which the researcher engineered through repeated request content submissions. The report does not state what was done with the captured cookies beyond the takeover claim.

Fix

Variants to test

  1. Store an HTML payload in every profile field and check whether it renders in the user dashboard, the public profile and any admin view. A positive result is the payload appearing as markup rather than text in any of those places.
  2. Replace the payload with a blind XSS payload from a service such as xsshunter and watch for a callback. A positive result is a hit from an origin other than your own browser, especially an admin panel.
  3. Use a noisy feature such as request content, support tickets or contact forms to draw staff to your profile, repeating the submission 20 to 30 times. A positive result is a blind XSS callback shortly after.
  4. Test whether the admin panel renders the same stored values as the user-facing dashboard. A positive result is the payload executing in the admin context, which turns self-XSS into account takeover.

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

A security researcher spent about three months looking at one private bug bounty program, a customer portal at portal.target.com. The portal did three things: you could create an account, search for products, and request products. That was it. Importantly, there was no way for one normal user to see another user's profile page.

The researcher found that the first name and last name fields on the profile accepted HTML and then displayed it back in the dashboard. He could put a small script in his own name and it would run in his own browser. On its own that is not very useful: it is called self-XSS, because the only person you can attack is yourself. But he realised that one other person can see any user's profile: the administrator. If he could get the admin to open his profile, the script would run in the admin's browser instead, and he could capture the admin's session cookies, which he describes as enough to take over the admin account.

To get the admin's attention he used the request content feature, which lets a user send free text to the people running the portal. He submitted the same request 20 to 30 times so that someone would notice. He also swapped his first name for a blind XSS payload from xsshunter.com, a service that tells you when your payload runs somewhere you cannot see. After a few hours he got an email: the payload had fired inside the admin panel, and the admin's cookies had been captured. The screenshot showed the admin trying to ban his account at that exact moment.

He reported it and, after three to four weeks, received a bounty. The rest of this article walks through the same steps slowly, explaining each idea from scratch.

The target and the setup

The target was a web application at portal.target.com. A web application is simply a program that runs on a server and that you use through your browser. This one was a customer portal: a place where customers log in, look at products and ask for them.

The program was private, meaning not everyone on the bug bounty platform could see it. He had spent about three months on this one program only, which is why he knew its infrastructure well. The report makes the point that focusing on a single program is good practice and can lead to several bounties.

No special tools were needed. He used a browser and created a normal account on the portal. For the blind part he used xsshunter.com. The only feature he relied on beyond the profile was request content, which lets a user send free text to the other side.

Finding it

Reconnaissance

Reconnaissance, or recon, is the information-gathering phase before you start poking at a target. The researcher first collected information about the technology stack, meaning the software the site is built with: the web server, the programming language, the framework and so on. Knowing the stack tells you which kinds of mistakes are likely.

He then tried a directory brute force on the subdomain. A directory brute force means asking the server for a long list of common folder and file names, one after another, to see which ones exist. It is like walking down a corridor trying every door handle. Nothing interesting came back.

The HTML test

So he did the simplest thing available: he created an account. While filling in the registration form he put a small piece of HTML in both the first name and last name fields:

HTML
<h1>tester</h1>

HTML is the language browsers use to describe a page: headings, paragraphs, images, links. <h1> means "heading, level one", and the browser normally shows the text between the tags in a large bold font. The point of this test is not to attack anything yet. It is to see whether the site treats what you typed as text or as instructions. If the dashboard shows a big bold "tester", the site is treating your input as HTML. If it shows the literal characters <h1>tester</h1>, it is treating them as plain text, which is the safe behaviour.

He confirmed the email, logged in, and the dashboard showed the payload rendered as a heading in both fields. In other words, the site was taking his input and putting it into the page as markup.

From HTML to script

He went to the edit profile section and replaced the heading in the first name field with this:

HTML
<img src=x onerror=alert(1)>

Line by line, this is one HTML tag with two attributes:

  • <img starts an image element.
  • src=x tells the browser the image is at the address x. There is no such address, so loading it will fail.
  • onerror=alert(1) is an event handler: a piece of JavaScript the browser runs when the image fails to load. alert(1) opens a small pop-up box showing the number 1.
  • > closes the tag.

So the trick is: the image cannot load, the browser runs the error handler, and the handler is JavaScript. This is a classic cross-site scripting payload. Cross-site scripting, usually shortened to XSS, is when an attacker gets their own code to run inside someone else's browser session on a website. The code then acts with that person's permissions.

He saved the changes, went back to the dashboard, and the pop-up appeared. The payload was stored on the server and shown again every time the dashboard loaded. That is stored XSS: the malicious input is saved in the site's database and served to whoever views it later.

The disappointment

He started writing the report and got stuck on the impact section. Impact means what damage an attacker could actually do. Here the answer was: not much. Because no normal user could view another user's profile, there was no victim. Cookie theft and account takeover of other users were out of reach. What he had was self-XSS: a script that only runs against the person who planted it. That is why he describes himself as very sad at this point.

The idea

He took a walk and came back with a plan. If ordinary users cannot see his profile, there is still one account that can see any user's profile: the administrator. The admin panel is the private interface where staff manage users.

That split the problem in two:

  1. How do I get the admin to open my profile?
  2. How do I know my payload actually ran on the admin's side?

For the first question he remembered the request content feature. His reasoning: if the same request is submitted 20 to 30 times, the admin, or whoever reviews requests, will surely notice it and come looking at the account.

For the second question he needed a blind XSS payload. Blind XSS is XSS where you cannot see the result yourself, because the code runs in a place you have no access to, such as an internal admin panel. You plant the payload and wait for a signal. The signal comes from an external service: the payload, when it runs, contacts that service and the service emails you. xsshunter.com is one such service.

He took the simple payload from xsshunter.com and put it in his first name field, then checked his own dashboard to confirm it still executed. It did: xsshunter emailed him to say the payload had triggered.

Exploitation, step by step

Step 1: work out who can see the profile

The only account that can view any normal user's profile is the admin's. So the target of the attack is the admin's browser session, not another customer's.

Step 2: get the admin's attention

The request content feature was the lever. He typed random characters into it and submitted the same request 20 to 30 times. The idea is simply noise: a human reviewing requests will notice a repeated, meaningless submission and investigate the account behind it.

Step 3: switch to a blind payload and confirm it runs

He replaced his first name with the blind XSS payload from xsshunter.com and loaded his own dashboard to check that it still ran. It did, and xsshunter sent him an email confirming the trigger. This check matters: if the payload had been filtered out, the rest of the plan would have been pointless.

Step 4: bait the admin

With the payload in place and the repeated requests sent, he waited. He went out with friends for two to three hours. When he came back there was an email from xsshunter saying the payload had triggered.

Step 5: read the result

The email showed the blind XSS firing inside the admin panel, and the cookies of the admin had been captured. A cookie is a small piece of data that a website asks your browser to store and send back with every request. One common use is a session cookie: after you log in, the server gives your browser a long random value, and on each later request the browser presents it so the server knows who you are. If someone else gets that value, they can present it too and the server will treat them as you. That is why stealing a session cookie is equivalent to stealing the account.

The screenshot showed the admin attempting to ban the account at the moment the payload executed.

From the original on medium.com

The chain went from self stored XSS to admin account takeover. He submitted the report and, after three to four weeks, a bounty was awarded.

Why it worked

The profile fields, first name and last name, saved whatever the user typed and then placed it back into the dashboard page without encoding. Encoding, or escaping, means converting special characters into harmless equivalents so the browser shows them as text instead of treating them as instructions. Without encoding, HTML and JavaScript in those fields run in the browser of anyone who views the profile.

The design assumed that only the owner ever sees the profile. That assumption was wrong: the payload ran in the admin's session when the admin viewed the account. The request content feature supplied the notification channel that brought the admin to the profile. The report does not describe the server-side filtering or output encoding in place.

Impact

Under the conditions described, an ordinary logged-in user could store script that executed in the admin's browser session and capture the admin's cookies, which the researcher describes as leading to admin account takeover. The precondition is that an admin views the affected profile, which the researcher engineered through repeated request content submissions. The report does not state what was done with the captured cookies beyond the takeover claim.

Fix

A content security policy is a set of rules a site sends to the browser saying which sources of script are allowed; a strict policy stops inline handlers like onerror from running even if they end up in the page.

Variants to test

  1. Store an HTML payload in every profile field and check whether it renders in the user dashboard, the public profile and any admin view. A positive result is the payload appearing as markup rather than text in any of those places.
  2. Replace the payload with a blind XSS payload from a service such as xsshunter and watch for a callback. A positive result is a hit from an origin other than your own browser, especially an admin panel.
  3. Use a noisy feature such as request content, support tickets or contact forms to draw staff to your profile, repeating the submission 20 to 30 times. A positive result is a blind XSS callback shortly after.
  4. Test whether the admin panel renders the same stored values as the user-facing dashboard. A positive result is the payload executing in the admin context, which turns self-XSS into account takeover.

Glossary

  • Account takeover: gaining control of someone else's account, usually by obtaining their session cookie or credentials.
  • Admin panel: the private interface where staff manage users and content; it often displays the same data as the public site.
  • Blind XSS: cross-site scripting where the payload runs somewhere you cannot see, such as an internal admin tool, and reports back to an external service.
  • Bug bounty program: an arrangement where a company pays researchers for reporting security flaws in its systems.
  • Content security policy: rules a site sends to the browser listing which scripts are allowed to run, used to block inline script.
  • Cookie: a small value a site asks the browser to store and send back on later requests; a session cookie identifies a logged-in user.
  • Cross-site scripting (XSS): getting your own code to run in another person's browser session on a website, with that person's permissions.
  • Directory brute force: requesting a long list of common folder and file names to discover which exist.
  • Encoding (escaping): converting special characters into harmless text so a browser displays them instead of executing them.
  • Event handler: an attribute such as onerror that tells the browser which JavaScript to run when something happens.
  • HTML: the language browsers use to describe a page's structure, such as headings, images and links.
  • Impact: the real-world damage an attacker could cause by exploiting a flaw.
  • JavaScript: the programming language browsers run, which is what an XSS payload is written in.
  • Private program: a bug bounty program visible only to invited researchers.
  • Reconnaissance (recon): gathering information about a target before testing it.
  • Request content: the portal feature that lets a user send free text to the people running the site.
  • Self-XSS: XSS where the payload only runs against the person who planted it, so there is no victim.
  • Session: the period during which a site remembers you as logged in, usually via a session cookie.
  • Stored XSS: XSS where the payload is saved on the server and served to whoever views the affected page later.
  • Technology stack: the combination of server, language and framework a site is built with.
  • xsshunter.com: an external service that hosts blind XSS payloads and emails you when one of them runs.

More by Vedant Tekale

View all

8 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.