I Made the Database Confess Its Own Name
The website inserted user input directly into SQL queries, allowing an attacker to inject commands. The attacker used a UNION-based SQL injection to determine the database was Oracle and then extracted its full version string.
medium.com
Published on medium.com
In Lab 1, I pulled out products the shop was hiding from customers. In Lab 2, I walked into the admin account without a password.
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 concatenated user input directly into SQL queries without parameterisation, so input was treated as code.
What the attacker needed
None
The fix
Use parameterized queries so that user input is treated as data, not code.
How it was found
- Send a single quote in the category parameter and observe a 500 error, confirming SQL injection.
- Use ORDER BY with increasing column numbers until an error occurs to determine the number of columns.
- Use UNION SELECT with NULL values and the dual table to match the column count and confirm Oracle.
- Replace NULLs with string literals to see which columns are displayed on the page.
- Use UNION SELECT to query the v$version view and extract the BANNER column containing the version string.
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.
The website takes what you type and puts it straight into a database command without checking it. This means you can type your own database commands and the database will run them. The attacker used this to make the website show the database's version number, which helps plan further attacks.
What is SQL injection?
Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.