You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Consider an application that lets users log in with a username and password. If a user submits the username `wiener` and the password `bluecheese`, the application checks the credentials by performing the following SQL query:
3
+
4
+
`SELECT * FROM users WHERE username = 'wiener' AND password = 'bluecheese'`
5
+
6
+
If the query returns the details of a user, then the login is successful. Otherwise, it is rejected.
7
+
8
+
Here, an attacker can log in as any user without a password simply by using the SQL comment sequence `--` to remove the password check from the WHERE clause of the query. For example, submitting the username `administrator'--` and a blank password results in the following query:
9
+
10
+
`SELECT * FROM users WHERE username = 'administrator'--' AND password = ''`
11
+
12
+
This query returns the user whose username is administrator and successfully logs the attacker in as that user.
0 commit comments