SQL Injection (SQLi) is a code injection technique where an attacker inserts malicious SQL code into application queries. This can allow attackers to:
Note: This is a pure frontend simulator. No real database is involved. The simulator shows what would happen if these queries were executed.
Enter these in the username or password field:
' OR '1'='1
admin'--
' OR 1=1--
' UNION SELECT username, password FROM users--
'; DROP TABLE users--
Vulnerable Code (Backend):
// โ VULNERABLE: String concatenation in SQL query
const query = "SELECT * FROM users WHERE username='" + username + "' AND password='" + password + "'";
db.execute(query);
The problem: User input is directly concatenated into the SQL query without sanitization, allowing attackers to modify the query logic.
Secure Code (Parameterized Query):
// โ
SECURE: Using parameterized queries/prepared statements
const query = "SELECT * FROM users WHERE username=? AND password=?";
db.execute(query, [username, password]);
// โ
SECURE: Using ORM (e.g., in Node.js with Sequelize)
User.findOne({ where: { username: username, password: password } });
When you enter: ' OR '1'='1 as username
The query becomes:
SELECT * FROM users WHERE username='' OR '1'='1' AND password='anything'
Since '1'='1' is always TRUE, the OR condition makes the entire WHERE clause
TRUE, bypassing authentication and returning all users!
' " ; -- /* */' OR '1'='1-- # /* */' OR SLEEP(5)--