Skip to content
SQL injection Write-up Beginner

SQL injection vulnerability in WHERE clause allowing retrieval of hidden data — PortSwigger

The product category filter was placed into a SQL query without proper handling, so a single quote broke the query and caused an error. By injecting a condition that is always true, an attacker could make the query return hidden, unreleased products.

RayofHope Follow

Published on infosecwriteups.com

Hi, my fellow hackers. This is Rayofhope.

RayofHope, on infosecwriteups.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 category value was concatenated directly into the SQL query inside single quotes, so user input could alter the query logic.

Impact

An attacker could retrieve hidden, unreleased products that the application did not intend to show.

What the attacker needed

Access to the shop's category filter

How it was found

  1. Find the category parameter in the request and change its value to a number to see if the page still responds normally.
  2. Intercept the request and send it to a repeater tool to inspect the response.
  3. Send a double quote and note the normal response, then send a single quote and note the server error.
  4. Use an ORDER BY clause with increasing numbers to work out how many columns the query returns.
  5. Inject a condition that is always true to make the query return hidden products.

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 questions (queries) by gluing together text, including whatever the user typed. If the site does not separate the user's text from the query properly, a user can type special characters that change the question being asked. Here, typing a quote mark broke the query, and typing a condition that is always true made the database return products it was meant to hide.

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 RayofHope

View all

1 more disclosed report, 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.