Concepts / Web injection and scripting

Web injection and scripting

Parameterised query

Also called prepared statement, bound parameter, parameterized query

Sending a database the fixed query and the values separately, so input is always data and never code.

Query and value travel separately
Query and value travel separately

The database compiles the query before it sees the value, so the value can only fill the placeholder as text. Its quote and -- are just characters to compare.

A parameterised (or prepared) query sends the database the SQL with placeholders, WHERE username = ?, and the values separately, never inside the query text. The database compiles the query first, then binds each value as data, so a quote or -- in the input is only characters it compares, never SQL it runs. It is the main defence against [[sql-injection]], alongside least privilege for the web account.

See it on real machines

Read next

Learn it on real machines.

Every lab is a small network of real Linux machines in your browser. Sign in with Google or email to start.

Start this lab