SQL Injection: How and Why It Works
Understand classic, blind, and out-of-band SQLi and why parameterized queries prevent it.
What is SQL Injection?
SQL Injection (SQLi) occurs when user-supplied input is included in a SQL query without proper sanitization, allowing attackers to manipulate the query logic. It is one of the oldest and most damaging web vulnerabilities.
How SQL Injection Works
A login form queries: SELECT * FROM users WHERE username='INPUT' AND password='INPUT'
If the attacker enters ' OR 1=1-- as username, the query becomes: SELECT * FROM users WHERE username='' OR 1=1--' AND password='...' — which returns all users.
All lessons in this course
- SQL Injection: How and Why It Works
- Cross-Site Scripting (XSS)
- Cross-Site Request Forgery (CSRF)
- Security Misconfiguration and Exposed Services