How I Bypassed a Firewall, Leading to a Successful SQL Injection
A course page parameter was vulnerable to SQL injection, but a web application firewall blocked exploitation on the main domain. The attacker found an unprotected subdomain and used it to bypass the firewall and extract database information.
Published on medium.com
The original lives on medium.com
We do not hold its text, 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 firewall protection was not applied consistently across all subdomains.
Impact
An attacker could extract arbitrary data from the database, including database names, versions, and table names, potentially leading to further compromise.
What the attacker needed
None
The fix
The application should use parameterised queries to prevent SQL injection, and the firewall should be applied consistently across all subdomains.
How it was found
- Test the course page parameter with a single quote and observe no error.
- Use ORDER BY to determine the number of columns, finding 19.
- Attempt a UNION SELECT query, which is blocked by the firewall.
- Discover a subdomain that is not protected by the same firewall.
- Run the UNION SELECT query on the subdomain and successfully retrieve data.
- Identify the reflected column and extract database name, version, and table names.
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 when user input is inserted into a database query without proper handling, letting an attacker change the query's meaning. Here, the attacker could add extra SQL commands to a URL parameter to read data from the database. A firewall (WAF) tries to block such attacks, but the attacker found another address for the same site that lacked this protection.
What is SQL injection?
Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.