I Bypassed WAF To Escalate SQLI ~Reward HOF
A SQL injection vulnerability was found in a government website's event page parameter, initially blocked by ModSecurity but bypassed using MySQL versioned comments. The attacker could extract database user, table names, and ultimately admin credentials, gaining admin panel access.
medium.com
Published on medium.com
This is how I bypassed MOD Security to Escalate SQLI which was found on the Indian GOVT website and as a reward I got an HOF as appreciation mail. Hi, Ajak Amico’s :) I hope Everybody is well, so without wasting any time let’s get started.
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 SQL queries without parameterisation, and the WAF's rules were bypassable with MySQL versioned comments.
Impact
The attacker could extract database user, table names, and admin credentials, leading to admin panel access.
What the attacker needed
None
How it was found
- Found a URL with an id parameter and added a single quote, causing a blank page.
- Balanced the query with a comment to restore the page.
- Used ORDER BY to determine the number of columns (9).
- Attempted UNION SELECT but was blocked by ModSecurity.
- Bypassed the firewall using versioned comments around UNION SELECT and a dot before the id value.
- Injected user() and group_concat(table_name) to extract database user and table names, then obtained admin credentials.
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 SQL injection is when a website puts user input directly into a database command, letting an attacker change the command. Here, the attacker added extra SQL code to a URL parameter to make the database reveal its contents. A firewall (ModSecurity) tried to block the attack, but the attacker used special comment syntax that the firewall did not recognise as dangerous.
What is SQL injection?
Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.