Security · interactive
SQL injection
A login form looks up the username you type. If the code pastes your text straight into the SQL, a quote mark ends the string early and the rest of your input becomes part of the query. The database here is a simulation.
Username typed
' OR '1'='1
SQL sent to the database
SELECT * FROM users WHERE username = '' OR '1'='1'
Rows returned
| 1 | admin | admin |
| 2 | alice | user |
| 3 | bob | user |
'1'='1' is always true, so every row matches. The app logs in as the first one: admin.
'1'='1' is always true, so every row matches. The app logs in as the first one: admin.
Username
How the code builds the query
Step 1 of 4 · read left to right
In production
Tools and technologies
Parameterized queries are built into every major driver and ORM.
Not tied to one language — use these names when you search docs or design a system.