I Thought SQL Injection Was a Myth — Until I Found One
A login endpoint was vulnerable to boolean-based SQL injection in the username parameter, allowing an attacker to infer database information through true/false responses. The author used this to determine the database type and version length, then ran sqlmap to extract 26 database names.
medium.com
Published on medium.com
When I was learning and reading blogs about SQL injection, I always thought it’s definitely an urban legend and its nowhere in the wild, turns out it exists!
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.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the username parameter was concatenated directly into a SQL query without parameterisation or input validation.
Impact
An attacker could bypass authentication and extract database names and version information, though the text does not show extraction of user data.
What the attacker needed
Access to the login page; none
How it was found
- Open the login page and submit a username containing a single quote to trigger an error.
- Inspect the browser console to find the endpoint called on login.
- Open the endpoint directly and try a random username to see the 'user not found' response.
- Try SQL injection payloads ending with a comment to bypass the login check.
- Use true and false conditions to confirm boolean-based injection.
- Use substring and length functions with binary search to extract database name and version.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
SQL injection is when user input is inserted into a database query without proper handling, so an attacker can change the query's meaning. Here, typing a special username made the login check always succeed, and by asking true/false questions the author could slowly learn facts about the database. This is called boolean-based blind SQL injection because the attacker only sees yes/no answers.
What is SQL injection?
Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.