What is SQL Injection
SQL Injection is a type of web application security
vulnerability in which an attacker is able to submit a database SQL
command which is executed by a web application, exposing the back-end
database. A SQL Injection attack can occur when a web application
utilizes user-supplied data without proper validation or encoding as
part of a command or query. The specially crafted user data tricks the
application into executing unintended commands or changing data. SQL
Injection allows an attacker to create, read, update, alter, or delete
data stored in the back-end database. In its most common form, a SQL
Injection attack gives access to sensitive information such as social
security numbers, credit card number or other financial data. According
to Veracode’s
State of Software Security Report SQL Injection is one of the most prevalent types of web application security vulnerability.
Key Concepts of a SQL Injection Attack
- SQL injection is a software vulnerability that occurs when data
entered by users is sent to the SQL interpreter as a part of an SQL
query
- Attackers provide specially crafted input data to the SQL interpreter and trick the interpreter to execute unintended commands
- Attackers utilize this vulnerability by providing specially crafted
input data to the SQL interpreter in such a manner that the interpreter
is not able to distinguish between the intended commands and the
attacker’s specially crafted data. The interpreter is tricked into
executing unintended commands
- a SQL Injection attack exploits security vulnerabilities at the
database layer. By exploiting the SQL injection flaw, attackers can
create, read, modify, or delete sensitive data
SQL Injections: The Most Prevalent Type of Application Security Vulnerability
With over 20% of all web vulnerabilities being attributed to SQL
Injection, this is the 2nd most common software vulnerability and having
the ability to find and prevent SQL injection should be top of mind for
web developers and security personnel. In general, a SQL Injection
attack exploits a web application which does not properly validate or
encode user-supplied input and then uses that input as part of a query
or command against a back-end database. For example, a typical form may
ask for a ID and create a URL:
http://www.somewebsite.com/id/id.asp?id=somedata. An attacker using SQL Injection may enter
"somedata or 1=1".
If the web application does not properly validate or encode the
user-supplied data and sends it directly to the database, the reply to
the query will expose all ids in the database since the condition
"1=1"
is always true. This is a basic example, but it illustrates the
importance of sanitizing user-supplied data before using it in a query
or command.
Preventing SQL Injection
- SQL injection can be prevented if you
adopt an input validation technique in which user input is authenticated
against a set of defined rules for length, type, and syntax and also
against business rules.
-
You should ensure that users with the permission to access the database
have the least privileges. Additionally, do not use system administrator
accounts like “sa” for Web applications. Also, you should always make
sure that a database user is created only for a specific application and
this user is not able to access other applications. Another method for
preventing SQL injection attacks is to remove all stored procedures that
are not in use.
-
Use strongly typed parameterized query APIs with placeholder substitution markers, even when calling stored procedures
-
Show care when using stored procedures since they are generally safe
from injection. However, be careful as they can be injectable (such as
via the use of exec() or concatenating arguments within the stored
procedure).
No comments:
Post a Comment