Exploiting SQLi to Query Database Version on MySQL and Microsoft
The product category filter was vulnerable to SQL injection, allowing an attacker to manipulate the database query. By using a UNION-based injection, an attacker could retrieve the database version string.
osintteam.blog
Published on osintteam.blog
Today, we’ll be exploiting one of the oldest and most devastating vulnerabilities out there — SQL Injection. I’ll be taking you through my step-by-step methodology from reconnaissance, to testing, to exploitation.
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 application concatenated user input directly into an SQL query without sanitisation or parameterisation.
Impact
An attacker could retrieve the database version, which is a first step toward further exploitation such as extracting sensitive data.
What the attacker needed
Access to the vulnerable web application
The fix
User input should be sanitised or, better, parameterised queries should be used to prevent SQL injection.
How it was found
- Identify the category filter parameter in the URL.
- Append a single quote to the parameter and observe a 500 error.
- Use a UNION SELECT with two columns to confirm the number of columns and reflection.
- Replace one column 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.
SQL injection is a flaw where user input is inserted directly into a database command, letting an attacker change what the command does. Here, the category filter was not properly sanitised, so adding extra SQL code could make the database return its version number.
What is SQL injection?
Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.