Skip to content
XSS Write-up Intermediate

How I found Cross-Site-Scripting (Reflected) on more than 300 systems!

A reflected XSS vulnerability was found in a third-party admin panel service's 404 error page, where user input was reflected without proper sanitisation. An attacker could execute arbitrary JavaScript in a victim's browser by crafting a malicious URL, potentially leading to session hijacking or other client-side attacks.

MR SINISTER Follow

Published on mrsinister1501.medium.com

Hey everyone, welcome to my second write-up. If you didn’t read my first, you can find it https://mrsinister1501.medium.com/my-bug-bounty-hunting-journey-methodology-and-tips-xd-790d8deb6247 This write-up is going to be about an Interesting bug, which I found a month ago.

Mr-Sinister, on mrsinister1501.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. 6 min read.

Context

This is a write-up about a reflected cross-site scripting issue found on a login page and admin panel belonging to a third-party service that provides admin panels to companies. The researcher found the service through Shodan while working a private HackerOne program, and the reflection appeared on the service's 404 error page. The report does not name the service or the affected domain.

The write-up was published on 25 April 2021, and the researcher describes the bug as found about a month earlier.

Setup

The researcher had been invited to a large private program on HackerOne and decided to focus on it. The tools and techniques mentioned are:

  • Shodan, for finding targets belonging to the company.
  • ffuf, for content discovery against the login endpoint.
  • PortSwigger's XSS cheat sheet and the PortSwigger article on beating HTML sanitising filters, used while building payloads.
  • A browser, to check reflections in the page source.

No versions, accounts or roles are given. The only precondition is access to the private program.

Finding it

The researcher started automation and, in parallel, ran Shodan dorking against the company to find interesting targets. The query used was:

Text
org:target http.html:"Login" port:443 -http.title:"Error,Forbidden,403"

This searches Shodan for hosts in the organisation's range, on port 443, whose HTML contains "Login", excluding results whose page title contains the listed error strings. Going through the results, the last one was a service the researcher recognised as providing admin panels for companies, which made it worth a look.

The domain loaded a login page that looked like an admin panel. The researcher tested for several vulnerabilities without success. Before moving on, they checked the ffuf output for the endpoint and got nothing. Frustrated, they requested /pleasework and saw that the path was reflected on the 404 error page.

That reflection is the entry point: user-controlled text from the URL path is written into the error page's HTML.

Exploitation

Step 1: confirm HTML injection

The first test was a strikethrough tag, <s>strikethrough?</s>, and HTML injection worked. This confirms that markup in the path reaches the response without being neutralised.

Step 2: try the basic payload and hit the WAF

The next attempt was the classic <script>alert(1)</script>. A WAF blocked it.

Step 3: map what the WAF blocks

By trial and error the researcher concluded that any payload containing the following tags causes the request to be blocked:

Text
<a>
 <script>
 <body>
 <audio>
 <image>
 <img>
 <style>
 <iframe>
 "javascript"
 <animate>

Many event handlers were also blocked when sent in the request, for example onerror.

Step 4: try <div>

The researcher remembered that <div> tags can also be used to get XSS. A payload using <div> was not blocked, but it did not execute either, because other characters in the payload were being blocked. The task became building a payload around <div>, using PortSwigger's XSS cheat sheet and the article on beating HTML sanitising filters for ideas.

Step 5: a working payload that needs a hover

After trying different event handlers against the WAF, this payload worked:

HTML
<div onpointerover=”alert(‘XSS POC by mrsinister15’)”>Please put your mouse on me to see the magic ;)</div>

The onpointerover handler fires when the pointer moves over the element, so the script runs when a user hovers the text "Please put your mouse on me to see the magic ;)". That works, but it requires the victim to hover that specific text.

Step 6: reduce the interaction with <html>

The researcher then replaced <div> with <html>, reasoning that the handler would then fire when the victim hovers anywhere on the page, requiring much less interaction. The report does not show the exact <html> payload.

The issue was reported to the private program that night.

Step 7: payloads with no interaction

The next morning the researcher produced two more payloads, neither of which needs user interaction:

HTML
<svg id=x tabindex=1 onload=alert(1)></svg>

Here the onload handler fires when the page loads. The alternative, described as the best payload, was:

HTML
<svg/onload=alert(1)>

Both were added to the report.

Step 8: triage and scope

The report was triaged, but the team accepted it as Admin Panel Disclosure rather than reflected XSS. In their view the XSS was in a third-party service, not in their own system.

That response led to the wider realisation: every website using the third-party service would be vulnerable to XSS with the same payloads. The researcher went back to Shodan to search for the service and its version, got more than 300 results, and tested the payload on a few of them. All of those tested were vulnerable at the same endpoint with the same payload.

The researcher contacted the service to report the issue and was waiting for a fix. On 23 April 2021 the private program paid out for the disclosed admin panel, which turned out to be an admin panel to their internal network that they could not afford to expose.

Root cause

The 404 page reflects the requested path into its HTML without encoding or filtering it, so markup supplied in the URL becomes part of the page. The WAF blocked a list of tags and some event handlers, but the <div>, <html> and <svg> payloads with onpointerover and onload got through. The protection is therefore a blocklist that misses valid alternatives, and the underlying output encoding is absent.

Impact

An attacker who can get a victim to open a crafted URL on an affected installation can run script in the victim's browser in the context of that site. The <svg/onload=alert(1)> form needs no interaction beyond loading the page. Because the vulnerable component is a third-party admin panel service, a Shodan search returned more than 300 systems, and the few tested were vulnerable at the same endpoint with the same payload. The private program treated the exposure as an admin panel to its internal network.

Fix

The <div>, <html> and <svg> payloads got past the WAF blocklist.

Variants to test

  1. Request a random path such as /pleasework123 and search the response source for the string. A reflection in the body, in an attribute, or inside a script block tells you where to work.
  2. Send <s>test</s> and check whether the tag is rendered. Rendered markup means HTML injection is possible.
  3. Send <script>alert(1)</script>. If it is blocked, a WAF is likely present; if it is not blocked but does not run, look at how the reflection is encoded.
  4. Try tags outside the obvious blocklist, such as <div>, <html> and <svg>, and pair them with handlers such as onpointerover and onload. A payload that executes on page load, like <svg/onload=alert(1)>, is the strongest result because it needs no user interaction.
  5. Add special characters to the reflected input, for example pleasework123 ' " ><, and inspect the response to see which are filtered.
  6. If the target HTML-encodes < and > as &lt; and &gt;, try a payload built from those encoded entities, such as &lt;script&gt;alert(1)&lt;/script&gt;, in case the value is decoded later.
  7. If the target URL-encodes the input, try double URL encoding the payload, in case it is decoded once more downstream.
  8. Where <> are filtered outright, try breaking out of the surrounding tag with a quote or double quote.
  9. Put an XSSHunter payload in every input field, especially contact forms, to catch blind XSS that fires in an admin interface later.
A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store From the original on mrsinister1501.medium.com
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store

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

What happened, in plain words

A security researcher was invited to a private bug bounty programme on HackerOne. Bug bounty programmes are schemes where companies pay people to find security problems in their systems and report them privately. The researcher used a search engine called Shodan, which indexes devices and services connected to the internet, to find one of the company's systems that looked interesting: a service that provides admin panels to companies. An admin panel is a private web page where staff manage a product or service, usually after logging in.

The researcher tried a few attacks on that login page and nothing worked. Then they typed a made-up address into the site, /pleasework, and noticed that the word "pleasework" appeared in the error page the site returned. That is the key moment: text the visitor controls is being copied into the page's HTML. HTML is the language web pages are written in, and if a site copies your text into its HTML without cleaning it, you can sometimes make the page run code. That class of bug is called cross-site scripting, or XSS.

A firewall for web traffic, called a WAF (web application firewall), blocked the obvious attacks. The researcher spent time working out which pieces of HTML the WAF refused, then built an attack from pieces it allowed. Two later payloads ran JavaScript (the programming language browsers execute) as soon as the page loaded, with no click or hover needed.

The researcher reported it. The company accepted the report, but as "admin panel disclosure" rather than XSS, because the vulnerable software belonged to a third-party company that sells admin panels to other businesses. That meant every website using that software would be vulnerable too. A Shodan search for the software returned more than 300 systems, and the few the researcher tested all fell to the same payload. The researcher told the software vendor and waited for a fix. On 23 April 2021 the private programme paid out for the exposed admin panel, which turned out to lead into their internal network.

Background you need first

A few ideas come up again and again below, so here they are in plain terms.

  • A URL path is the part of a web address after the domain. In https://example.com/pleasework, the path is /pleasework. When you visit a path that does not exist, the server usually answers with a "404 Not Found" page.
  • A 404 page is just a web page the server builds to tell you the address was wrong. Many sites put the address you asked for into that page, so you can see what went wrong. If they do that without cleaning the text, whatever you typed becomes part of the page.
  • HTML is the markup that describes a page: tags like <div> (a generic box) or <script> (a block of code) tell the browser what to draw or run. JavaScript is the code those tags can contain.
  • XSS (cross-site scripting) means getting your own JavaScript to run inside someone else's web page, in the victim's browser. "Reflected" XSS means the malicious text travels in the request (here, in the URL) and is echoed straight back in the response. "Stored" XSS would mean the site saves it and shows it to others later.
  • A WAF is a filter that sits in front of a website and inspects requests, blocking ones that look like attacks. Many WAFs work from a blocklist: a list of known-bad words and tags. Blocklists are easy to get around because there are always other ways to write the same thing.
  • Shodan is a search engine for internet-connected services rather than web pages. You can search by organisation, port (the numbered door a service listens on; 443 is the standard port for encrypted HTTPS traffic) and by text found in the page.
  • ffuf is a command-line tool that tries many possible paths on a site quickly, to discover pages that are not linked anywhere.

The setup

The researcher had been invited to a large private programme on HackerOne and decided to concentrate on it. The tools mentioned are Shodan for finding the company's systems, ffuf for guessing paths on the login page, PortSwigger's XSS cheat sheet and PortSwigger's article on beating HTML sanitising filters for payload ideas, and a browser to look at the page source. The page source is the raw HTML the server sent, which you can view in any browser; it shows what the site really produced, not just what it drew on screen.

No versions, accounts or roles are given. The only precondition mentioned is access to the private programme.

Finding the target

The researcher started some automation and, in parallel, searched Shodan for systems belonging to the company. The query was:

Text
org:target http.html:"Login" port:443 -http.title:"Error,Forbidden,403"

Line by line:

  • org:target limits results to hosts registered to the organisation (the name is a placeholder here).
  • http.html:"Login" keeps only hosts whose page HTML contains the word "Login".
  • port:443 keeps only hosts listening on port 443, the HTTPS port.
  • -http.title:"Error,Forbidden,403" removes results whose page title contains those error words, so the list is less noisy.

Going through the results, the last one was a service the researcher recognised as one that provides admin panels to companies. That made it worth a closer look, because admin panels are exactly the kind of thing an attacker would like to reach.

The domain loaded a login page and admin panel. The researcher tested for several kinds of vulnerability and none worked. Before giving up on the endpoint, they checked what ffuf had found for it and got nothing. Frustrated, they requested /pleasework by hand and saw that the path appeared in the 404 error page.

That reflection is the entry point. Text from the URL path is written into the error page's HTML, and if it is written without cleaning, the browser will treat it as markup.

Exploitation, step by step

Step 1: confirm HTML injection

The first test was a strikethrough tag:

HTML
<s>strikethrough?</s>

<s> starts strikethrough text and </s> ends it. If the word came back crossed out on the page, the browser had treated the tag as markup rather than as plain text. It did, so HTML injection worked: markup in the path reaches the response without being neutralised.

Step 2: try the classic payload and hit the WAF

The next attempt was the textbook XSS payload:

HTML
<script>alert(1)</script>

<script> tells the browser to run the JavaScript inside it, and alert(1) opens a small pop-up showing "1". A pop-up is the harmless proof that code ran. A WAF blocked this request.

Step 3: map what the WAF blocks

By trial and error the researcher worked out that any payload containing these tags caused the request to be blocked:

Text
<a>
 <script>
 <body>
 <audio>
 <image>
 <img>
 <style>
 <iframe>
 "javascript"
 <animate>

Each line is a piece of HTML the WAF refused to let through: links (<a>), scripts (<script>), page bodies (<body>), audio (<audio>), images (<image>, <img>), styles (<style>), embedded frames (<iframe>), the literal word "javascript", and SVG animation (<animate>). Many event handlers were blocked too, for example onerror. An event handler is an attribute on a tag that names code to run when something happens, such as an image failing to load (onerror).

Step 4: try <div>

The researcher remembered that <div> tags can also be used to get XSS. A payload using <div> was not blocked, but it did not run either, because other characters in the payload were being blocked. The task became building a payload around <div>, using PortSwigger's XSS cheat sheet and the article on beating HTML sanitising filters for ideas.

Step 5: a working payload that needs a hover

After trying different event handlers against the WAF, this payload worked:

HTML
<div onpointerover=”alert(‘XSS POC by mrsinister15’)”>Please put your mouse on me to see the magic ;)</div>

Line by line:

  • <div opens a generic box element.
  • onpointerover=”alert(‘XSS POC by mrsinister15’)” is an event handler: when the pointer moves over the box, run the JavaScript alert('XSS POC by mrsinister15'), which shows a pop-up with that text. "POC" means proof of concept, a minimal demonstration that the bug is real.
  • >Please put your mouse on me to see the magic ;)</div> is the visible text inside the box, followed by the closing tag.

The handler fires when the pointer moves over the element, so the script runs when a user hovers that text. That works, but it requires the victim to hover one specific piece of text, which is unlikely.

Step 6: reduce the interaction with <html>

The researcher then replaced <div> with <html>, reasoning that the handler would then fire when the victim hovers anywhere on the page, requiring much less interaction. The exact <html> payload is not shown in the write-up.

The issue was reported to the private programme that night.

Step 7: payloads with no interaction

The next morning the researcher produced two more payloads, neither of which needs user interaction:

HTML
<svg id=x tabindex=1 onload=alert(1)></svg>

Line by line:

  • <svg opens an SVG element. SVG is a format for drawing graphics inside a web page.
  • id=x gives the element the name x, so it can be referred to.
  • tabindex=1 makes the element focusable, as if it were a button in a form.
  • onload=alert(1) is the handler: when the element loads, run alert(1).
  • ></svg> closes the element.

Here the onload handler fires when the page loads. The alternative, described as the best payload, was:

HTML
<svg/onload=alert(1)>

This is the same idea in the shortest form: <svg opens the element, the / ends the opening tag early, onload=alert(1) runs the pop-up when it loads, and > closes the tag. No hover, no click, nothing but the page loading. Both were added to the report.

Step 8: triage and scope

The report was triaged, meaning the programme's staff reviewed it and confirmed it was valid. But the team accepted it as admin panel disclosure rather than reflected XSS. In their view the XSS was in a third-party service, not in their own system.

That response led to a wider realisation: every website using that third-party service would be vulnerable to XSS with the same payloads. The researcher went back to Shodan to search for the service and its version, got more than 300 results, and tested the payload on a few of them. All of those tested were vulnerable at the same endpoint with the same payload.

The researcher contacted the service to report the issue and was waiting for a fix. On 23 April 2021 the private programme paid out for the disclosed admin panel, which turned out to be an admin panel to their internal network that they could not afford to expose.

Why it worked

The 404 page copies the requested path into its HTML without encoding or filtering it, so markup supplied in the URL becomes part of the page. Encoding here means turning characters like < into harmless text such as &lt;, so the browser shows them instead of acting on them. The WAF blocked a list of tags and some event handlers, but the <div>, <html> and <svg> payloads with onpointerover and onload got through. The protection is a blocklist that misses valid alternatives, and the underlying output encoding is absent. The write-up does not describe the server-side code, so the exact place where encoding should happen is not stated.

What an attacker could do

An attacker who can get a victim to open a crafted URL on an affected installation can run script in the victim's browser in the context of that site. Running "in the context of the site" means the script is treated as part of that website, so it can do what the site's own pages can do for that logged-in user. The <svg/onload=alert(1)> form needs no interaction beyond loading the page. Because the vulnerable component is a third-party admin panel service, a Shodan search returned more than 300 systems, and the few tested were vulnerable at the same endpoint with the same payload. The write-up does not state what data or actions the panel exposes, so the practical consequences beyond script execution are not described. The private programme treated the exposure as an admin panel to its internal network.

How it should be fixed

The <div>, <html> and <svg> payloads got past the WAF blocklist.

Things to try yourself

  1. Request a random path such as /pleasework123 and search the response source for the string. A reflection in the body, in an attribute, or inside a script block tells you where to work.
  2. Send <s>test</s> and check whether the tag is rendered. Rendered markup means HTML injection is possible.
  3. Send <script>alert(1)</script>. If it is blocked, a WAF is likely present; if it is not blocked but does not run, look at how the reflection is encoded.
  4. Try tags outside the obvious blocklist, such as <div>, <html> and <svg>, and pair them with handlers such as onpointerover and onload. A payload that executes on page load, like <svg/onload=alert(1)>, is the strongest result because it needs no user interaction.
  5. Add special characters to the reflected input, for example pleasework123 ' " ><, and inspect the response to see which are filtered.
  6. If the target HTML-encodes < and > as &lt; and &gt;, try a payload built from those encoded entities, such as &lt;script&gt;alert(1)&lt;/script&gt;, in case the value is decoded later.
  7. If the target URL-encodes the input, try double URL encoding the payload, in case it is decoded once more downstream. URL encoding replaces special characters with % codes so they can travel safely in an address.
  8. Where <> are filtered outright, try breaking out of the surrounding tag with a quote or double quote.
  9. Put an XSSHunter payload in every input field, especially contact forms, to catch blind XSS that fires in an admin interface later. Blind XSS is one where the payload runs somewhere you cannot see, such as a staff member's admin screen, and XSSHunter is a service that tells you when it fires.

Glossary

  • Admin panel: a private web interface where staff manage a product or service, usually behind a login.
  • Blind XSS: XSS that fires somewhere the attacker cannot see, such as an admin screen, rather than in the attacker's own browser.
  • Blocklist: a filter that blocks a list of known-bad items and allows everything else.
  • Bug bounty programme: a scheme where a company pays researchers to report security problems privately.
  • Cross-site scripting (XSS): getting your own JavaScript to run inside someone else's web page in a victim's browser.
  • Encoding (HTML): turning characters like < into harmless text such as &lt; so the browser displays them instead of acting on them.
  • Event handler: an attribute on an HTML tag that names code to run when something happens, such as a pointer moving over it or an element loading.
  • ffuf: a command-line tool that tries many possible paths on a site to discover hidden pages.
  • HackerOne: a platform where companies run bug bounty programmes and receive reports.
  • HTML: the markup language web pages are written in, made of tags such as <div> and <script>.
  • HTML injection: getting your own markup into a page, which may or may not lead to code running.
  • HTTPS / port 443: the encrypted version of the web protocol, and the numbered port it normally uses.
  • JavaScript: the programming language browsers run; XSS is about getting it to run on someone else's page.
  • Payload: the small piece of input crafted to trigger a bug.
  • Port: a numbered door on a computer that a network service listens on.
  • Proof of concept (POC): a minimal demonstration that a bug is real.
  • Reflected XSS: XSS where the malicious text travels in the request and is echoed straight back in the response.
  • Shodan: a search engine for internet-connected services, searchable by organisation, port and page content.
  • SVG: a format for drawing graphics inside a web page.
  • Triage: the review step where a programme's staff confirm a report is valid.
  • URL encoding: replacing special characters with % codes so they can travel safely in a web address.
  • URL path: the part of a web address after the domain, such as /pleasework.
  • WAF (web application firewall): a filter in front of a website that inspects requests and blocks ones that look like attacks.
  • XSSHunter: a service that hosts XSS payloads and alerts you when one fires.
A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store From the original on mrsinister1501.medium.com
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store

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.