Mobile Application Bounty Practice: SQL Injection Principles, Vulnerability Discovery and…
An Android app's list query interface passed a user-supplied sort field into SQL by string concatenation, so the sort parameter was injectable. Because no data or errors were returned, the author used a random-ordering trick to turn the sort order into a true/false signal and brute-forced the database name character by character.
Published on medium.com
This article primarily shares an experience in exploiting SQL injection vulnerabilities in mobile app applications, focusing on the current environment and the various ways SQL injection can still be exploited along with its principles. It then goes on to share my approach to SQL injection exploitation and some…
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 sort field was inserted into the SQL statement by string concatenation because prepared-statement placeholders cannot be used for column names or keywords.
Impact
An attacker could extract database contents such as the database name through blind injection, though a WAF blocked the original payload until it was adjusted.
What the attacker needed
Access to the app's source code; a request to a list endpoint with a sort parameter; a WAF that filters commas
The fix
The sort field should be validated against a whitelist of allowed column names, since parameterised queries cannot cover identifiers.
How it was found
- Search the app's source for query interfaces that accept sorting parameters such as sortBy.
- Send a single quote in the sort parameter and observe a server error, showing the input reaches the query.
- Send a random-ordering function as the sort value and confirm the returned order changes between requests.
- Compare results for a true condition and a false condition to confirm a boolean blind channel.
- Replace commas with spaces to get past the WAF's comma filtering.
- Brute-force the database name one character at a time using a comparison on each character's ASCII value.
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.
A database query is built from parts of a web request. If the app glues the user's text straight into the query instead of treating it as plain data, the user can slip in extra database instructions. Here the sort option was glued in, and even though the page showed no data, the author could tell 'yes' from 'no' by watching how the list was ordered.
What is SQL injection?
Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.