Web and API securityHackBlue

Parameterized vs concatenated queries

Build the same product search three ways and watch the token view: concatenation lets input change the query, bound parameters and allowlists keep it a value.

  • Interactive lab
  • Beginner
  • 5 graded steps
  • 0 of 5 solved

Your goal

Your goalChoose how the server builds each part of the query so no input can ever change its shape.

The product search on a shop sends three user inputs to the database: the search text, the sort column, and the page size. Today all three are glued into the SQL string.

For each input, choose how the server builds the query, type any value you like, and watch the token view. The query is safe when no input can change its shape. Nothing here runs against a real database.

What’s on screen
Three inputs
three panels: Search box, Sort column, and Page size. Each has buttons for how the server builds that part.
Input value
the text box in each panel, with Everyday inputs buttons under it. You can type anything.
Token view
the list under the query. It shows how the database splits the query into pieces, and the line below says whether the shape changed.
Walkthrough
the numbered path beside the workbench (below it on a phone). Each step says what to do and what you should see. Hints open one at a time.
Words to know
SQL
Structured Query Language, how programs ask a database for data
Search box qString concatenation
SELECT id, name, price FROM products WHERE name LIKE '%O'Brien%'

Unterminated string starting at character 64

Sort column sortString concatenation
ORDER BY price
  1. ORDERkeyword
  2. BYkeyword
  3. priceidentifier

The input stayed a single value. The query shape matches the template.

Page size limitString concatenation
LIMIT 25
  1. LIMITkeyword
  2. 25number

The input stayed a single value. The query shape matches the template.

At least one input can still change the query or silently break it.