Skip to content
SQL injection Write-up Intermediate

From Recon to DNS Callbacks: Discovering an MSSQL Out-of-Band SQL

An SQL injection in the login email field of an admissions portal allowed an attacker to execute MSSQL commands that triggered outbound DNS requests, exfiltrating database name, user, and server name. The injection was confirmed via DNS callbacks to an external collaborator service.

nullsecurityx Follow

Published on nullsecurityx.medium.com

It’s been quite some time since I published my last article — probably a few months. Between work and university commitments, finding the time to sit down and write has been more challenging than I expected.

NullSecurityX, on nullsecurityx.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 an SQL query without parameterisation, allowing injection of MSSQL commands that execute stored procedures like xp_dirtree.

Impact

An attacker could exfiltrate sensitive database information such as the database name, current user, and server name via DNS callbacks; the text does not claim further impact like RCE.

What the attacker needed

Access to the login page; a test account; outbound DNS from database server; attacker-controlled DNS server

How it was found

  1. Enumerate directories with ffuf and find /admissions/auth login page.
  2. Create a test account and log in.
  3. Fuzz the email parameter with MSSQL-specific payloads in Burp Intruder, observing a different status code (577) for one payload.
  4. Craft a payload using xp_dirtree to trigger a DNS lookup to a collaborator domain.
  5. Split the payload into chunks concatenated with + to bypass a length restriction.
  6. Send payloads that concatenate DB_NAME(), SYSTEM_USER, and @@SERVERNAME into the DNS subdomain and observe callbacks.

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 login form's email field was not properly sanitised, so an attacker could insert database commands. The database server was tricked into making a DNS lookup to an attacker-controlled domain, which carried out stolen data like the database name. This is called out-of-band SQL injection because the data leaves through a separate channel (DNS) rather than the web page response.

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 nullsecurityx

View all

6 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.