Vulnerabilities
SQL Injection (SQLi)
Attack injecting malicious SQL code through user input
SQL Injection is a vulnerability that allows an attacker to inject malicious SQL code into database queries through unvalidated input. One of the most common and dangerous web application vulnerabilities.
Types of SQL Injection
- In-band SQLi — result visible in response
- Blind SQLi — result not directly visible
- Out-of-band SQLi — data transferred via different channel
Example of Vulnerable Code
SELECT * FROM users WHERE username = '$username' AND password = '$password'
When entering ' OR '1'='1 the query becomes:
SELECT * FROM users WHERE username = '' OR '1'='1' AND password = ''
Protection
- Prepared Statements (parameterized queries)
- ORM frameworks
- Input validation
- Principle of least privilege for DB
Related Terms
Category
CVE, OWASP Top 10, vulnerability types and classification