what is SQL injection
SQL injection is a common web security vulnerability where attackers insert malicious SQL code
into input fields to manipulate a database query. This exploit occurs when an application fails to
properly sanitize user inputs, allowing the injected code to alter the intended SQL statement's
logic. Attackers often use it to extract sensitive data, modify records, or even gain control over
the database server. [1] [2]
How It Works
Applications typically build SQL queries by concatenating strings with user input, such as in a
login form. An attacker might enter ' OR '1'='1 into a username field, which closes the original
query prematurely and adds a condition that's always true, bypassing authentication. For
example, a vulnerable query like SELECT * FROM users WHERE name = '" + input + "' AND pass =
'" + pass + "' becomes exploitable. [2] [3] [4] [1]
Types of Attacks
In-band SQLi: Attackers use the same channel for data exfiltration, like error-based
(leveraging database errors) or union-based (combining results with UNION). [5]
Blind SQLi: No direct data return; inferred through response time or boolean conditions. [6]
Second-order SQLi: Malicious input stored in the database and executed later during
retrieval. [6]
Prevention Methods
Use prepared statements or parameterized queries to separate SQL code from data, ensuring
inputs are treated as literals. Input validation, output encoding, and web application firewalls
(WAFs) provide additional layers of defense. [7] [3] [8] [2]
⁂
1. [Link]
2. [Link]
3. [Link]
4. [Link]
5. [Link]
6. [Link]
7. [Link]
8. [Link]
9. [Link]
10. [Link]