SQL Injection
SQL Injection
Web Server
rm
a l i c i ous fo
post m
1
2
unintended
3 receive query response SQL query
Attacker
Victim SQL DB
WHAT LEADS TO SQL INJECTION
$username = $_POST['username’];
$password = $_POST['password’];
$query = "SELECT * FROM users WHERE username = '$username' AND password = '$password'";
$result = mysqli_query($conn, $query);
SQL PAYLOADS
Sqli payloads are specific pieces of SQL code designed by attackers to exploit SQL
injection vulnerabilities in an application. These payloads are injected into user input
fields or parameters, ex :
Authentication Bypass:
Input: admin' --
SELECT * FROM users WHERE username = 'admin' -- ' AND password =
Resulting Query: 'password';
Explanation: The -- marks the start of a comment in SQL, making the rest of the query
irrelevant and potentially allowing an attacker to bypass password checks.
PRACTICAL EXAMPLE
HOW TO PROTECT AGAINST SQLI
Ensure the application operates with the least amount of database privileges
necessary, avoiding the use of admin-level database accounts for routine
operations
DETAILED ERROR HANDLING:
Avoid revealing detailed error messages to users, as they can provide clues to
attackers. Log errors server-side and provide generic error messages to users.
THANKYOU