How I Found a Critical SQL Injection in an “Abandoned” Website: Exploiting a Rare Chain of…
A legacy subdomain's 404 error handler concatenated the user-controlled request URI into an INSERT statement, causing an error-based SQL injection. An attacker could extract database contents, including admin credentials, through verbose MySQL error messages.
infosecwriteups.com
Published on infosecwriteups.com
This type of case is literally 1% of SQLi, it is extremely rare to see this type of failure with multiple factors combined Error-Based SQL Injection (XPATH Injection) + INSERT-Based, so this is the case study.
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
The application concatenated the raw REQUEST_URI into an INSERT statement without parameterisation, and verbose error reporting exposed the resulting database errors.
Impact
An attacker could read the entire database, including admin credentials and client data, and because the database user was root, potentially access other databases on the shared server.
What the attacker needed
Authorised access to the target; legacy subdomain reachable; verbose error messages enabled
The fix
The application should use prepared statements with bound parameters instead of concatenating user input into SQL, and should disable error display in production.
How it was found
- Map subdomains and find a forgotten legacy development subdomain.
- Notice PHP warnings and a public phpinfo page leaking internal paths and configuration.
- Send a malformed URL containing a comma and observe a MySQL syntax error revealing an INSERT statement.
- Craft a payload that closes the current row, injects EXTRACTVALUE, and starts a new valid row.
- Use EXTRACTVALUE with SUBSTRING to extract data in chunks from the admin table.
- Automate row enumeration with Burp Intruder using LIMIT offsets.
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.
When a website logs a bad URL into its database, it should treat that URL as data, not as part of the database command. Here the site pasted the URL straight into the command, so a crafted URL could make the database run extra instructions and reveal secrets in error messages.
What is SQL injection?
Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.