The Database That Couldn’t Keep a Secret
A category filter parameter was concatenated directly into a SQL query, so a single quote caused a server error and a UNION SELECT could be appended. The attacker could make the database return its own version string, revealing the MySQL build and underlying operating system.
That’s the trick this part of the series drills into you: it isn’t ten attacks, it’s one attack wearing ten costumes. Learn the skeleton once.
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
The application built its SQL query by string concatenation, pasting user input directly into the query instead of using parameterised queries.
Impact
The database disclosed its exact version and operating system, which could help an attacker choose known exploits for that build; the text does not show further data extraction in this lab.
What the attacker needed
None
The fix
The application should use parameterised queries so user input is always treated as data, never as SQL code.
How it was found
- Send a single quote in the category parameter and observe a 500 error.
- Use ORDER BY with increasing column numbers until an error occurs to count the columns.
- Send a UNION SELECT with the same number of NULL columns to confirm it fits.
- Replace one NULL with @@version to retrieve the database 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.
A website often builds database questions by pasting what you type straight into a sentence. If you type special characters like a single quote, you can break that sentence and add your own question. Here the added question asked the database for its version number, which the page then displayed.
What is SQL injection?
Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.