M4 — Insufficient Input/Output Validation
A deliberately vulnerable Android training app builds a database query by pasting the user-supplied username straight into the SQL statement. An attacker can inject SQL through that field to append their own query and pull back data the app did not intend to show, including a hidden flag.
medium.com
Published on medium.com
A falta de validação e sanitização adequada de dados externos, como entradas de usuários ou dados de rede, em aplicativos móveis pode causar graves vulnerabilidades de segurança. Sem essas proteções, o aplicativo fica exposto a ataques como SQL Injection, Command Injection e XSS (Cross-Site Scripting).
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 username is concatenated into the SQL query string without parameterisation or sanitisation, so typed text becomes part of the command.
Impact
An attacker could read arbitrary rows from the app's database, including data the screen was not meant to reveal.
What the attacker needed
The Beetlebug training app installed; local access to the app
The fix
The query should be fixed by using parameterised statements so user input is always treated as data, not code.
How it was found
- Open the insecure database option in the Beetlebug app and search for the admin user to see normal output.
- Search for a non-existent user to confirm the not-found message.
- Inspect the app source with JADX to see how the query is built.
- Enter a username containing a UNION-based injection to append a second query.
- Read the returned data, which includes the flag.
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 app takes whatever you type in the username box and drops it directly into a database command. Because it does not treat the text as plain data, you can type extra database instructions that the app then runs. This lets you read other rows in the database that the normal screen would never show.
What is SQL injection?
Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.