A form of web application vulnerability known as SQL Injection happens when user input is not adequately cleaned up before being incorporated into SQL queries. Without adequate validation or parameterisation, a weak login mechanism in the context of authentication simply enters user-provided values (such as the username and password) into a SQL query. Example of vulnerable SQL query:
An attacker can insert malicious SQL code to change the query's intended logic if the application is unable to handle special characters correctly. For example, by typing:
In this case, '1'='1' is always true, and the remainder of the query is commented out. By doing this, authentication is essentially circumvented, allowing the attacker to log in without legitimate credentials.
There are serious repercussions when SQL Injection occurs at the authentication endpoint:
To protect against SQL Injection and authentication bypass, developers should take the following steps: