Skip to content
SQL injection Write-up Beginner

First Blood: Finding My First SQL Injection in the Wild

An unauthenticated gallery page accepted an id parameter that was inserted into a SQL query without sanitisation, producing a database error. The author then used UNION-based injection to enumerate databases and tables and reported that sensitive healthcare-related data was exposed.

medium.com

Published on medium.com

When I started learning bug bounty hunting, I made one thing crystal clear for myself: I won’t jump randomly between topics.

Muhammad Saad Sabir, 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

Likely the id parameter was concatenated directly into a SQL query without parameterisation or input validation.

Impact

An unauthenticated attacker could read sensitive healthcare-related data, including admin information and schedules, from the database.

What the attacker needed

No authentication needed; target page reachable over the internet

How it was found

  1. Use a Google dork to find a URL with an id parameter on the target site.
  2. Send a single quote in the id parameter and observe a SQL syntax error.
  3. Test boolean logic with a tautology payload and see all gallery items returned.
  4. Use ORDER BY to determine the query has five columns.
  5. Use a UNION SELECT with a known string to find which column is reflected.
  6. Use information_schema queries to list databases and tables.

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.

A website often builds database queries by pasting user input into a command. If that input is not cleaned, a person can add extra database instructions. Here the id value in the address bar was pasted straight into a query, so the author could make the database return other tables.

What is SQL injection?

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

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.