Skip to content
SQL injection Write-up Intermediate

Exploiting second-order blind SQL injection

The name parameter on a quiz page was vulnerable to second-order blind SQL injection, with the injected payload executed when the score page retrieved the user's score. An attacker could use boolean-based queries to enumerate database schema and extract the admin password, then log in to the admin area.

niraj choubey Follow

Published on infosecwriteups.com

12 Days of Hacky Holidays CTF Dear hackers, The Grinch has gone hi-tech this year with the intentions of ruining the holidays and we need you to…www.hackerone.com

niraj choubey, on infosecwriteups.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 or escaping, and the query result was only observable indirectly via a count on another page.

Impact

An attacker could extract the admin password and gain access to the admin area, potentially leading to full control of the application.

What the attacker needed

Access to the quiz page; ability to submit a name; trigger the score page

How it was found

  1. Submit a name containing a SQL injection payload on the quiz page.
  2. Trigger the score page to execute the stored payload and observe the count of other players with the same name.
  3. Use boolean-based queries to enumerate the number of tables in the database.
  4. Enumerate table and column names, confirming the existence of an admin table with username and password columns.
  5. Determine the length of the admin password and extract it character by character using substring comparisons.
  6. Log in to the admin area with the recovered credentials to obtain the flag.

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.

The quiz page saved the player's name and later used it in a database query without proper sanitisation. By submitting a name containing SQL code, an attacker could ask the database true/false questions and slowly extract information such as the admin password. This is called blind SQL injection because the attacker does not see the query results directly, only indirect clues.

What is SQL injection?

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

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.