Skip to content
SQL injection Write-up Intermediate

Utilizing Lockdown: Blind Sqli leads to Account Takeover & Data Extraction

An administrative login form was vulnerable to blind SQL injection in its user id and password parameters, allowing the researcher to log in as an administrator. A second parameter on an admin page was also injectable, letting the researcher dump the database containing user data.

Shakti Mohanty Follow

Published on medium.com

Bounty$1,400 View original

This is Shakti Ranjan Mohanty a security researcher from Odisha. This write-up is all about my last finding on which i was able to Takeover the Administrative account and was able to extract data.

shakti mohanty, 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

The target was a private-programme medical management application, referred to throughout as redacted.com. The programme's policy put only the apex domain in scope: every subdomain of the form *.redacted.com was explicitly out of scope. The organisation's stated priority was the protection of user information.

The feature that mattered was an administrative login page on a subdomain, m***.redacted.com, used by administrative doctors. Behind it sat an admin panel with functions such as adding blogs, adding and deleting members, and uploading and viewing receipts.

Setup

The researcher had 2 to 3 years in the field and worked as a security analyst, so hunting time was limited; the pandemic's work-from-home period gave him the time to push on this programme. No accounts were provisioned for the test: the whole point of the finding is that no valid credentials were needed.

Reconnaissance used two tools:

Exploitation used Burp Suite (Intruder and Spider) and Sqlmap. The report gives no versions for any of these.

Finding it

The researcher deliberately went outside the stated scope, reasoning that out-of-scope subdomains are the ones nobody tests. Amass and Assetfinder produced a large set of subdomains; he harvested 30 of them and checked each one. One of them, m***.redacted.com, presented a login page for an administrative doctor.

He put a single quote as the value of both the user id and the password parameter:

An SQL error came back. That was the first signal.

Exploitation

Step 1: confirm injection and try a classic bypass

He tried a standard authentication bypass on the login:

Text
1' or '1'='1

It failed. The response to a failed login request was 200 OK, which makes a failed attempt look superficially like a successful one unless the body is inspected.

Step 2: fuzz for a payload that changes the status code

He loaded Burp Intruder with blind SQL injection payloads against the login. One payload returned 302 Found, a different status from the 200 OK of a failed login. He cross-checked with the payload that had succeeded:

Text
')) or (('x'))=(('

by submitting it in both fields:

Text
Userid=')) or (('x'))=((' &Password=')) or (('x'))=(('

He was logged in to the administrative account. The admin functionality, including adding blogs, adding and deleting members, and uploading and viewing receipts, was now accessible.

Step 3: try to extract the database through the login form

The administrative subdomain was out of scope, and the programme's priority was user information, so the researcher expected the report to be closed as N/A unless he could show database access. He first tried to dump data manually through the userid and password parameters. That failed. He then ran Sqlmap against the same point. That also failed.

Step 4: find a new injection point inside the admin panel

With admin access in hand, he looked for hidden parameters in the panel. Burp Spider enumerated paths, and one of them was:

Text
m***.redacted.com/ImagingCenter/MailingList.php?personID=1&lang=en&navigation=1&namesOnly=1&view=board

Sqlmap against this endpoint returned the database. The vulnerable parameter was personID, and the database was MySQL. With that, he had data on all users, members, students and other records.

Step 5: file upload

He considered uploading a malicious file through the upload section and asked the organisation for permission. Permission was denied, so no upload was attempted.

Timeline

Event Time
Reported the bug 5/11/2020, 7:28:34 PM
Bug accepted 5/12/2020, 12:50:43 PM
Triaged and status changed from High to Critical 5/12/2020, 12:50:51 PM
Bounty 1400 €
Awarded Bounty From the original on medium.com

The bounty award as shown in the report.

Reply from the Organisation From the original on medium.com

The organisation's reply, reproduced in the write-up.

Root cause

The report does not show the underlying queries, but the behaviour is consistent with the login form concatenating the user id and password values into SQL, so a quote in either field broke out of the string literal and an always-true boolean expression in both fields satisfied the check. MailingList.php was also injectable through the personID parameter, though the report does not show how that query is built.

The failed-login response being 200 OK is what made the initial bypass attempt ambiguous; the 302 Found returned by one payload is what distinguished it from the failures.

Impact

An unauthenticated attacker could log in to the administrative doctor account on the subdomain and use the admin functions exposed there. From inside the panel, the personID parameter of MailingList.php allowed extraction of the MySQL database, covering users, members, students and other records. The researcher's own framing is that the data extraction is what gave the report impact, because the administrative subdomain itself was out of scope and the programme prioritised user information. The upload path was not tested, since permission was refused.

Fix

A general fix for this class of issue is parameterised queries (prepared statements) for the login check and for personID in MailingList.php, so that user input is never concatenated into SQL.

Variants to test

  1. Login forms on out-of-scope subdomains. Submit a single quote in each field and look for a database error. A positive result is an error page or a changed response body.
  2. Status-code differential on authentication. Send a batch of blind SQL injection payloads through Intruder and compare status codes. A positive result is a status code that differs from the one returned for failed logins.
  3. Boolean payloads in both fields at once. Try the same tautology in the username and the password, since the query may test both. A positive result is a session or a redirect to an authenticated page.
  4. Numeric parameters inside authenticated panels. Spider the panel and test parameters such as personID with Sqlmap. A positive result is a confirmed injection point and a retrievable schema.
  5. Manual extraction before tooling. If Sqlmap fails on the login, try the same parameters by hand and then move to other endpoints; the report shows the login point resisting both manual and automated dumping while a panel parameter gave way.

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 found a login page for doctors who manage a medical application. The page was on a part of the company's website that the bug bounty programme had said was off limits, but he tested it anyway. By typing a special piece of text into the username and password boxes, he got logged in as an administrator without knowing any real password. Once inside, he found another page that let him pull the whole database out, including information about users, members and students. He reported it, the company accepted it the next day, raised its severity from High to Critical, and paid him 1400 €.

This article walks through the same steps he took, but explains every idea from scratch. If you can use a browser, you can follow it.

Awarded Bounty From the original on medium.com

The screenshot shows the bounty award as it appeared in the report.

The target and the rules

The company ran a private programme. A bug bounty programme is an agreement where a company invites researchers to look for security problems in its systems and pays for good findings. "Private" means you can only take part if you are invited; the details are not public. The application itself was a medical management application, software that a clinic or hospital uses to keep track of patients, staff, appointments and similar records. Throughout the report the real name is replaced with redacted.com.

The programme had a policy, a written set of rules saying which parts of the company's systems you are allowed to test. The policy said only the main domain, redacted.com, was in scope (allowed to be tested). Every subdomain of the form *.redacted.com was out of scope (not allowed).

A subdomain is a name that sits in front of the main domain, separated by a dot. If the main site is example.com, then shop.example.com and mail.example.com are subdomains. The * is a wildcard meaning "any name here". So the rules said: test the front door, but not the side doors.

The company also said its priority was protecting user information, meaning the personal data of the people who use the application.

The feature at the centre of the story was an administrative login page on a subdomain, m***.redacted.com. A login page is the form where you type a username and a password. "Administrative" means it was meant for staff with special powers, in this case administrative doctors. Behind that login sat an admin panel: a set of web pages where an administrator can do things ordinary users cannot, such as adding blog posts, adding and deleting members, and uploading and viewing receipts.

Getting ready

The researcher had two to three years of experience in the field and worked professionally as a security analyst, someone whose job is to look at systems and find weaknesses. Because of his day job he had little time for bug hunting. During the pandemic, when companies moved to working from home, he suddenly had more free time and used it for bounty work.

No test accounts were created for this test. That matters: the whole finding is that no valid username or password was needed at all.

For the first stage, reconnaissance (recon), he used two tools. Recon means mapping out what a company owns on the internet before testing anything, the way a burglar might first walk around a building noting every door and window.

  • Amass is a tool that discovers subdomains and related internet names for a domain.
  • Assetfinder does a similar job, finding domains and subdomains connected to a target.

For the attack stage he used Burp Suite and Sqlmap. Burp Suite is a tool that sits between your browser and a website and lets you see and change every request you send. Two parts of it appear here: Intruder, which sends the same request many times with different values filled in automatically, and Spider, which crawls a website by following links and recording every page and parameter it finds. Sqlmap is a tool that automates attacks against databases behind web pages. The report gives no version numbers for any of these tools.

Finding the login page

The researcher deliberately went outside the stated scope. His reasoning was simple: out-of-scope subdomains are the ones nobody else tests, so they are more likely to still contain old mistakes.

Amass and Assetfinder produced a large list of subdomains. He took 30 of them and checked each one by hand. One of them, m***.redacted.com, showed a login page for an administrative doctor. That was the door he decided to try.

Testing the login form

Step 1: a single quote

He typed a single quote character as the value of both the user id and the password field:

A single quote is the character '. In many databases, text values are wrapped in single quotes, so a query might look like WHERE username = 'alice'. If a website pastes whatever you typed straight into that query, and you type a quote yourself, the quote closes the text early and the rest of your input is treated as part of the database command rather than as text. That is the essence of SQL injection: making your input change the meaning of a database query instead of just being stored as a value.

An SQL error came back. That was the first signal: the page had tried to run his quote as part of a database command and the database complained. A normal login form should simply say "wrong username or password".

Step 2: the classic bypass attempt

He then tried a well-known trick for getting past a login without a password:

Text
1' or '1'='1

Read it in pieces. 1' closes the text value early. Then or adds a second condition. '1'='1' is a comparison that is always true, because the text "1" equals the text "1". If the database is asked "is the username this value or is 1 equal to 1?", the second half is always true, so the whole condition is true and the login check can pass.

It failed. The response to a failed login request was 200 OK. HTTP status codes are three-digit numbers a web server sends with every response. 200 means "here is the page you asked for", and it is what you normally get for a page that loads fine, including a login page that says "wrong password". So a failed login and a successful one could look identical at the status-code level, and he had to look at the actual page content to tell them apart.

Step 3: trying many payloads automatically

Instead of guessing one payload at a time, he loaded Burp Intruder with a list of blind SQL injection payloads. A payload here just means the piece of text you put into the input field. "Blind" means the page does not show you the database output or an error; you have to infer what happened from indirect signs, such as whether the page looks different or the status code changes.

One payload returned 302 Found. A 302 status code means "the thing you asked for is somewhere else, go there", and browsers follow it automatically. In practice, a 302 after a login usually means "you are logged in, here is the dashboard". That was different from the 200 OK of a failed login, so it stood out.

He cross-checked with the payload that had produced it:

Text
')) or (('x'))=(('

and submitted it in both fields:

Text
Userid=')) or (('x'))=((' &Password=')) or (('x'))=(('

Line by line: Userid= is the name of the username field and Password= is the name of the password field, joined with & the way form data is normally sent. The value in each is the same payload. Inside the payload, ')) closes whatever brackets and quotes the original query had opened. Then or adds a second condition. (('x'))=(('x')) compares the text "x" with the text "x", which is always true. So the query becomes "does the real check pass or is x equal to x?", and the answer is always yes.

He was logged in to the administrative account. The admin functions were now available to him: adding blogs, adding and deleting members, uploading and viewing receipts.

Step 4: trying to pull data through the login form

The administrative subdomain was out of scope, and the programme's priority was user information. He expected the report to be closed as N/A (not applicable, meaning "this does not count") unless he could show that actual data was reachable. So he tried to dump the database, meaning to extract its contents, using the same userid and password fields. That failed. He then ran Sqlmap against the same point. That also failed.

Step 5: finding a new injection point inside the panel

Since he was already logged in as an administrator, he looked for hidden parameters in the panel. A parameter is a named value in a web address or form, the part after a ? in a URL. For example, in page.php?id=5, the parameter is id and its value is 5. "Hidden" here means parameters that are not visible on the page itself but are used by the site behind the scenes.

Burp Spider crawled the panel and recorded the paths it found. One of them was:

Text
m***.redacted.com/ImagingCenter/MailingList.php?personID=1&lang=en&navigation=1&namesOnly=1&view=board

Reading it left to right: m***.redacted.com is the subdomain, /ImagingCenter/MailingList.php is the page on the server, and everything after ? is a set of parameters separated by &. personID=1 means the person identifier is 1, lang=en means language English, navigation=1, namesOnly=1 and view=board are further settings the page understands. The .php ending tells you the page is written in the PHP programming language.

He ran Sqlmap against this address and it returned the database. The vulnerable parameter was personID, and the database was MySQL, a very common database system. With that, he had data on all users, members, students and other records.

Step 6: the file upload he did not try

He considered uploading a malicious file through the upload section. A malicious file is a file crafted to do something harmful when the server runs or stores it, for example a script that gives the attacker control. Because this was a step beyond simply reading data, he asked the organisation for permission first. Permission was denied, so he did not attempt it.

Timeline

Event Time
Reported the bug 5/11/2020, 7:28:34 PM
Bug accepted 5/12/2020, 12:50:43 PM
Triaged and status changed from High to Critical 5/12/2020, 12:50:51 PM
Bounty 1400 €

Triaged means the company's security team reviewed the report and confirmed it was real. The severity rating went from High to Critical, the highest level.

Reply from the Organisation From the original on medium.com

The organisation's reply, as reproduced in the write-up.

Why it worked

The report does not show the query, but the behaviour is consistent with the login form gluing the user id and password values directly into the query text. In everyday terms, imagine a form letter that says "Dear ____, your account is..." and someone writes a whole new paragraph into the blank, changing the letter's meaning. Because the values were pasted in as-is, a quote in either field broke out of the text, and an always-true comparison in both fields satisfied the check. MailingList.php was also injectable through the personID parameter, though the report does not show how that query is built.

The failed-login response being 200 OK is what made the first bypass attempt ambiguous: the status code alone did not show the attempt had failed. The 302 Found on a successful login is what made the working payload stand out.

What an attacker could have done

Someone with no account at all could log in to the administrative doctor account on the subdomain and use the admin functions there. From inside the panel, the personID parameter of MailingList.php allowed extraction of the MySQL database, covering users, members, students and other records. The researcher's own framing is that the data extraction is what gave the report impact, because the administrative subdomain itself was out of scope and the programme prioritised user information. The upload path was not tested, since permission was refused.

How to fix it

A general fix for this class of issue is parameterised queries (also called prepared statements) for the login check and for personID in MailingList.php, so that user input is never glued into SQL.

Variants to test

If you want to practise the same ideas on systems you are allowed to test:

  1. Login forms on out-of-scope subdomains. Submit a single quote in each field and look for a database error. A positive result is an error page or a changed response body.
  2. Status-code differential on authentication. Send a batch of blind SQL injection payloads through Intruder and compare status codes. A positive result is a status code that differs from the one returned for failed logins.
  3. Boolean payloads in both fields at once. Try the same always-true comparison in the username and the password, since the query may test both. A positive result is a session or a redirect to an authenticated page.
  4. Numeric parameters inside authenticated panels. Spider the panel and test parameters such as personID with Sqlmap. A positive result is a confirmed injection point and a retrievable schema (the database's structure).
  5. Manual extraction before tooling. If Sqlmap fails on the login, try the same parameters by hand and then move to other endpoints; the report shows the login point resisting both manual and automated dumping while a panel parameter gave way.

Glossary

  • Admin panel: a set of web pages where an administrator can manage a site, such as adding content or managing members.
  • Administrative login page: a login form intended for staff with special powers, not ordinary users.
  • Amass: a tool that discovers subdomains and related internet names for a domain.
  • Assetfinder: a tool that finds domains and subdomains connected to a target.
  • Blind SQL injection: SQL injection where the page does not show database output or errors, so you infer what happened from indirect signs such as a changed status code or page.
  • Bounty: the money a company pays for a valid security finding.
  • Burp Suite: a tool that sits between your browser and a website so you can see and change every request.
  • Critical: the highest severity rating for a security issue.
  • Database: organised storage for a website's data, such as user records.
  • Dump: to extract the contents of a database.
  • Hidden parameter: a parameter used by a site behind the scenes that is not visible on the page itself.
  • HTTP status code: a three-digit number a web server sends with every response, such as 200 for success or 302 for a redirect.
  • In scope: allowed to be tested under a programme's rules.
  • Intruder: the part of Burp Suite that sends the same request many times with different values filled in automatically.
  • Malicious file: a file crafted to do something harmful when a server runs or stores it.
  • Medical management application: software a clinic or hospital uses to keep track of patients, staff, appointments and similar records.
  • MySQL: a common database system.
  • N/A: not applicable, meaning a report does not count as a valid finding.
  • Out of scope: not allowed to be tested under a programme's rules.
  • Parameter: a named value in a web address or form, such as id=5 in page.php?id=5.
  • Parameterised query: a way of sending values to a database separately from the command, so they can never change its meaning.
  • Payload: the piece of text you put into an input field during a test.
  • Policy: a written set of rules saying which parts of a company's systems you may test.
  • Prepared statement: another name for a parameterised query.
  • Private programme: a bug bounty programme you can only join if invited.
  • Reconnaissance (recon): mapping out what a company owns on the internet before testing anything.
  • Security analyst: someone whose job is to examine systems and find weaknesses.
  • Severity: how serious a security issue is judged to be, often on a scale such as High or Critical.
  • Spider: the part of Burp Suite that crawls a website by following links and recording every page and parameter it finds.
  • SQL error: an error message from a database, often a sign that your input reached the database as a command.
  • SQL injection: making your input change the meaning of a database query instead of just being stored as a value.
  • Sqlmap: a tool that automates attacks against databases behind web pages.
  • Subdomain: a name that sits in front of a main domain, separated by a dot, such as shop.example.com.
  • Triaged: reviewed and confirmed as real by the company's security team.
  • User information: the personal data of the people who use an application.
  • WAF (web application firewall): a filter that inspects incoming requests and blocks suspicious ones.

More by Shakti Mohanty

View all

3 more disclosed reports, best first.

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.