Skip to content
SQL injection Write-up Intermediate

X Forwarded for SQL injection

The X-Forwarded-For header was not properly validated and was inserted into a SQL query, allowing an attacker to perform blind time-based SQL injection. This could let an attacker extract the entire database, including table and column names and data.

Nikos Danopoulos Follow

Published on outpost24.com

Ghost Labs performs hundreds of success tests for its customers ranging from global enterprises to SMEs. Our team consists of highly skilled ethical hackers, covering a wide range of advanced testing services to help companies keep up with evolving threats and new technologies.

Nikos Danopoulos, on outpost24.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

Impact

An attacker could extract the entire database, including sensitive data, as the report states the whole database along with valuable column information was received.

What the attacker needed

Ability to send HTTP requests with custom headers; no authentication required

How it was found

  1. Send a request to the index page with a crafted X-Forwarded-For header containing a time-based SQL injection payload.
  2. Observe that the response is delayed, confirming the injection.
  3. Use manual enumeration with Burp Intruder to determine the database length.
  4. Extract the database name character by character using time delays.
  5. Enumerate table names from information_schema.tables using similar time-based queries.
  6. Use sqlmap with a simplified payload to extract column names and data from interesting tables.

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 web application took the value of a special header called X-Forwarded-For, which is meant to carry the client's IP address, and put it directly into a database query without checking it. By sending a crafted header, an attacker could make the database wait for a few seconds if a condition was true, which allowed them to ask yes/no questions and slowly extract information. This is called blind SQL injection because the attacker does not see the query results directly.

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.