How I Turned a “Type 3 Chars” Search Box Into Full SQLi
The city search feature sent raw SQL queries from the client to the server, allowing an attacker to inject arbitrary SQL. The attacker enumerated the database and extracted user credentials.
medium.com
Published on medium.com
During a recent penetration test, I discovered an interesting SQL injection vulnerability in a web application’s city search functionality. What started as a simple search feature turned into a complete database enumeration.
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 accepted raw SQL queries from the client and executed them without validation.
Impact
An attacker could extract the entire database, including user credentials, and potentially use them for lateral movement if reused.
What the attacker needed
Access to the city search feature
How it was found
- Enter a 3-character string in the city search and observe the POST request to the web service.
- Modify the DBQry parameter to include a SQL query that returns the expected columns.
- Use system views to list tables and columns.
- Extract data from the useraccount table.
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 website let the user's browser send the actual database query to the server, instead of just a search term. This meant an attacker could change the query to ask for any data, like usernames and passwords.
What is SQL injection?
Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.