A Straight 5-hour Escalation! Exploiting Boolean-Based SQL Injection.👽
The 'id' parameter in a project edit page was vulnerable to boolean-based blind SQL injection, allowing an attacker to extract the database name, table names, column names, and data by observing differences in HTTP status codes.
Published on medium.com
{{media:0}}
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.
Context
The target was a web application whose project editing feature lives at a page called projects-edit.html. The researcher describes the site as having a Project tab, and when a project is edited the application loads it by an id parameter in the URL. The report does not name the product or the company; the host is shown as redacted.com throughout, apart from one query where the real-looking host biztool.ro appears.
The feature normally takes the numeric project identifier from the query string and uses it to fetch the corresponding project record so the edit form can be populated. The identifier appears to be placed into a SQL query rather than bound as a parameter, though the report does not show the server-side code.
Setup
The tools used were:
- A browser and manual crawling of the site.
- Wappalyzer, used to fingerprint the backend as MySQL.
- Burp Suite Intruder (referred to as "the intruder tab"), used to iterate ASCII values as payloads.
- An ASCII table, used to translate the numeric values returned by the payloads back into characters.
The only precondition shown is that the edit page is reachable and accepts an id parameter.
Finding it
The researcher's recon approach was to study the application before probing it: how it works, how it is designed, which technology it uses and which features it implements. While crawling, a Project tab was found, and editing a project produced a URL of this shape:
A single quote was appended to the value:
The server answered with a 500 Internal Server Error. That response suggested the quote had broken the SQL statement. To confirm, the query was balanced so that it would parse again:
With the trailing comment the page returned a 200 response again, which is the classic signature of an injectable parameter. The researcher stopped recon at that point and focused on exploitation, noting that a P1-class flaw is worth pursuing quickly because there is a high chance of it being reported by someone else first.
Exploitation
Step 1: choosing the injection technique
A UNION-based attempt was made first, but the site redirected to its main page, so that route was abandoned. Blind boolean-based injection was tried next and worked. The behaviour observed throughout exploitation was consistent:
- A query that evaluates to FALSE returns a 301 status code.
- A query that evaluates to TRUE returns a 200 status code.
Wappalyzer identified the backend as MySQL, which determined the syntax used for the rest of the attack.
Step 2: confirming the boolean condition
A false condition:
A true condition:
The difference between the two responses confirmed that the result of an injected boolean expression controls the status code, which is all that is needed to extract data one bit at a time.
Step 3: length of the database name
With the boolean oracle established, the first piece of information taken was the length of the current database name.
This query asks whether the database name has length 1; a true answer gives 200 and a false answer gives 301. The true case was then tested with a different number:
The length of the database name was 12 characters.
Step 4: extracting the database name character by character
The characters were recovered one at a time by comparing the ASCII value of each position against candidate numbers. The URL was sent to Intruder, the position of the candidate value was marked, and the attack was run over the range 97 to 125. The payload that produced a 200 response identified the character; all others produced 301.
First character, false candidate:
First character, true candidate:
The 200 response arrived on the payload with value 121, which in the ASCII table is y, so the first letter of the database name is y.
Second character, false candidate:
Second character, true candidate:
The 200 response arrived on 111, which is o, so the second letter is o.
The same Intruder process was repeated for all twelve positions. The recovered values were:
| Position | ASCII | Character |
|---|---|---|
| 1 | 121 | y |
| 2 | 111 | o |
| 3 | 117 | u |
| 4 | 114 | r |
| 5 | 98 | b |
| 6 | 117 | u |
| 7 | 115 | s |
| 8 | 105 | i |
| 9 | 110 | n |
| 10 | 101 | e |
| 11 | 115 | s |
| 12 | 115 | s |
The database name was yourbusiness.
Step 5: length of the first table name
The next step was to enumerate tables from information_schema.tables. First the length of the first table name was tested.
The true condition was the one with length 7, so the first table name is seven characters long. The same pattern was used to confirm the length of the fourth table, this time scoping the schema with database() and using limit 4,1:
Step 6: extracting the first table name
The same ASCII technique was applied to the table name. The query was sent to Intruder with the candidate value marked as the payload position.
ASCII 97 is a, so the first letter of the table name is a.
ASCII 100 is d, so the second letter is d.
All seven characters were recovered the same way:
| Position | ASCII | Character |
|---|---|---|
| 1 | 97 | a |
| 2 | 100 | d |
| 3 | 100 | d |
| 4 | 114 | r |
| 5 | 101 | e |
| 6 | 115 | s |
| 7 | 115 | s |
The table name was address.
Step 7: length and name of the first column
The column length was tested with the following query, which is the one place in the write-up where the host appears as biztool.ro rather than redacted.com:
https://biztool.ro/projects/projects-edit.html?id=879 AND (length((select column_name from information_schema.COLUMNS where table_schema=database() limit 0,1))) = 5 -- -
The column name is 5 characters long. The first character was then extracted with the same Intruder method:
The full set of values recovered was:
| Position | ASCII | Character |
|---|---|---|
| 1 | 112 | p |
| 2 | 108 | l |
| 3 | 97 | a |
| 4 | 99 | c |
| 5 | 101 | e |
The column name was Place.
Step 8: extracting the data
The final target was the data itself. The researcher's assumption was that the value would start with a lowercase letter, since lowercase ASCII runs from 97 (a) to 122 (z), and the same Intruder method was used. Instead of a 200, the requests returned 500 responses, which indicated that the first character was not a lowercase letter.
The search was repeated with uppercase candidates, and this time it matched. The first character was S. The remaining characters were recovered in the same way:
| Position | ASCII | Character |
|---|---|---|
| 1 | 83 | S (uppercase) |
| 2 | 116 | t |
| 3 | 114 | r |
| 4 | 97 | a |
| 5 | 100 | d |
| 6 | 97 | a |
| 7 | 32 | space |
| 8 | 83 | S (uppercase) |
| 9 | 116 | t |
| 10 | 114 | r |
| 11 | 101 | e |
| 12 | 101 | e |
| 13 | 116 | t |
The extracted value was Strada Street. At that point the researcher had enough to write up the finding for the company. The whole exercise took about five hours of continuous work.
Root cause
The id parameter from the query string is placed into a SQL statement without parameterisation, so an appended quote changes the structure of the query and any boolean expression the attacker adds becomes part of it. The application's error handling also leaks the difference between a query that parses and one that does not: a broken statement produces a 500, while a syntactically valid statement with a false condition produces a 301 and a true condition produces a 200. The difference between a 200 and a 301 response is a reliable oracle, and it is what makes the blind extraction practical. Nothing in the write-up indicates that a WAF, input validation or least-privilege database account interfered with the attack.
Impact
An attacker who can reach the edit page can read data from the database through the boolean oracle, one character at a time. In this case the researcher recovered the database name, a table name, a column name and a row value, which is enough to demonstrate that any table reachable by the application's database user could be enumerated and dumped. The practical limit is speed: each character requires a full Intruder run, and the whole extraction took roughly five hours.
Fix
The change that addresses the root cause is to use parameterised queries or prepared statements for the id value so that user input can never alter query structure, and to stop returning distinguishable status codes for database errors so that a boolean oracle is not available. Restricting the database account to the minimum privileges the feature needs limits what a successful injection can reach.
Variants to test
- Numeric identifiers on other edit and detail pages. Append a single quote to any
id-style parameter and look for a 500, then balance the query with a trailing comment. A return to normal behaviour is a positive result. - Boolean oracle via status codes. Send
AND 1=1andAND 1=2in the same parameter and compare status codes or response bodies. A consistent difference between the two is a positive result. - Length and substring extraction. Use
length(database())andascii(substr((select database()),1,1))with an Intruder payload range. A single payload value producing a distinct response identifies the character. - Schema enumeration through
information_schema. Querytable_nameandcolumn_namewithlimitoffsets. Recovering readable identifiers confirms the injection reaches the schema. - Character class assumptions. When a lowercase-only payload range returns errors, repeat with uppercase and digits. A match outside the first range confirms the data contains mixed case, as happened here with
S. - UNION fallback. If boolean injection is blocked, try a UNION SELECT and watch for redirects or reflected columns, as the researcher did before switching techniques.
What happened, in plain words
A security researcher spent about five hours pulling information out of a website's database, one letter at a time, using nothing more than a web browser and a few helper tools. The website had a page for editing a "project". That page took a number from the address bar (the project's ID) and used it to look up the project in a database. The problem appears to be that the website pasted that number straight into the database instruction (a SQL query) without keeping it separate. By adding extra characters to the number in the address bar, the researcher could make the database answer yes-or-no questions, and by asking enough of those questions he could spell out the name of the database, the names of its tables and columns, and finally a piece of data stored inside it.
This kind of flaw is called SQL injection. To understand it, imagine a librarian who takes a written request slip and reads it out loud to fetch a book. If you write "the blue book" on the slip, all is well. But if you write "the blue book, and also tell me the combination of the safe", a careless librarian might read the whole thing as one instruction and hand over the safe combination too. The website here behaved like that careless librarian: the value from the address bar ended up affecting the database instruction.
A few words you will meet throughout, explained from zero:
- Database: an organised store of information, like a very large, very strict spreadsheet. A website keeps its users, projects, addresses and so on in databases.
- SQL: the language used to ask a database questions, such as "give me the project with ID 879".
- Query: one such question written in SQL.
- Parameter: a value that is slotted into a query, such as the number 879. When a site is careful, the parameter is kept separate from the query text so it can never be mistaken for an instruction. When a site is careless, the parameter is glued into the query text, and that is the bug.
- HTTP status code: a three-digit number a web server sends back with every page. 200 means "here is your page, all fine". 301 means "this has moved, look elsewhere". 500 means "something broke on the server". You can see these in a browser's developer tools or in a tool like Burp Suite.
- Blind SQL injection: a form of SQL injection where the attacker never sees the database's answer directly. Instead, the attacker asks yes-or-no questions and watches some side effect (here, the status code) to learn the answer.
- Boolean: a value that is either true or false. "1=1" is true; "1=2" is false.
- ASCII: a numbered table that gives every letter, digit and symbol a number. For example, lowercase "a" is 97, lowercase "y" is 121, uppercase "S" is 83, and a space is 32. This matters because the researcher could only ask the database for numbers, so he converted numbers back to letters using this table.
- Burp Suite Intruder: a feature of a security testing tool that takes a request and automatically repeats it many times, swapping one part for each value in a list. Here it was used to try every ASCII number from 97 to 125 in turn and see which one made the server answer 200.
- Wappalyzer: a browser extension that looks at a website and guesses which software it is built with. Here it identified the database software as MySQL.
- MySQL: a popular database program. Knowing it was MySQL told the researcher which SQL syntax to use.
- information_schema: a built-in set of tables inside MySQL that lists all the other tables and columns. It is like the index at the back of a book: it does not contain the story, but it tells you where everything is.
- UNION: a SQL keyword that joins the results of two queries together. Attackers sometimes use it to make the database return extra data alongside the normal answer.
- Comment: in SQL, a sequence like
-- -tells the database to ignore the rest of the line. Attackers use it to cut off the part of the query they do not want.

The researcher's own account begins with a short introduction and a note that the work took about five hours of continuous effort. He also mentions his YouTube and Instagram channels, which are not relevant to the technical story.
How the researcher found the page
Before touching anything, the researcher spent time simply looking at the site: what it does, how it is laid out, which technology it uses and which features it offers. This is called reconnaissance (recon for short), and it is the equivalent of walking around a building before trying the doors. While browsing, he found a tab called Project. When he edited a project, the address bar showed a URL like this:
Line by line:
https://is the secure version of the protocol browsers use to fetch pages.redacted.comis the site's name. In the published write-up the real name has been replaced withredacted.comto protect the company./projects/projects-edit.htmlis the path to the page that lets you edit a project.?id=879is the part after the question mark. Everything after?is called the query string, and it carries small pieces of information to the page. Hereidis the name of the value and879is the value itself: the ID of the project being edited.
The page takes that 879 and uses it to fetch the matching project from the database so the edit form can be filled in. That is the moment where the bug lives.
Testing whether the page is vulnerable
The researcher's first test was to add a single quote character (') to the end of the number:
Why a quote? In SQL, text values are wrapped in single quotes, like 'hello'. If the website is gluing the value into a query, adding a quote can break the query's structure, the same way an extra closing bracket breaks a sentence in a programming language. The server responded with a 500 Internal Server Error, meaning something on the server broke. That is a strong hint that the quote ended up inside a database query.
To confirm, the researcher balanced the query so it would parse again, by adding a comment at the end:
Line by line:
879is still the project ID.-- -is a SQL comment. Everything after it on the same line is ignored by the database. The trailing space and dash are there because some databases require a space after the two dashes for the comment to be recognised.
With the comment in place, the page returned to normal. That combination, a quote causing an error and a comment fixing it, is the classic signature of an injectable parameter. At this point the researcher stopped recon and focused on exploitation, noting that a serious flaw like this (he calls it a P1, meaning a high-priority issue) is worth pursuing quickly because someone else may report it first.
Choosing an exploitation technique
He first tried UNION-based injection, which tries to make the database return extra data alongside the normal answer. The site redirected him to its main page, so that route did not work. He then tried blind boolean-based injection, and that worked. Throughout the rest of the attack, the behaviour was consistent:
- A query that evaluates to false returns a 301 status code.
- A query that evaluates to true returns a 200 status code.
That difference is the whole trick. The researcher cannot see the database's answer, but he can see whether the server said 200 or 301, and that tells him whether his yes-or-no question was answered yes or no. Wappalyzer identified the backend as MySQL, which told him which SQL syntax to use.
Confirming the yes-or-no behaviour
He sent a deliberately false condition:
And a deliberately true one:
Line by line:
ANDis a SQL keyword meaning "and also". The database evaluates the whole expression, and the result is true only if both sides are true.1=1is always true;1=2is always false.- -is the comment again, cutting off whatever the original query had after the ID.
The two responses differed, which confirmed that the result of an injected true-or-false expression controls the status code. That is all the researcher needs to extract data one bit at a time.
Finding the length of the database name
With the yes-or-no channel established, the first piece of information he took was the length of the current database's name. Knowing the length tells him how many characters he will need to extract later.
Line by line:
database()is a MySQL function that returns the name of the current database.length(...)returns the number of characters in whatever is inside the brackets.=1asks whether that length is 1. If yes, the server answers 200; if no, 301.
He then tested a different number:
This time the answer was true, so the database name is 12 characters long.
Extracting the database name, one letter at a time
Now he needed the actual letters. He could not ask "what is the name?" directly, because the server only answers yes or no. Instead he asked, for each position, "is the ASCII number of this character equal to N?" and tried every N in turn. The URL was sent to Burp Suite Intruder, the candidate number was marked as the position to swap, and the attack was run over the range 97 to 125 (the ASCII range that covers lowercase letters). The payload that produced a 200 identified the character; all the others produced 301.
First character, a false candidate:
First character, the true candidate:
Line by line:
select database()fetches the database name.substr(..., 1, 1)takes one character from that name, starting at position 1 and taking 1 character. So it grabs the first letter.ascii(...)converts that letter into its ASCII number.=97asks whether that number is 97 (which is "a");=121asks whether it is 121 (which is "y").
The 200 response arrived on the payload with value 121, which in the ASCII table is y, so the first letter of the database name is y.
Second character, a false candidate:
Second character, the true candidate:
Here substr(..., 2, 1) takes the second character. The 200 arrived on 111, which is o, so the second letter is o.
He repeated the same Intruder process for all twelve positions. The recovered values were:
| Position | ASCII | Character |
|---|---|---|
| 1 | 121 | y |
| 2 | 111 | o |
| 3 | 117 | u |
| 4 | 114 | r |
| 5 | 98 | b |
| 6 | 117 | u |
| 7 | 115 | s |
| 8 | 105 | i |
| 9 | 110 | n |
| 10 | 101 | e |
| 11 | 115 | s |
| 12 | 115 | s |
The database name was yourbusiness.
Finding the length of the first table name
The next step was to list the tables inside that database. MySQL keeps a built-in catalogue called information_schema that lists every table and column, so the researcher queried that catalogue. First he tested the length of the first table name:
Line by line:
select table_name from information_schema.tablesasks the catalogue for table names.where table_schema="yourbusiness"restricts the answer to tables inside the database calledyourbusiness.limit 0,1means "skip 0 rows and return 1 row", so it returns just the first table name.length(...)counts its characters, and=1or=7asks whether that count matches.
The true condition was the one with length 7, so the first table name is seven characters long. He then used the same pattern to confirm the length of the fourth table, this time scoping the schema with database() and using limit 4,1:
Here limit 4,1 skips four rows and returns the fifth, which is the fifth table in the list (the numbering starts at zero). database() is used instead of the literal name, which is a common shortcut.
Extracting the first table name
The same ASCII technique was applied to the table name. The query was sent to Intruder with the candidate number marked as the payload position.
ASCII 97 is a, so the first letter of the table name is a.
ASCII 100 is d, so the second letter is d.
All seven characters were recovered the same way:
| Position | ASCII | Character |
|---|---|---|
| 1 | 97 | a |
| 2 | 100 | d |
| 3 | 100 | d |
| 4 | 114 | r |
| 5 | 101 | e |
| 6 | 115 | s |
| 7 | 115 | s |
The table name was address.
Finding the length and name of the first column
The column length was tested with the following query. This is the one place in the write-up where the host appears as biztool.ro rather than redacted.com:
https://biztool.ro/projects/projects-edit.html?id=879 AND (length((select column_name from information_schema.COLUMNS where table_schema=database() limit 0,1))) = 5 -- -
Line by line:
select column_name from information_schema.COLUMNSasks the catalogue for column names.where table_schema=database()restricts the answer to the current database.limit 0,1returns just the first column name.length(...) = 5asks whether that name is five characters long.
The answer was true, so the column name is 5 characters long. The first character was then extracted with the same Intruder method:
Here the query is scoped to the address table, so it asks for the first column of that table. ASCII 112 is p. The full set of values recovered was:
| Position | ASCII | Character |
|---|---|---|
| 1 | 112 | p |
| 2 | 108 | l |
| 3 | 97 | a |
| 4 | 99 | c |
| 5 | 101 | e |
The column name was Place.
Extracting the data itself
The final target was the data stored in that column. The researcher's assumption was that the value would start with a lowercase letter, since lowercase ASCII runs from 97 (a) to 122 (z), and he used the same Intruder method. Instead of a 200, the requests returned 500 responses, which indicated that the first character was not a lowercase letter. In other words, his guess about the character set was wrong, and the server was erroring out rather than answering yes or no.
He repeated the search with uppercase candidates, and this time it matched. The first character was S. The remaining characters were recovered in the same way:
| Position | ASCII | Character |
|---|---|---|
| 1 | 83 | S (uppercase) |
| 2 | 116 | t |
| 3 | 114 | r |
| 4 | 97 | a |
| 5 | 100 | d |
| 6 | 97 | a |
| 7 | 32 | space |
| 8 | 83 | S (uppercase) |
| 9 | 116 | t |
| 10 | 114 | r |
| 11 | 101 | e |
| 12 | 101 | e |
| 13 | 116 | t |
The extracted value was Strada Street. At that point the researcher had enough to write up the finding for the company. The whole exercise took about five hours of continuous work.
Why the site was vulnerable
The id value from the address bar is placed into a SQL statement without being kept separate from the query text. That means an appended quote changes the structure of the query, and any true-or-false expression the attacker adds becomes part of it. The application's error handling also leaks the difference between a query that parses and one that does not: a broken statement produces a 500, a syntactically valid statement with a false condition produces a 301, and a true condition produces a 200. The difference between a 200 and a 301 response is a reliable yes-or-no channel, and it is what makes the blind extraction practical. The report does not show the server-side code, so the exact way the value is glued in is likely rather than confirmed. Nothing in the write-up indicates that a web application firewall, input validation or a restricted database account interfered with the attack.
What the impact was
An attacker who can reach the edit page can read data from the database through the yes-or-no channel, one character at a time. In this case the researcher recovered the database name, a table name, a column name and a row value, which is enough to demonstrate that any table reachable by the application's database user could be listed and dumped. The report does not state what else the database contained, whether the account had write privileges, or how many records were exposed. The practical limit is speed: each character requires a full Intruder run, and the whole extraction took roughly five hours.
How to fix it
The change that addresses the root cause is to use parameterised queries (also called prepared statements) for the id value, so that user input can never alter the query's structure. A useful comparison: instead of reading the whole request slip aloud, the librarian is handed the book title on a separate card that is never read as an instruction. It also helps to stop returning distinguishable status codes for database errors, so that a yes-or-no channel is not available. Restricting the database account to the minimum privileges the feature needs limits what a successful injection can reach.
Variants to test
- Numeric identifiers on other edit and detail pages. Append a single quote to any
id-style parameter and look for a 500, then balance the query with a trailing comment. A return to normal behaviour is a positive result. - Yes-or-no channel via status codes. Send
AND 1=1andAND 1=2in the same parameter and compare status codes or response bodies. A consistent difference between the two is a positive result. - Length and substring extraction. Use
length(database())andascii(substr((select database()),1,1))with an Intruder payload range. A single payload value producing a distinct response identifies the character. - Schema enumeration through
information_schema. Querytable_nameandcolumn_namewithlimitoffsets. Recovering readable identifiers confirms the injection reaches the schema. - Character class assumptions. When a lowercase-only payload range returns errors, repeat with uppercase and digits. A match outside the first range confirms the data contains mixed case, as happened here with
S. - UNION fallback. If boolean injection is blocked, try a UNION SELECT and watch for redirects or reflected columns, as the researcher did before switching techniques.
Glossary
- ASCII: a numbered table that gives every letter, digit and symbol a number, so text can be represented as numbers.
- Blind SQL injection: SQL injection where the attacker cannot see the database's answer directly and instead infers it from side effects such as status codes or page differences.
- Burp Suite Intruder: a tool that repeats a web request many times, swapping one part for each value in a list, used here to try every ASCII number in turn.
- Column: a vertical slice of a database table, such as the "Place" column of an address table.
- Comment (SQL): a sequence such as
-- -that tells the database to ignore the rest of the line. - Database: an organised store of information kept by a website, like a very strict spreadsheet.
- Database name: the identifier of one database inside the database server; here
yourbusiness. - Exploitation: the step of actually using a vulnerability to prove what it allows, rather than just finding it.
- False / true condition: an expression that evaluates to no or yes, such as
1=2or1=1. - HTTP status code: a three-digit number a web server sends with every response; 200 means success, 301 means moved, 500 means server error.
- information_schema: a built-in MySQL catalogue that lists all tables and columns, like an index at the back of a book.
- Injection: inserting extra characters into a value so that they are treated as part of the surrounding instruction.
- Intruder: see Burp Suite Intruder.
- Length function: a SQL function that counts the characters in a value.
- MySQL: a popular database program.
- Parameter: a value slotted into a query, such as the project ID.
- Parameterised query / prepared statement: a way of sending a query where the parameter is kept separate from the query text, so it can never be read as an instruction.
- Payload: the value an attacker sends in a request, here the candidate ASCII number.
- P1: a high-priority severity label used in bug bounty programmes.
- Query: a question written in SQL and sent to a database.
- Query string: the part of a URL after the
?, carrying small pieces of information such asid=879. - Reconnaissance (recon): studying a target before probing it, to understand how it works and what features it has.
- Redirect: a server response telling the browser to go to a different page, often a 301.
- Schema: the structure of a database, meaning its tables and columns; also used as another word for a database.
- SQL: the language used to ask a database questions.
- SQL injection: a flaw where user input is treated as part of a SQL query, letting an attacker change what the database is asked to do.
- substr: a SQL function that takes a slice of a piece of text, given a starting position and a length.
- Table: a grid of rows and columns inside a database, such as an
addresstable. - Wappalyzer: a browser extension that guesses which software a website is built with.
- Web application firewall (WAF): a filter that sits in front of a website and tries to block malicious requests.