Skip to content
SQL injection Write-up Intermediate

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.

Ahmed Samy Follow

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

  1. Test the course page parameter with a single quote and observe no error.
  2. Use ORDER BY to determine the number of columns, finding 19.
  3. Attempt a UNION SELECT query, which is blocked by the firewall.
  4. Discover a subdomain that is not protected by the same firewall.
  5. Run the UNION SELECT query on the subdomain and successfully retrieve data.
  6. 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.

More by Ahmed Samy

View all

1 more disclosed report, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

SQL injection

The lesson behind this report.

Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.