SQL Injection is a code injection technique where malicious SQL statements are inserted into entry fields for execution. This can allow attackers to bypass authentications, retrieve database contents, or escalate privileges.
// VULNERABLE CODE (String Concatenation)
const query = "SELECT * FROM users WHERE username = '" + userInput + "' AND password = '" + userPass + "'";If the attacker inputs `' OR '1'='1` as the username, the query becomes:
SELECT * FROM users WHERE username = '' OR '1'='1' AND password = '...';💡 Because '1'='1' is always true, the database returns all user profiles, bypassing password checks completely!
Verify exercises to earn ★ 150 XP and unlock next lab level.