Everything Is Input: SQL Injection Through Parameter Names
A SQL injection existed in the parameter names of a PHP recipe filtering endpoint, allowing an attacker to execute arbitrary SQL queries. The author confirmed it with time-based blind injection and wrote a custom extractor to dump database information.
How a 500 error, a hunch, and a lot of manual testing led me to a SQL injection I had never seen before and why I had to write my own script to prove it.
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 application iterated over the keys of the GET parameters and concatenated them directly into SQL queries without parameterization.
What the attacker needed
A valid PHP session cookie; the `subtype[]=snack` parameter present; ability to send crafted HTTP requests
The fix
The application should parameterize all SQL queries and never build SQL from user-controlled parameter names.
How it was found
- Send a request to the recipe endpoint with a normal `subtype[]=snack` parameter and observe the response.
- Replace the entire query string with a time-based blind SQL injection payload and measure the response time.
- Confirm the delay scales with the sleep value (e.g., sleep(6) gives ~12.6 seconds).
- Add the payload as a second parameter key alongside `subtype[]=snack` to trigger the vulnerable code path.
- Use a custom script that sends bitwise AND queries to extract data character by character.
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.
SQL injection is when user input is inserted into a database query without proper handling, letting an attacker change the query's meaning. Here, the vulnerable part was not the value of a parameter but its name, so the attacker could put SQL code into the parameter name itself. This let them make the database wait (a time-based test) and then extract data one bit at a time.
What is SQL injection?
Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.