What is SQL Injection?

Duane Chambers
3 min readSep 25, 2021

SQL Injection Vulnerability Explained

SQL injection is an extremely dangerous and insidious web application security vulnerability, where SQL files, database rows, and stored procedures are automatically compiled by database administrators when executing queries. With the SQL commands inserted, the executed query is dynamically compiled by the database. Unfortunately, the user is not allowed to examine the generated SQL, so it is virtually impossible to prevent SQL injections in large databases. The only way to avoid SQL injection attacks is never to allow users to execute any SQL statement or execute the SQL stored procedure independently.

The main goal of SQL injections vulnerability is an injection of SQL scripts into web applications and server sockets for quick and efficient execution. It usually happens when a vulnerable web application uses user-provided inputs and parameters while passing the same parameters to another web application function. The most popular ways to perform SQL injection attacks are through the use of VBA, C# Client Code, programming error messages, improper SQL injection declaration, usage of unsafe operators, application programming interfaces, application program interface (API) usage, and connect/expressions. In a nutshell, SQL injection results in data corruption, database corruption, system crash, and application termination. So the symptoms are — database corruption, application termination, and application data loss.

An SQL injection attack starts with the attacker creating simple SQL scripts. He then inserts these SQL scripts into the target database to fill the required fields to the output SQL statement. To execute the attack successfully, the attacker first uses a temporary file to hold the SQL script. Then he continues with the same technique of inserting new SQL statements into the old database.

The two most common types of SQL injection vulnerabilities are first-order and second-order SQL injection. The developer can perform the first-order SQL injection using improper keywords, table names, or entity reference characters. The second-order SQL injection vulnerability is caused by developers bypassing application security features such as encryption and token usage. These SQL injections usually result in application crashes or data loss. To avoid these SQL injection vulnerabilities, the developers should use secure tables and safe entity references.

The SQL injection vulnerabilities are categorized into two categories. The two major categories are blind and default. The blind SQL injection vulnerability occurs when an attacker sends a request to the server which contains incorrect, incomplete, or missing input data. For instance, the database may use a ‘?’ character for database hint. The data that you provide could be missing, outdated, or inconsistent. When the application receives input that was not expected, it then sends back an error message to the user.

The second category of SQL injection vulnerability is called the ‘default’ SQL injection vulnerability. When an application is executed with the ‘ — ‘ option, there is no way that an administrator can check for or supply needed information to the user. In this case, the default SQL injection vulnerability occurs when an attacker uses a command injection vulnerability to create and execute a series of commands within the affected database tables.

--

--

Duane Chambers

I provide advisory services for corporations and executives regarding network architecture, test design/execution, network virtualization and datacenter design.