Skip to content
SQL injection Write-up Beginner

How 2 Cute Bugs offered me a reward of 650€

The product search page reflected user input without sanitisation, allowing cross-site scripting, and the product ID parameter was vulnerable to SQL injection. An attacker could exploit the SQL injection to dump the database, including admin credentials, and then log in as an administrator.

Anirudh Krishnakumar Follow

Published on medium.com

Bounty$691 View original

Hey amazing cyberfolks 😊 !!. This is me ani ! back with an interesting vulnerabilities I found ,for which I was awarded a bounty of 650€.

Anirudh Krishnakumar(a.k.a)0x_s3cur1ty_r3s34rch3r, 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 write-up covers two vulnerabilities found on an online travel goods e-commerce site, referred to throughout as redacted.com. The site let visitors register an account and buy travel products. Two features mattered here: a search box that reflected the submitted term back into the page, and a product page whose URL carried a numeric product identifier, for example redacted.com/products?productID=21. The product ID selected which product was displayed.

The researcher received a reward of 650€ for the report.

From the original on medium.com

Setup

The target was not found on a public bug bounty platform. The researcher prefers private programs discovered through Google dorks, because HackerOne and Bugcrowd can be crowded, and notes that dork-based programs are often unresponsive. The starting point was a curated list of dorks in a GitHub repository:

Text
responsible disclosure bounty r=h:eu

The researcher paged through many results, deliberately chose an old program, and picked a random domain from it. On the target, a normal user account was registered and the application was explored as a logged-in user.

Finding it

Login and authentication features were tested first without success. The search feature was the first opening: searching for testbro reflected the input in the page. Breaking out of the surrounding context and injecting an XSS payload executed it, and an alert box appeared. The payload used was of the form:

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

While browsing products, the researcher noticed that every product link carried a numeric ID in the URL, as in redacted.com/products?productID=21. A single quote was appended to the value:

Text
productID=21'

The server returned an SQL syntax error.

From the original on medium.com

Exploitation

Step 1: Confirm and enumerate with sqlmap

Rather than crafting payloads by hand, the researcher used sqlmap, while recommending manual testing to understand the underlying behaviour. The first command listed the databases on the server:

Bash
 sqlmap -u http://redacted.com/products?productID=21 --dbs

-u sets the target URL and --dbs asks sqlmap to enumerate database names. The tool returned the full list of databases. One database name stood out, and it was used to list its tables:

Bash
sqlmap -u http://redacted.com/products?productID=21 -D redacted --tables

-D redacted selects the database and --tables enumerates its tables. Among the results was a table named users. The researcher then dumped it:

Bash
sqlmap -u http://redacted.com/products?productID=21 -D redacted -T users --dump-all

-T users selects the table and --dump-all extracts its contents. The dump included the administrator's username and password.

The password was stored in an encoded form. The researcher pasted it into CyberChef, identified the encoding as Base64, and decoded it to recover the plaintext password.

Step 2: Find the admin login

With credentials in hand, the next problem was where to use them. Directory brute forcing with gobuster revealed an admin login endpoint:

Text
redacted.com/admin/login

The recovered credentials were entered there and the login succeeded as administrator.

Step 3: Report

A detailed report covering the findings was submitted to the site's security team. Three days later the team offered a reward of 650€.

Root cause

The product ID from the query string produced an SQL syntax error when a single quote was appended, and sqlmap could dump the databases. The search feature likewise reflected user input into the page without encoding it, allowing script injection. The dumped administrator password was Base64-encoded rather than hashed, so it could be decoded directly. Directory brute forcing found the admin login endpoint, and the recovered credentials logged in as administrator. The report does not describe any server-side defences such as a WAF or parameterised queries.

Impact

An attacker who can reach the product page could dump the databases, including the users table with administrator credentials. Because the admin password was only Base64-encoded, it could be decoded and used to log in to the admin panel, giving administrative control over the site. The reflected XSS in the search feature executed the injected payload when the researcher submitted the search. The report does not state how many accounts or records were exposed.

Fix

The measures that would address the findings are parameterised queries or prepared statements for the product ID, output encoding of reflected search input, and storing passwords as salted hashes rather than Base64. Restricting or hardening the admin login path would also reduce the value of leaked credentials.

Variants to test

  1. Numeric identifiers in URLs (productID, id, item, pid): append a single quote and look for a database error or a change in response length. A positive result is a syntax error or a boolean difference between and 1=1 and and 1=2.
  2. Reflected search terms: submit a term containing HTML special characters and check whether they come back encoded. A positive result is the payload appearing unencoded in the response and executing in the browser.
  3. Dumped credential columns: check whether passwords decode as Base64 or another reversible encoding. A positive result is a readable plaintext password after decoding.
  4. Admin panels: run directory brute forcing against the host and try recovered credentials at any login endpoint found. A positive result is a successful authenticated session with administrative privileges.
  5. Old dork-discovered programs: the same numeric-parameter and reflection tests apply, but expect slower responses and less reliable triage.

That's it for today folks. C you guys in another write up :). Peace

From the original on medium.com

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

What happened, in plain words

A security researcher found two serious weaknesses in an online shop that sells travel goods. The shop is called redacted.com in this write-up. The first weakness was in the search box: whatever you typed was put back into the page without being made safe, so a small piece of code could run in a visitor's browser. The second weakness was in the address of a product page: the number that tells the shop which product to show was dropped straight into a database question, so a carefully chosen character could make the database spill out its contents. Using a free tool called sqlmap, the researcher pulled out the shop's database, found a table of users, and recovered the administrator's username and password. The password was not properly protected, only scrambled in a way that is easy to undo. The researcher then guessed the address of the admin login page, signed in with those credentials, and reported everything. Three days later the shop's security team offered a reward of 650€.

From the original on medium.com

How the hunt started

The researcher did not find this shop on a big public bug bounty platform. Those platforms, such as HackerOne and Bugcrowd, can be crowded, so the researcher prefers private programs discovered through Google dorks. A Google dork is simply a search query written to find particular kinds of pages, here pages that mention a responsible disclosure program. The starting point was a curated list of such dorks in a GitHub repository. One dork was picked at random:

Text
responsible disclosure bounty r=h:eu

This is a Google search. The words responsible disclosure bounty look for pages about programs that promise to handle reported security problems responsibly. The researcher paged through many results, deliberately chose an old program, and picked a random domain from it. On that site, a normal user account was registered and the shop was explored as a logged-in customer.

The search box that ran code

Login and account features were tested first, without success. The search feature was the first opening. The researcher searched for testbro and noticed that the word came back in the page. That is called reflection: the site takes what you typed and places it into the page it sends back. If the site does not make that text safe first, you can type not just words but pieces of a web page, including small programs. This kind of weakness is called cross-site scripting, or XSS. The payload used was of the form:

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

Line by line: <img starts an image element. src=xss tells the browser to load an image from a place called xss, which does not exist. onerror=alert(1) is an instruction that the browser runs if the image fails to load. alert(1) makes a small pop-up box appear with the number 1. Because the image address is broken, the error instruction runs, and the pop-up appears. That pop-up is proof that the browser executed code supplied by the visitor. The researcher broke out of the surrounding context, injected this payload, and saw the pop-up.

The product number that talked to the database

While browsing products, the researcher noticed that every product link carried a number in the address, as in redacted.com/products?productID=21. The part after the question mark is the query string, a way of passing small pieces of information to the server. Here productID=21 tells the shop which product to display. A single quote was appended to the value:

Text
productID=21'

A single quote is a special character in the language used to ask databases questions, called SQL. It marks the beginning or end of a piece of text. If the shop drops the number straight into its database question without care, the extra quote breaks the question's grammar. The server returned an SQL syntax error. In other words, the shop was treating the visitor's input as part of its own instructions to the database.

From the original on medium.com

Using sqlmap to read the database

Rather than crafting payloads by hand, the researcher used sqlmap, a free tool that automates finding and exploiting SQL injection. The researcher still recommends trying payloads manually to understand the underlying behaviour. The first command listed the databases on the server:

Bash
 sqlmap -u http://redacted.com/products?productID=21 --dbs

Line by line: sqlmap runs the tool. -u sets the target URL, the address to test. http://redacted.com/products?productID=21 is that address, including the product number. --dbs asks sqlmap to list the names of all databases on the server. The tool returned the full list of databases. One database name stood out, and it was used to list its tables:

Bash
sqlmap -u http://redacted.com/products?productID=21 -D redacted --tables

Line by line: -u again gives the target URL. -D redacted selects the database named redacted. --tables asks sqlmap to list the tables inside that database. A database is like a filing cabinet, and tables are the drawers inside it. Among the results was a table named users. The researcher then dumped it:

Bash
sqlmap -u http://redacted.com/products?productID=21 -D redacted -T users --dump-all

Line by line: -u gives the target URL. -D redacted selects the database. -T users selects the table named users. --dump-all extracts all the contents of that table. The dump included the administrator's username and password.

The password was stored in an encoded form. Encoding is not encryption: it is a way of writing data in a different alphabet, and anyone can reverse it. The researcher pasted the password into CyberChef, a free website for transforming data, identified the encoding as Base64, and decoded it to recover the plaintext password. Base64 turns arbitrary data into letters, digits and a few symbols, and is often used to carry data through systems that only handle text. It offers no secrecy.

Finding the admin login

With credentials in hand, the next problem was where to use them. Directory brute forcing with gobuster revealed an admin login endpoint:

Text
redacted.com/admin/login

Directory brute forcing means trying a long list of common folder and file names against a website to see which ones exist. Gobuster is a tool that does this quickly. The address found is the login page for administrators. The recovered credentials were entered there and the login succeeded as administrator.

Reporting and reward

A detailed report covering the findings was submitted to the site's security team. Three days later the team offered a reward of 650€.

Why it worked

The product ID from the query string produced an SQL syntax error when a single quote was appended. A bound parameter is a placeholder that the database fills in separately, so the input can never change the structure of the question. Because the input was concatenated, a single quote produced a database syntax error and sqlmap could extract arbitrary data. The search feature likewise reflected user input into the page without encoding it, allowing script injection. The dumped administrator password was Base64-encoded rather than hashed. A salted hash is a one-way scramble: the site stores only the scrambled value and can check a password without ever being able to recover it. Base64 can be undone by anyone, so the dumped administrator password could be recovered directly. Directory brute forcing found the admin login endpoint, and the recovered credentials logged in as administrator. The report does not describe any server-side defences such as a WAF or parameterised queries.

What an attacker could do

An attacker who can reach the product page could dump the databases, including the users table with administrator credentials. Because the admin password was only Base64-encoded, it could be decoded and used to log in to the admin panel, giving administrative control over the site. The reflected XSS in the search feature executed the injected payload when the researcher submitted the search. The report does not state how many accounts or records were exposed.

How to fix it

The measures that would address the findings are parameterised queries or prepared statements for the product ID, output encoding of reflected search input, and storing passwords as salted hashes rather than Base64. Restricting or hardening the admin login path would also reduce the value of leaked credentials.

Other places to try the same ideas

  1. Numeric identifiers in URLs (productID, id, item, pid): append a single quote and look for a database error or a change in response length. A positive result is a syntax error or a boolean difference between and 1=1 and and 1=2.
  2. Reflected search terms: submit a term containing HTML special characters and check whether they come back encoded. A positive result is the payload appearing unencoded in the response and executing in the browser.
  3. Dumped credential columns: check whether passwords decode as Base64 or another reversible encoding. A positive result is a readable plaintext password after decoding.
  4. Admin panels: run directory brute forcing against the host and try recovered credentials at any login endpoint found. A positive result is a successful authenticated session with administrative privileges.
  5. Old dork-discovered programs: the same numeric-parameter and reflection tests apply, but expect slower responses and less reliable triage.

That's it for today folks. C you guys in another write up :). Peace

From the original on medium.com

Glossary

  • API: a way for one piece of software to ask another for data or actions, like a waiter taking your order to the kitchen.
  • Base64: a reversible way of writing data using letters, digits and a few symbols; it hides nothing.
  • Bound parameter: a placeholder in a database question that is filled in separately, so input cannot change the question's structure.
  • Bug bounty platform: a website where companies list programs and researchers submit reports, such as HackerOne or Bugcrowd.
  • Concatenation: joining pieces of text end to end to make one string.
  • Cookie: a small piece of data a website stores in your browser so it can recognise you on later requests.
  • CyberChef: a free website for transforming data, such as decoding Base64.
  • Database: an organised store of data, like a filing cabinet.
  • Directory brute forcing: trying a long list of common folder and file names against a website to find ones that exist.
  • Encoding: writing data in a different alphabet; reversible by anyone.
  • Endpoint: a specific address on a website that performs an action, such as a login page.
  • Google dork: a search query written to find particular kinds of pages.
  • Gobuster: a tool that tries many folder and file names quickly.
  • Hash: a one-way scramble of data; you can check a password against it but cannot turn it back into the password.
  • Parameter: a named value passed in a URL or request, such as productID=21.
  • Parameterised query: a database question built with placeholders so input is treated as data, not instructions.
  • Payload: the piece of input crafted to trigger a weakness.
  • Query string: the part of a URL after the question mark, carrying small pieces of information.
  • Reflection: when a site puts what you typed back into the page it sends.
  • Responsible disclosure: a program where a company promises to handle reported security problems properly.
  • Salted hash: a hash combined with a random value per user, so identical passwords do not produce identical stored values.
  • SQL: the language used to ask databases questions.
  • SQL injection: a weakness where visitor input becomes part of a database question, letting the visitor read or change data.
  • SQL syntax error: an error from the database saying the question is not grammatically valid.
  • sqlmap: a free tool that automates finding and exploiting SQL injection.
  • Token: a piece of data, often secret, that proves who you are or grants access.
  • WAF: a web application firewall, a filter that inspects requests and blocks suspicious ones.

Similar reports

View all

Same bug class and techniques, clearest first.

SQL injection

The lesson behind this report.

Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.