1 What is SQL Injection?
SQL Injection (SQLi) occurs when user-supplied data is embedded directly into a SQL query without sanitization. An attacker can break out of the intended query and execute arbitrary SQL, leading to data theft, authentication bypass, or full database compromise.
Vulnerable example (Python):
username = request.form['username']
query = "SELECT * FROM users WHERE username = '" + username + "'"
cursor.execute(query)
If the attacker sends ' OR '1'='1 as the username, the query becomes WHERE username = '' OR '1'='1', returning all rows and bypassing login.