Skip to content
SQL injection Write-up Intermediate

My Pentest Log -12- (Out-Of-Band Sql Injection in MySQL)

A PHP web application's 'id' parameter in news.php was vulnerable to SQL injection, indicated by differing responses to single and double quotes. The author confirmed it using an out-of-band technique, causing the MySQL server to make DNS requests to an external collaborator.

hcibo.medium.com

Published on hcibo.medium.com

Today, I would like to inform you about the out-of-band sql injection process that I encountered on an application that I was doing web security tests.

Hamit CİBO, on hcibo.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 built SQL queries by directly concatenating user input from the 'id' parameter without proper sanitisation or parameterisation.

Impact

An attacker could inject arbitrary SQL queries, potentially leading to data disclosure or other database manipulation, though the text only confirms the injection itself.

What the attacker needed

Access to the news.php endpoint; MySQL database with outbound network access

How it was found

  1. Send a single quote in the 'id' parameter of news.php and observe a false response.
  2. Send double quotes in the same parameter and observe a true response, indicating possible injection.
  3. Since time-based testing was not possible, decide to use an out-of-band technique.
  4. Confirm the database is MySQL, which supports the LOAD_FILE function for external requests.
  5. Inject a LOAD_FILE payload pointing to a Burp Collaborator domain into the parameter.
  6. Observe DNS requests arriving at the collaborator, confirming the SQL injection.

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, a quote character changed the application's response, hinting at this flaw. The tester then used a trick that makes the database server contact an outside server, proving the injection worked even when normal error messages were hidden.

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.