

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Still calibrating
click for more info
Not enough gems
Cost: 6 gems
1: Injection
incomplete
2: Fixing SQL Injection
incomplete
3: Injection Beyond SQL
incomplete
4: Safe Validation and Sanitization
incomplete
5: When to Sanitize
incomplete
6: Unsafe Archive Extraction
incomplete
7: Safe Archive Extraction
incomplete
8: LLM Prompt Injection
incomplete
9: Limiting Tool Calls
incomplete
10: Narrow Tool Interfaces
incomplete
11: File Upload Security
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Parameterized queries keep SQL instructions separate from untrusted values.
Database APIs let you pass user input as separate parameters instead of simply concatenating it into the query string. The database can tell code apart from data, so a parameter can't change the query's structure.
Modern SQL libraries support parameterization. There's no excuse for building queries with raw strings!
This is not safe:
db.prepare(
`SELECT id, email, plan FROM customers WHERE email = '${email}'`,
).all();
A parameterized query fixes it:
db.prepare(`SELECT id, email, plan FROM customers WHERE email = ?`).all(email);
An attacker who provides an email like ' OR 1=1 -- will simply get an empty result, not the entire customers table.
Bearly Secure inserts product-search input directly into a SQL string. Parameterize the search query so user input can no longer change its structure.
With Bearly Secure still running, run and submit the CLI tests from the project root.