Skip to content
SQL injection Write-up Beginner

The Database Handed Me Every Password — It Just Needed the Right Table Name

A shop's category filter pasted user input straight into a SQL query, so a UNION-based injection could read other tables. The author used Oracle's requirement for a FROM clause to fingerprint the database, then dumped a users table and logged in as the administrator.

guyani Follow

Published on medium.com

Labs 1–2 taught me to bend a query. Labs 3–4 made the database say its own name.

morgan_hack, on medium.com

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 category parameter into the SQL query as text rather than using a parameterised query.

Impact

An attacker could read the entire users table, including the administrator's password, and log in as that account.

What the attacker needed

None

The fix

The query should pass the category value as a bound parameter so it is treated as data, never as SQL.

How it was found

  1. Send a single quote in the category parameter and observe a server error.
  2. Increase an ORDER BY clause until it breaks to count the columns.
  3. Send a UNION SELECT without a FROM clause, see it fail, then add FROM dual to confirm Oracle.
  4. List table names from all_tables and spot the randomised users table.
  5. List column names from all_tab_columns for that table.
  6. Dump the username and password columns and log in as the administrator.

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 shop's filter box put whatever you typed directly into a database command instead of keeping it separate. By adding extra database instructions, the author made the page print out a hidden table of usernames and passwords. That is called SQL injection: user input being treated as code.

What is SQL injection?

Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.

More by guyani

View all

6 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

SQL injection

The lesson behind this report.

Input reaches a database query as code, letting an attacker read or change data the application never meant to expose.