Skip to content
SQL injection Write-up Intermediate

XPATH Injection - Exploiting Error-based SQL Injection

A date parameter in an Android payment app's API was vulnerable to SQL injection, but standard UNION, boolean and blind techniques failed. The tester used MySQL/MariaDB XML functions to trigger error-based injection and extract the database version and name.

Krunal Savaliya Follow

Published on sklnhunt.github.io

Hey hackers!! Today, I’m explaining the exploitation of the error-based SQL injection via XPATH injection.

Krunal Savaliya, on sklnhunt.github.io

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 the date parameter directly into a SQL query without parameterisation, allowing injection.

Impact

An attacker could extract database information such as the version, database name and table names, and potentially further data.

What the attacker needed

Access to the merchant API; ability to intercept requests

How it was found

  1. Intercept the dashboard sales API request in Burp Suite.
  2. Add a single quote to the toDate parameter and observe a SQL ERROR response.
  3. Try UNION, boolean and blind payloads, which all fail.
  4. Inject an updatexml payload to trigger an XPATH syntax error containing the database version.
  5. Replace version() with database() to retrieve the current database name.
  6. Use information_schema.tables to list table names.

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, normal tricks did not work, so the tester used special database functions that produce error messages containing query results. Those error messages leaked information such as the database version and name.

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 Krunal Savaliya

View all

1 more disclosed report, 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.