Skip to content
XSS Write-up Beginner

How I got 450$ just in one Google search (SQLi + RXSS)?

A subdomain endpoint reflected an XSS payload and was also vulnerable to SQL injection. An attacker could execute script in a victim's browser and inject the site's database.

Zhenwar Hawlery Follow

Published on medium.com

Bounty$450 View original

Zhenwar Hawlery

Zhenwar Hawlery, 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

This is a write-up of two bugs found in a single bug bounty program: a reflected cross-site scripting (RXSS) issue and an SQL injection (SQLi) issue. The researcher does not name the company or the program, and states that the company did not want the bugs disclosed, so the target is referred to throughout as redacted.com and the subdomain as subdomain.redacted.com. The report does not describe what the affected feature normally does.

The total reward was 450 USD: 150 USD for the reflected XSS and 300 USD for the SQLi.

Setup

The researcher worked from a single selected subdomain of the target. The tools used were:

  • aquatone, for subdomain discovery and for checking subdomains for takeover.
  • Sublist3r, assetfinder and Knockpy as additional subdomain finders and enumerators.
  • Online subdomain finders: nmmapper, spyse and dnsdumpster.
  • Google Search and DuckDuckGo for dorking.
  • BurpSuite, including its Scanner.
  • SQLmap, run in wizard mode.

No accounts or roles are mentioned. The only precondition described is that the researcher had a subdomain to focus on, obtained from the enumeration step.

Finding it

Step 1: subdomain enumeration

The researcher started with subdomain discovery, on the reasoning that hidden directories on subdomains sometimes contain critical bugs. aquatone was used for this, with the following command after installation:

Bash
aquatone-discover -d sitetarget.com
aquatone tool From the original on medium.com

The screenshot shows the aquatone tool in use. According to the report, aquatone collects subdomains, reports which of them are available, and checks them for subdomain takeover. The result of this step was 50+ subdomains, most of them active on the website. One of them was chosen as the primary target.

Step 2: dorking the chosen subdomain

With a subdomain selected, the first methodology applied was dorking through Google Search and DuckDuckGo, using this keyword:

Text
site:subdomain.redacted.com
Google Search From the original on medium.com

The screenshot shows the Google search results for that query. The report also lists the kinds of random keywords that can be used to surface directories, files and parameters through search engines:

Text
site:example.com admin
Text
site:example.com login
Text
site:example.com key
Text
site:example.com log
Text
site:example.com php or site:example.com html
Text
site:example.com id=

and random numbers:

Text
site:example.com 1
Text
site:example.com 2020

This search surfaced an endpoint, shown in the screenshot below.

An error page From the original on medium.com

The screenshot shows that page.

Exploitation

Step 3: reflected XSS

The first thing tried on the endpoint was XSS, with this payload:

Text
"><svg/onload=alert(document.domain)>

The payload uses "> to break out, then an svg element whose onload handler calls alert(document.domain). According to the report, the alert fired, confirming reflected XSS.

The bug was reported directly to the company, which replied after a few hours and paid a 150 USD bounty.

Step 4: retesting after the fix

After waiting a few hours for the fix, the researcher revisited the directory and found that the company's security team had fixed the bug. Several XSS payloads were tried to bypass the new filter, but none worked.

Step 5: finding the SQLi with Burp Scanner

BurpSuite was opened and the page reloaded. The request was captured, sent to Burp Scanner, and Burp was minimised while other approaches were tried. After a few minutes Burp reported an SQLi bug.

Step 6: confirming the SQLi with SQLmap

A terminal was opened and SQLmap was run in wizard mode:

Bash
sqlmap — wizard

The vulnerable URL was entered into the wizard. The report states that the researcher was able to inject the main website database and used this as a proof of concept.

SQLmap tool for Automatic Injecting SQL Vulnerabilities From the original on medium.com

The screenshot shows SQLmap being used for automatic injection of SQL vulnerabilities.

Step 7: reporting and reward

The SQLi was reported to the website security team, which replied within 5 to 15 minutes. The rewards were 150 USD for the reflected XSS and 300 USD for the SQLi, 450 USD in total.

Root cause

The report does not analyse the code behind either bug. For the XSS, the payload "><svg/onload=alert(document.domain)> executed, which indicates that user input was reflected into an HTML context without adequate output encoding. For the SQLi, Burp Scanner flagged the request and SQLmap was able to inject the database, which indicates that user input reached a SQL query without proper parameterisation.

Impact

The reflected XSS allowed script execution in the context of the affected subdomain, as demonstrated by alert(document.domain). The SQLi allowed injection of the main website database, which the researcher used as a proof of concept.

Fix

The researcher revisited the directory and found the XSS had been fixed; retried payloads no longer worked.

Variants to test

  1. Dork for error pages on other subdomains. Run site:subdomain.target.com with the keyword lists above and look for endpoints that return error pages. A positive result is an endpoint that reflects input or accepts parameters worth testing.
  2. Reflection test with a harmless marker. Send a unique string in each parameter and check whether it appears unencoded in the response. A positive result is the marker appearing inside an HTML attribute or tag context.
  3. XSS payload after a fix. When a filter is deployed, retry context-appropriate payloads such as the one above. A positive result is the alert firing again, which would mean the fix is bypassable.
  4. Scanner pass on captured requests. Send requests to Burp Scanner and review its findings. A positive result is a reported injection point that can then be confirmed manually.
  5. SQLmap confirmation. Run SQLmap against a suspected parameter and check whether it identifies an injectable parameter and can retrieve data. A positive result is a confirmed injection with a working proof of concept.

As the researcher puts it: check again and gain again.

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 found two bugs in a company's website and was paid 450 US dollars for them. The first bug was a reflected cross-site scripting (XSS) issue, worth 150 dollars. The second was an SQL injection (SQLi) issue, worth 300 dollars. Both were found on the same subdomain of the same target.

The researcher does not name the company or the program, because the company did not want the bugs made public. Throughout the write-up the target is called redacted.com and the subdomain is called subdomain.redacted.com. The report does not describe what the affected feature normally does.

You do not need any special software knowledge to follow this. Everything below is explained from zero, in the order the researcher did it.

Setup

The researcher picked one subdomain of the target and worked only on that. The tools used were:

  • aquatone, for finding subdomains and for checking them for takeover.
  • Sublist3r, assetfinder and Knockpy, as extra subdomain finders and enumerators.
  • Online subdomain finders: nmmapper, spyse and dnsdumpster.
  • Google Search and DuckDuckGo for dorking.
  • BurpSuite, including its Scanner.
  • SQLmap, run in wizard mode.

No accounts or roles are mentioned. The only precondition described is that the researcher had a subdomain to focus on, obtained from the enumeration step.

Finding it

Step 1: subdomain enumeration

A subdomain is a smaller part of a website's address. If the main site is example.com, then shop.example.com and blog.example.com are subdomains. They often run different software, are maintained by different teams, and are forgotten more often than the main site, which is why researchers look at them first.

The researcher started with subdomain discovery, on the reasoning that hidden directories on subdomains sometimes contain critical bugs. aquatone was used for this, with the following command after installation:

Bash
aquatone-discover -d sitetarget.com

Line by line:

  • aquatone-discover is the name of the program being run. It is one part of the aquatone toolkit.
  • -d is a flag, meaning "the domain I want to look at follows".
  • sitetarget.com is the domain being searched. It is a placeholder for the real target.

The command asks aquatone to go out and collect as many subdomains of sitetarget.com as it can find.

aquatone tool From the original on medium.com

The screenshot shows the aquatone tool in use. According to the report, aquatone collects subdomains, reports which of them are available, and checks them for subdomain takeover. Subdomain takeover is when a subdomain points at a service that no longer exists, so anyone who claims that service can effectively take over the subdomain. Think of a shop that moved out but left its sign on the door: anyone can hang their own sign there.

The result of this step was 50+ subdomains, most of them active on the website. One of them was chosen as the primary target.

Step 2: dorking the chosen subdomain

With a subdomain selected, the first methodology applied was dorking. Dorking means using a search engine's normal search box with special keywords to find pages the site owner may not have meant to expose. It is like using a library catalogue with very precise search terms instead of browsing the shelves.

The researcher used Google Search and DuckDuckGo with this keyword:

Text
site:subdomain.redacted.com

Line by line:

  • site: is a search operator. It tells the search engine to return only results from the domain that follows.
  • subdomain.redacted.com is the subdomain being searched.

So the query asks Google: show me every page you know about on this subdomain.

Google Search From the original on medium.com

The screenshot shows the Google search results for that query.

The report also lists the kinds of random keywords that can be used to surface directories, files and parameters through search engines:

Text
site:example.com admin
Text
site:example.com login
Text
site:example.com key
Text
site:example.com log
Text
site:example.com php or site:example.com html
Text
site:example.com id=

and random numbers:

Text
site:example.com 1
Text
site:example.com 2020

Line by line:

  • admin, login, key, log are words that often appear in the addresses of administrative or login pages. Pages like these are interesting because they are meant for staff, not visitors.
  • php and html are file types. Searching for them finds pages written in those languages.
  • id= is a common pattern in web addresses that carry a parameter. A parameter is a named value in a URL, like the q in a search address. Parameters are where a lot of bugs live, because they carry input from the user into the site.
  • 1 and 2020 are just numbers. Pages that contain numbers in their addresses often have numeric parameters, which are worth testing.

This search surfaced an endpoint. An endpoint is a specific address on a website that does something when you visit it, like a counter in a shop.

An error page From the original on medium.com

The screenshot shows that page.

Exploitation

Step 3: reflected XSS

Cross-site scripting, or XSS, is a bug where a website takes something a visitor typed and puts it into the page without cleaning it first. If the visitor typed a piece of code instead of normal text, the browser runs that code as if the site itself had written it. Think of a noticeboard where anyone can pin a note: if the board does not check what is pinned, someone can pin a note that says "hand over your keys" and other visitors will believe it came from the shop.

Reflected XSS means the input is not stored on the server. It goes straight from the request back into the response, so the victim has to be tricked into clicking a prepared link.

The first thing tried on the endpoint was XSS, with this payload:

Text
"><svg/onload=alert(document.domain)>

Line by line:

  • "> closes whatever HTML attribute or tag the input was sitting inside. If the page had written value=" before the input, this closes the quote and the tag, so what follows is treated as new HTML rather than as text.
  • <svg starts an SVG element. SVG is a way to draw pictures in HTML, and it can carry event handlers.
  • /onload= attaches an event handler called onload, which runs as soon as the element has loaded.
  • alert(document.domain) is the code that runs. alert opens a pop-up box, and document.domain is the current site's address. Showing the address proves the code is running in the context of the target site, not somewhere harmless.
  • > closes the SVG tag.

According to the report, the alert fired, confirming reflected XSS. A pop-up appearing is the simplest possible proof: it means the browser ran code that the site did not intend to run.

The bug was reported directly to the company, which replied after a few hours and paid a 150 USD bounty. A bounty is a reward a company pays to someone who reports a bug responsibly instead of misusing it.

Step 4: retesting after the fix

After waiting a few hours for the fix, the researcher revisited the directory and found that the company's security team had fixed the bug. A fix here means the site now cleans or blocks the input that used to get through.

Several XSS payloads were tried to bypass the new filter, but none worked. A filter is a check the site performs on input before using it. Bypassing a filter means finding an input that the filter does not recognise as dangerous but the browser still runs. Retesting after a fix matters because a filter that only blocks the exact payload from the first report is not a real fix.

Step 5: finding the SQLi with Burp Scanner

BurpSuite is a tool that sits between your browser and the website, so you can see and change every request the browser sends. A request is the message your browser sends to a server when you open a page or submit a form. Burp lets you capture that message, look at it, and send it again with changes.

BurpSuite was opened and the page reloaded. The request was captured, sent to Burp Scanner, and Burp was minimised while other approaches were tried. The Scanner is the part of Burp that automatically tries many kinds of input against a request and reports anything that looks wrong. After a few minutes Burp reported an SQLi bug.

SQL injection, or SQLi, is a bug where a website builds a database query out of whatever a visitor typed, without separating the two. SQL is the language databases use to fetch and change data. If the visitor's text becomes part of the query, the visitor can change what the query does. Think of a form where you write your name and the clerk reads it out loud to a colleague: if you write "and also open the safe", the colleague may do it, because nothing marked where your name ended and the instruction began.

Step 6: confirming the SQLi with SQLmap

A terminal was opened and SQLmap was run in wizard mode:

Bash
sqlmap — wizard

Line by line:

  • sqlmap is the name of the program. It is a tool that automates testing a URL for SQL injection.
  • — wizard is the option that starts an interactive mode. Instead of typing many flags, the tool asks you questions one at a time.

The vulnerable URL was entered into the wizard. The report states that the researcher was able to inject the main website database and used this as a proof of concept. A proof of concept is the smallest demonstration that a bug is real, enough to convince the owner without doing damage.

SQLmap tool for Automatic Injecting SQL Vulnerabilities From the original on medium.com

The screenshot shows SQLmap being used for automatic injection of SQL vulnerabilities.

Step 7: reporting and reward

The SQLi was reported to the website security team, which replied within 5 to 15 minutes. The rewards were 150 USD for the reflected XSS and 300 USD for the SQLi, 450 USD in total.

Root cause

The report does not analyse the code behind either bug. For the XSS, the payload "><svg/onload=alert(document.domain)> executed, which indicates that user input was reflected into an HTML context without adequate output encoding. Output encoding means converting characters like < and " into harmless forms before putting them in a page, so the browser shows them as text instead of treating them as code.

For the SQLi, Burp Scanner flagged the request and SQLmap was able to inject the database, which indicates that user input reached a SQL query without proper parameterisation. Parameterisation means sending the query and the data separately, so the database always treats the data as data and never as part of the instruction.

Impact

The reflected XSS allowed script execution in the context of the affected subdomain, as demonstrated by alert(document.domain). The SQLi allowed injection of the main website database, which the researcher used as a proof of concept.

Fix

The researcher revisited the directory and found the XSS had been fixed; retried payloads no longer worked.

Variants to test

  1. Dork for error pages on other subdomains. Run site:subdomain.target.com with the keyword lists above and look for endpoints that return error pages. A positive result is an endpoint that reflects input or accepts parameters worth testing.
  2. Reflection test with a harmless marker. Send a unique string in each parameter and check whether it appears unencoded in the response. A positive result is the marker appearing inside an HTML attribute or tag context.
  3. XSS payload after a fix. When a filter is deployed, retry context-appropriate payloads such as the one above. A positive result is the alert firing again, which would mean the fix is bypassable.
  4. Scanner pass on captured requests. Send requests to Burp Scanner and review its findings. A positive result is a reported injection point that can then be confirmed manually.
  5. SQLmap confirmation. Run SQLmap against a suspected parameter and check whether it identifies an injectable parameter and can retrieve data. A positive result is a confirmed injection with a working proof of concept.

As the researcher puts it: check again and gain again.

Glossary

  • Subdomain: a smaller part of a website's address, such as shop.example.com under example.com.
  • Subdomain takeover: when a subdomain points at a service that no longer exists, letting anyone who claims that service control the subdomain.
  • aquatone: a tool that collects subdomains, reports which are available, and checks them for takeover.
  • Sublist3r, assetfinder, Knockpy: additional tools for finding and enumerating subdomains.
  • Dorking: using a search engine's normal search box with special keywords to find pages the owner may not have meant to expose.
  • Endpoint: a specific address on a website that does something when you visit it.
  • Parameter: a named value in a URL, such as id= or q=, that carries input from the user into the site.
  • Error page: the page a site shows when something goes wrong, often echoing back what was typed.
  • Cross-site scripting (XSS): a bug where a site puts visitor input into a page without cleaning it, so the browser runs it as code.
  • Reflected XSS: XSS where the input goes straight from the request back into the response, so the victim must be tricked into clicking a prepared link.
  • Payload: the piece of input an attacker sends to trigger a bug.
  • Filter: a check a site performs on input before using it.
  • Bypass: finding an input that a filter does not recognise as dangerous but the browser still runs.
  • BurpSuite: a tool that sits between your browser and a website so you can see and change every request.
  • Request: the message your browser sends to a server when you open a page or submit a form.
  • Scanner: the part of Burp that automatically tries many kinds of input against a request and reports anything that looks wrong.
  • SQL injection (SQLi): a bug where a site builds a database query out of visitor input without separating the two, so the visitor can change what the query does.
  • SQL: the language databases use to fetch and change data.
  • SQLmap: a tool that automates testing a URL for SQL injection.
  • Proof of concept: the smallest demonstration that a bug is real, enough to convince the owner without doing damage.
  • Output encoding: converting characters like < and " into harmless forms before putting them in a page.
  • Parameterisation: sending a query and its data separately, so the database always treats the data as data.
  • Bounty: a reward a company pays to someone who reports a bug responsibly instead of misusing it.
  • Fix: a change to the site that cleans or blocks the input that used to get through.

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.