SQL (Structured Query Language) injection: what it is and how a tester checks for it
See how text typed into a form can become part of a query, why a parameterised query stops it, and what a tester tries safely on a test site and reports without harm.
L1–L4 are part of the Pro pass
L0 Explain simply
Analogy: a form with a blank line for your name. The clerk reads the sentence aloud: please give a ticket to, then your name. If the name is read as more instructions, the clerk may do more than you asked. A careful clerk reads the name as only a name.
Daily List is a to-do list app. The search box is supposed to find a task title. Tom checks that a title with an apostrophe stays a title. (SYNTHETIC / TRAINING ONLY: Daily List and the people here are invented.).
What it is: is what happens when text a person typed becomes part of a (Structured Query Language) statement. SQL is the language of the query. A table is a grid. A row is one task. A column is one fact, such as the title. The typed text is input treated as code when the app glues it into the statement. A parameterised query keeps the statement and the value apart. The neighbour is a normal search that finds no row. A safe miss is an empty list. A database error from a quote mark is a sign the text was glued in.
Why it matters: A name like O'Brien can break the search, or, on a bad build, change what the query means. Tom tests on a system the team owns, with , and he does not try to take real data.
PLAIN WORDS · 2 in this section
- apostrophe
- the mark ' used in writing
- parameterised
- set up so each simulated user gets its own values
PICTURE IT
The picture is the one the lesson above opens with. The table below shows how each part of it matches the software.
THE REAL JOB A clerk reading a form aloud, name included.
- Permission
- Try
- Report
HOW THE PICTURE MAPS
| In the picture | In the software |
|---|---|
| The printed sentence | The SQL text |
| The blank for your name | A value from the user |
| A clerk who obeys your note | A query that treats input as code |
| A clerk who reads the name as a name | A parameterised query |
WHERE THIS PICTURE STOPS
- A clerk can ask questions, but a database follows its rules.
- A form has one blank, but an app has many fields.
- A clerk is fooled by words, but a program is fooled by its own string joins.
HOOK
Name is a name, not an order.
TELL A FRIEND
A clerk: a name is only a name.
OFTEN MIXED UP WITH Looking at data with SQL SELECT. That topic reads data with SELECT. This one shows how typed text can change a query.
PRACTISE AND KEEP
Sources for this topic — 4 sources
- Market practice
Query Parameterization Cheat Sheet (OWASP) ↗ — Open Worldwide Application Security Project · OWASP cheat sheet: parameterised queries make the developer write the SQL first and pass values afterwards, so the database can tell code from data and inserted SQL cannot change the query (search excerpt, page not opened)
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
- Market practice
SELECT command reference (PostgreSQL documentation) ↗ — PostgreSQL · PostgreSQL select reference: where filters rows using the conditions given in the query text (search excerpt, page not opened)
PostgreSQL18 publisher documentation opened on6November2026: SELECT: WHERE/HAVING/output aliases, functional dependence, NULL ordering and LIMIT. No execution on PostgreSQL is claimed; engine-specific examples remain scoped to18.
- Market practice
Structured Query Language (SQL) injection prevention cheat sheet (Open Worldwide Application Security Project) ↗ — Open Worldwide Application Security Project (OWASP) · Official OWASP SQL Injection Prevention Cheat Sheet, Prepared Statements and Allow-List Input Validation, opened 2026-11-06: bind data values; map identifiers/directions to fixed allowed tokens. A symptom does not itself prove exploitation.
Found through a web search; the page was not opened (search excerpt, page not opened). Version: Web page, no edition number. Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.
V34 review, 6 November 2026: Read complete official repository sheet. Bind values; dynamic SQL structure requires separate safe handling, and object authorisation remains distinct.
- Implementation-specific
SQLite official documentation — constraints, types and transactions ↗ — SQLite · SQLite rolling official documentation, opened 2026-11-06: foreignkeys.html, datatype3.html, lang_createtable.html, lang_transaction.html, isolation.html, cli.html, series.html and lang_createtrigger.html as relevant. Historical SQLite 3.40.1 results remain distinct from in-memory audit witnesses on 3.53.1.
Relevant primary pages opened 6 November2026; rolling documentation and CLI examples (3.54.0) are distinct from historical lesson runs3.40.1 and audit witnesses3.53.1. No file/connected database audit execution.
Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.