SQL Injection Masterclass - A vintage illustration showing a hacker breaking through database defenses

SQL Injection Masterclass

"To build a fortress, you must first understand the siege."

What is SQL Injection (SQLi)?
The art of subverting database queries.

SQL Injection occurs when untrusted user input is concatenated directly into a database query without proper sanitization or parameterization. This allows an attacker to manipulate the query's structure, potentially accessing, modifying, or deleting data they shouldn't see.

// Vulnerable Code

query = "SELECT * FROM users WHERE name = '" + userInput + "'";

If the user inputs ' OR '1'='1, the query becomes:

SELECT * FROM users WHERE name = '' OR '1'='1'

Since '1'='1' is always true, the database returns all users instead of just one.