Skip to content
SQL injection Write-up Advanced

Conditional Error Blind SQLi — Real World vs. Portswigger L

A web application was vulnerable to SQL injection, but the endpoint only returned a blank 200 response or a 302 on error, and a WAF blocked common payloads. The author used a conditional error technique with random_bytes, ifnull and nullif to extract data character by character.

rodriguezjorgex Follow

Published on medium.com

Recently I stumbled upon a Bug Bounty target with a web application that was vulnerable to a SQL Injection. However, the endpoint would always respond with a 200 OK response, and the body would be empty.

Rodriguezjorgex, on medium.com

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 a SQL query without parameterisation, and the WAF only blocked some keywords.

Impact

An attacker could extract database information such as the current database user, though the WAF blocked some common payloads and the extraction was manual and slow.

What the attacker needed

A vulnerable endpoint; a WAF that blocks some keywords; manual character-by-character guessing

The fix

The application should use parameterised queries so user input is never treated as SQL code, and the WAF should not be relied on as the only defence.

How it was found

  1. Send a single quote and observe a 302 error response.
  2. Send two single quotes and observe a normal 200 response.
  3. Try a confirmation payload and see it blocked by the WAF.
  4. Use a conditional error payload with random_bytes, ifnull and nullif to test the first character of the current user.
  5. Observe a 302 when the guessed character is wrong and a 200 when it is correct.
  6. Repeat for each character to extract the username.

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. Here the site hid errors, so the attacker made the database fail only when a guessed character was wrong, using the difference between a normal response and an error response to learn data one letter at a time.

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 rodriguezjorgex

View all

4 more disclosed reports, 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.