I Asked PostgreSQL a Question It Wasn’t Supposed to Answer
The category filter parameter was inserted directly into a SQL query without sanitisation, allowing UNION-based SQL injection. An attacker could extract usernames and passwords from a hidden users table and log in as administrator.
Labs 1–2 taught me to bend a query. Labs 3–4 taught me to make the database say its name.
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 user-supplied category value directly into a SQL query instead of using parameterised queries.
Impact
An attacker could read every username and password in plain text and log in as administrator, leading to a full breach.
What the attacker needed
Access to the category filter parameter; no authentication required
The fix
The application should use parameterised queries so user input is passed as data and never interpreted as SQL code.
How it was found
- Add a single quote to the category value and observe a database error, confirming injection.
- Use ORDER BY to determine the query returns two columns.
- Use UNION SELECT with text markers to confirm both columns accept text.
- Query information_schema.tables to list table names and identify the users table.
- Query information_schema.columns to find the username and password column names.
- Use UNION SELECT to dump usernames and passwords from the users 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 took whatever you typed into the category filter and pasted it directly into a database command. By adding extra database instructions, the author made the site reveal a hidden table of usernames and passwords. This is called SQL injection, and it happens when user input is treated as code instead of plain 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.