Skip to content
SQL injection Write-up Intermediate

How I made $2000 with URL REDIRECTION?

The author found SQL injection parameters on a subdomain, but direct payloads were filtered. They then used an open redirect on the main domain to reach the same subdomain, bypassing the filter, and successfully exploited the SQL injection.

Simran Singh Follow

Published on medium.com

Bounty$2,000 View original

Simran Singh

Simran Singh, 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. 5 min read.

Context

This is a first bug bounty write-up by Simran Singh, published on 12 August 2020, describing a SQL injection found in a private program. The program is not named, and the author says this is because naming it could go against the program's rules and policies. Throughout the article the target is referred to as example.com, with the vulnerable host referred to as sub.example.com.

The feature involved is a newsletter subscription endpoint on the main domain that accepts a redirect destination in a query parameter, and a blog page on a subdomain that takes a page identifier in a query parameter. The author's central observation is that the redirect destination pointed at the same subdomain on which the SQL injection had been found.

Setup

The author does not describe any accounts, roles or specific tool versions. The tools mentioned are:

  • nmap, for port scanning
  • subdomain enumeration and directory listing, described only generically
  • Arjun, for parameter discovery
  • Burp Suite, for inspecting responses to SQL injection payloads

The only precondition stated is that the program was private and that its policy listed URL redirection as out of scope.

Finding it

The author began with routine reconnaissance: nmap port scanning, subdomain enumeration and directory listing. Some subdomains were found, but nothing described as interesting. At that point the author decided to change approach and used Arjun to discover parameters.

This produced some SQL injection vulnerable parameters on a subdomain. The full URI string is given as:

Text
https://sub.example.com/@someone’s_name/blog?pageid=143

SQL injection attempts were then made against this endpoint and the responses inspected in Burp Suite, but every payload was filtered. The author stopped for the day.

The next day, while reviewing the program policy again, the author noticed that URL redirection was listed as out of scope. Rather than dropping the topic, the author decided to look for a redirect URL parameter anyway. A subscription endpoint on the main domain was found that takes a destination in a parameter:

Text
https://www.example.com/subscribe?r=https://sub.example.com/subscribe_to_newsletter/

The key detail is that the destination subdomain in this redirect URL is the same subdomain on which the SQL injection had been tested. The author notes that the destination subdomain is the same one on which the SQL injection had been tested, and then repeated the whole set of SQL injection tests through the redirect.

Exploitation

Step 1: Discover parameters on the subdomain

Arjun was used to enumerate parameters on the subdomain, which surfaced parameters that appeared vulnerable to SQL injection. The blog endpoint takes a pageid parameter:

Text
https://sub.example.com/@someone’s_name/blog?pageid=143

Step 2: Attempt SQL injection directly

SQL injection payloads were sent to the pageid parameter and the responses examined in Burp Suite. All payloads were filtered, so the direct route did not work. The report does not give the individual payloads used at this stage.

Step 3: Find the redirect parameter

Reviewing the policy led the author to look for a redirect URL parameter. One was found on the main domain's subscription endpoint:

Text
https://www.example.com/subscribe?r=https://sub.example.com/subscribe_to_newsletter/

The r parameter carries an absolute URL, and the destination is the same subdomain that hosts the vulnerable blog endpoint.

Step 4: Repeat the SQL injection tests through the redirect

The author then ran the whole set of SQL injection tests again, this time through the URL redirection, starting with a database check and then moving on to tables and columns. The report does not include the payloads used in this phase or the responses returned. The author describes the outcome only as "BANG BANG!", meaning the tests succeeded.

Step 5: Report and payout

A proof of concept video and screenshots were produced, and the issue was reported to the program on 2 August 2020. On 11 August 2020 the author found an unread email in the inbox.

From the original on medium.com

The screenshot shows the inbox email that followed the report. The author's conclusion is that some people do not realise that a domain name is also known as a root domain.

Root cause

The report does not explain how the redirect was validated; the author only remarks that some people do not know a domain name is also known as a root domain. The author phrases this as some people not knowing that a domain name is also known as a root domain.

Why the direct SQL injection was filtered but the redirected path was not is not explained in the report. The author only states that the direct payloads were filtered and that the tests succeeded once run through the redirect.

Impact

What it does establish is that SQL injection was achievable on the subdomain's pageid parameter, and that the redirect on the main domain provided a route to that subdomain. The bounty was 2000 USD. The author does not state which party was affected beyond the private program, and the program name is withheld.

Fix

Separately, the SQL injection on pageid needs parameterised queries or equivalent server-side handling.

Variants to test

  1. Look for redirect parameters on the main domain that accept absolute URLs, such as r=, redirect=, next= or url=, and check whether a subdomain of the root domain is accepted. A positive result is a redirect that lands on a host you control or on a subdomain you are authorised to test.
  2. When a subdomain has parameters that look injectable but are filtered on direct requests, retry the same payloads through a redirect on the parent domain. A positive result is a response that differs from the filtered one, for example a database error or a change in page content.
  3. Use parameter discovery tooling such as Arjun on blog, profile and newsletter endpoints to find identifiers like pageid that are passed to the backend. A positive result is a parameter whose value changes the response in a way consistent with a query.
  4. Enumerate subdomains and check each one for both a redirect entry point on the parent domain and injectable parameters of its own. A positive result is a pair where the redirect reaches the host that carries the injectable parameter.
  5. Review the program policy for features listed as out of scope, such as open redirection, and check whether they can be chained into an in-scope issue. A positive result is a chain where the out-of-scope feature is only the transport and the impact lands on an in-scope asset.

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, Simran Singh, spent a day testing a company's website. The company ran a private bug bounty program, which is an arrangement where a company invites selected researchers to look for security holes in its systems and pays them for the ones they find. The researcher found a SQL injection in the website's database handling and was paid 2000 USD for it. The report was published on 12 August 2020.

The interesting part is not just the database problem. It is how the researcher got to it. The direct route to the broken page was blocked by a filter. The researcher then found a newsletter subscription link on the main domain that takes a destination address, and repeated the SQL injection tests through it.

The company is never named. The researcher says naming it could go against the program's rules and policies, so the article calls the main site example.com and the smaller part of it sub.example.com.

The two features involved

Two ordinary website features are involved, and it helps to understand what each one does before following the story.

  1. A blog page on a subdomain. A subdomain is a smaller address that sits under a main address, the way a named room sits inside a building. If the main address is example.com, then sub.example.com is a subdomain. The blog page shows a particular post, and it decides which post to show from a number in the address, here called pageid. That number is handed to the server, which looks the post up in its database.
  2. A newsletter subscription link on the main domain. This link has a parameter called r that holds a web address. After you subscribe, the site sends your browser on to whatever address is in r. This kind of feature is common: it lets a site return you to the page you came from. When a site accepts any address at all in such a parameter, the weakness is called an open redirect.

A parameter is simply a named value attached to the end of a web address, after a question mark. In ?pageid=143, the parameter name is pageid and its value is 143. You can see them in your browser's address bar whenever you search or fill in a form.

The tools mentioned

The researcher lists a handful of tools. You do not need to install them to follow the story, but here is what each one is for:

  • nmap, a program that probes a server to see which network doors (ports) are open. Think of knocking on every door of a building to see which ones answer.
  • Subdomain enumeration, the practice of hunting for the smaller addresses under a main address, because companies often forget about the less-used ones.
  • Directory listing, looking for folders on a web server that are visible when they should not be.
  • Arjun, a tool that guesses and tests parameter names on a web address to find ones the site responds to but does not advertise.
  • Burp Suite, a tool that sits between your browser and the website and lets you read and change every request and response. Think of it as a transparent mail slot where you can read and rewrite the letters going both ways.

The only precondition the researcher states is that the program was private and that its policy listed URL redirection as out of scope. A program policy is the rulebook: it says which parts of the company's systems you are allowed to test and which findings will not be paid for.

Finding it

The researcher started the way most people start: routine reconnaissance. That means mapping out what exists before attacking anything. nmap port scanning, subdomain enumeration and directory listing were all run. Some subdomains turned up, but nothing the researcher considered interesting.

At that point the researcher decided to change approach and used Arjun to discover parameters. This is a sensible move: instead of guessing which addresses matter, you ask the site which named values it reacts to. Arjun surfaced some parameters on a subdomain that looked vulnerable to SQL injection. The full address is given as:

Text
https://sub.example.com/@someone’s_name/blog?pageid=143

Reading this address piece by piece:

  • https:// is the secure web protocol, the padlock version of the web.
  • sub.example.com is the subdomain being tested.
  • /@someone’s_name/blog is the path, the location of the blog page on that server.
  • ?pageid=143 is the parameter: the page is being asked for post number 143.

SQL injection is the weakness being hunted here. A website's database is where it keeps its content, and the site talks to it in a language called SQL. When a site takes a value from the address bar and drops it straight into a database question without checking it, a visitor can type database instructions instead of a plain number. It is like a form that asks for your age and accepts "30, and also please show me everyone's salary". The database cannot tell the difference between the number and the extra instruction, so it obeys both.

SQL injection attempts were then made against this endpoint and the responses inspected in Burp Suite. Every payload was filtered. A payload is the crafted value you send in the hope of triggering the weakness; filtered means the site recognised the attempt and refused or cleaned it. The researcher stopped for the day.

The next day, while reviewing the program policy again, the researcher noticed that URL redirection was listed as out of scope. Rather than dropping the topic, the researcher decided to look for a redirect URL parameter anyway. This is a deliberate change of mindset: an out-of-scope feature is not necessarily useless, because it can sometimes be used as transport to reach something that is in scope.

A subscription endpoint on the main domain was found that takes a destination in a parameter:

Text
https://www.example.com/subscribe?r=https://sub.example.com/subscribe_to_newsletter/

Line by line:

  • https://www.example.com/subscribe is the newsletter subscription page on the main domain.
  • ?r= is the parameter that carries the destination.
  • https://sub.example.com/subscribe_to_newsletter/ is the destination, a page on the subdomain.

The key detail is that the destination subdomain in this redirect URL is the same subdomain on which the SQL injection had been tested. The researcher notes that the destination subdomain is the same one on which the SQL injection had been tested, and then repeated the whole set of SQL injection tests through the redirect.

Exploitation

Step 1: Discover parameters on the subdomain

Arjun was used to enumerate parameters on the subdomain, which surfaced parameters that appeared vulnerable to SQL injection. The blog endpoint takes a pageid parameter:

Text
https://sub.example.com/@someone’s_name/blog?pageid=143

This step exists because you cannot attack a value you do not know is read. Arjun's job is to find the names the site quietly accepts, so the researcher knows pageid is worth pushing on.

Step 2: Attempt SQL injection directly

SQL injection payloads were sent to the pageid parameter and the responses examined in Burp Suite. All payloads were filtered, so the direct route did not work. The report does not give the individual payloads used at this stage.

This is the straightforward attempt: put the malicious value where the site expects a number and see what comes back. The filter caught it every time, which is why the researcher needed another route.

Step 3: Find the redirect parameter

Reviewing the policy led the researcher to look for a redirect URL parameter. One was found on the main domain's subscription endpoint:

Text
https://www.example.com/subscribe?r=https://sub.example.com/subscribe_to_newsletter/

The r parameter carries an absolute URL, meaning a full address including https:// and the host name, and the destination is the same subdomain that hosts the vulnerable blog endpoint.

Step 4: Repeat the SQL injection tests through the redirect

The researcher then ran the whole set of SQL injection tests again, this time through the URL redirection, starting with a database check and then moving on to tables and columns. A database check means asking the database to confirm it is there and which kind it is; tables and columns are the internal shelves and fields where data is stored, so finding them is how you learn what can be read. The report does not include the payloads used in this phase or the responses returned. The researcher describes the outcome only as "BANG BANG!", meaning the tests succeeded.

Step 5: Report and payout

A proof of concept video and screenshots were produced, and the issue was reported to the program on 2 August 2020. A proof of concept is a small, repeatable demonstration that the problem is real, so the company can see it rather than take it on trust. On 11 August 2020 the researcher found an unread email in the inbox.

From the original on medium.com

The screenshot shows the inbox email that followed the report. The researcher's conclusion is that some people do not realise that a domain name is also known as a root domain.

Root cause

The report does not explain how the redirect was validated; the researcher only remarks that some people do not know a domain name is also known as a root domain. The researcher phrases this as some people not knowing that a domain name is also known as a root domain.

A simple comparison: a building's reception desk checks that a visitor is going to "the company's building" and lets them through, without checking which room. If one room in that building has an unlocked safe, the reception check has done the attacker a favour.

Why the direct SQL injection was filtered but the redirected path was not is not explained in the report. The researcher only states that the direct payloads were filtered and that the tests succeeded once run through the redirect.

Impact

What it does establish is that SQL injection was achievable on the subdomain's pageid parameter, and that the redirect on the main domain provided a route to that subdomain. The bounty was 2000 USD.

Fix

An allowlist is a short list of names that are permitted, and anything not on the list is refused. Separately, the SQL injection on pageid needs parameterised queries or equivalent server-side handling. A parameterised query is a way of building a database question where the value is kept separate from the instructions, so a value can never be mistaken for an instruction.

Variants to test

  1. Look for redirect parameters on the main domain that accept absolute URLs, such as r=, redirect=, next= or url=, and check whether a subdomain of the root domain is accepted. A positive result is a redirect that lands on a host you control or on a subdomain you are authorised to test.
  2. When a subdomain has parameters that look injectable but are filtered on direct requests, retry the same payloads through a redirect on the parent domain. A positive result is a response that differs from the filtered one, for example a database error or a change in page content.
  3. Use parameter discovery tooling such as Arjun on blog, profile and newsletter endpoints to find identifiers like pageid that are passed to the backend. A positive result is a parameter whose value changes the response in a way consistent with a query.
  4. Enumerate subdomains and check each one for both a redirect entry point on the parent domain and injectable parameters of its own. A positive result is a pair where the redirect reaches the host that carries the injectable parameter.
  5. Review the program policy for features listed as out of scope, such as open redirection, and check whether they can be chained into an in-scope issue. A positive result is a chain where the out-of-scope feature is only the transport and the impact lands on an in-scope asset.

Glossary

  • Bug bounty program: an arrangement where a company invites researchers to find security problems in its systems and pays for valid reports.
  • Private program: a bug bounty program open only to selected researchers, not to the public.
  • Program policy: the rulebook that says which systems may be tested and which findings are in or out of scope.
  • In scope / out of scope: whether a system or feature is covered by the program's rules and eligible for a reward.
  • Domain name: the main address of a site, such as example.com.
  • Root domain: another name for the main domain, as opposed to its subdomains.
  • Subdomain: a smaller address under a main domain, such as sub.example.com.
  • Registrable domain: the part of an address that a person or company actually registers, such as example.com.
  • Host: the machine or service a web address points to, identified by its name.
  • URL / URI: the full web address you type into a browser.
  • Path: the part of a web address that names the page or folder, such as /blog.
  • Parameter: a named value attached to a web address after a question mark, such as pageid=143.
  • Absolute URL: a full web address including the protocol and host, such as https://sub.example.com/.
  • Endpoint: a specific address on a server that accepts requests and does something with them.
  • Reconnaissance: the mapping-out phase of testing, where you learn what exists before attacking anything.
  • Port scanning: probing a server to see which network doors are open.
  • Subdomain enumeration: hunting for the smaller addresses under a main domain.
  • Directory listing: a web server showing the contents of a folder that should not be visible.
  • nmap: a tool for port scanning.
  • Arjun: a tool for discovering parameter names a site accepts.
  • Burp Suite: a tool that sits between browser and site so you can read and change requests and responses.
  • Payload: the crafted value you send to try to trigger a weakness.
  • Filtered: the site recognised an attempt and refused or cleaned it.
  • SQL: the language websites use to ask their database questions.
  • Database: where a site keeps its content and data.
  • Table and column: the shelves and fields inside a database where data is stored.
  • SQL injection: a weakness where a value from the address bar is treated as part of a database instruction, letting a visitor run their own instructions.
  • Parameterised query: a way of building a database question that keeps values separate from instructions, preventing SQL injection.
  • Open redirect: a weakness where a site sends visitors to any address supplied in a parameter, without checking it.
  • Redirect validation: the check a site performs on a redirect destination before sending the visitor there.
  • Allowlist: a short list of permitted names, with everything else refused.
  • Proof of concept (POC): a small, repeatable demonstration that a problem is real.
  • Bounty: the reward paid for a valid report.
  • Chain: using one weakness as a step to reach or trigger another.

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.