Bl Nd Exe Breaching Databases In Total Silence
The tracking cookie was concatenated into a SQL query without sanitisation, allowing SQL injection. An attacker could use conditional errors to confirm a user exists, then brute-force the administrator password character by character, and in a second case read usernames and passwords directly from verbose database error messages.
Published on infosecwriteups.com
The technique in our previous write up won’t work in this scenario, because injecting different boolean conditions makes no difference to the application’s responses.
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 cookie value is concatenated into a SQL statement without parameterisation, and database errors are surfaced to the user.
Impact
An attacker could confirm the administrator account exists, extract its password and log in as administrator; the second case leaks usernames and passwords directly through error messages.
What the attacker needed
Control of the TrackingId cookie; Oracle database (first case); ability to send many requests
The fix
The query should be parameterised so cookie values are never concatenated into SQL, and verbose database errors should not be returned to users.
How it was found
- Append a single quote to the TrackingId cookie and confirm an error appears.
- Append a comment sequence and confirm the error disappears.
- Use a subquery against a known table to confirm the input is treated as SQL.
- Use a CASE expression with a divide-by-zero to make an error occur only when a condition is true.
- Test password length and then each character position with Intruder, spotting HTTP 500 responses.
- In the second case, trigger a verbose error and use CAST to leak usernames and passwords.
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 cookie the site uses for analytics is pasted straight into a database command, so the attacker can add their own database instructions. By making the database fail only when a guess is correct, they can ask yes/no questions and slowly learn secret values like a password. In the second case the database's error text itself reveals the stolen data.
What is SQL injection?
Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.