SQL Injection Attacks and Prevention Tec PDF
SQL Injection Attacks and Prevention Tec PDF
Abstract: SQL injection attacks are a serious security threat to Web applications. They allow attackers to obtain unrestricted access to
the databases underlying the applications and to the potentially sensitive information these database contain. Various researchers have
proposed various methods to address the SQL injection problem. To address this problem, we present an extensive review of the various
types of SQL injection attacks. For each type of attack, we provide descriptions and examples of how attacks of that type could be
performed. We also present a methodology to prevent the SQL injection attacks.
Keywords: SQL Injection, Attack Intent, Blind Injection, Prevention, Attack Intent, Prepared Statement, Stored procedure
_______________________________________________________*****________________________________________________________
293
IJRITCC | APR 2013, Available @ http://www.ijritcc.org
______________________________________________________________________________
International Journal on Recent and Innovation Trends in Computing and Communication
So you will just login without valid username and password SELECT <rest of injected query> because the attackers
to the admin panel of a website. completely control the seond/injected query they can use
that query to retrieve information from a specified table. The
III. ATTACK INTENT result of this attack is that the database returnsa dataset that
is the union of the results of the original first query and the
Identifying injectable parameters: results of the injected second query.
The attacker wants to probe a Web application to discover
which parameters and user input fields are vulnerable to Example: An attacker could inject the text “‟ UNION
SQL injection Attacks SELECT pass1 from user_info where LoginID=‟secret - -”
into the login field, which produces the following query:
Performing database finger-printing:
The attacker wants to discover the type and version of SELECT pass1 FROM user_info WHERE loginID=‟‟
database that a Web application is using. Certain types of
databases respond differently to different queries and UNION SELECT pass1 from user_info where
attacks, and this information can be used to “fingerprint” the LoginID=‟secret‟ -- AND pass1=‟‟
database. Knowing the type andversion of the database used
by a Web application allows an attacker to craft database Assuming that there is no login equal to “”, the original first
specific attacks. query returns the null set, whereas the second query returns
data from the “user_info” table. In this case, the database
Determining database schema: would return column “pass1” for account “secret”. The
To correctly extract data from a database, the attacker database takes the results of these two queries, unions them,
often needs to know database schema information, such as and returns them to the application.
table names, column names, and column data types. Attacks
with this intent are created to collect or infer this kind of In many applications, the effect of this operation is that the
information. These types of attacks employ techniques that value for “pass1” is displayed along with the account
will extract data values from the database information.
IV. ATTACKS
Tautology-based attack is to inject code in one or more Web applications commonly use SQL queries with client-
conditional statements so that they always evaluate to true. supplied input in the WHERE clause to retrieve data from a
The most common usages of this technique are to bypass database. By adding additional conditions to the SQL
authentication pages and extract data. If the attack is statement and evaluating the web application‟s output, you
successful when the code either displays all of the returned can determine whether or not the application is vulnerable to
records or performs some action if at least one record is SQL injection.
returned.
For instance, many companies allow Internet access to
Example: In this example attack, an attacker submits “ ‟ or archives of their press releases.A URL for accessing the
1=1 - -” company‟s fifth press release might look like this:
The Query for Login mode is:
http://www.thecompany.com/pressRelease.jsp?pressRelease
SELECT * FROM user info WHERE ID=5
loginID=‟‟ or 1=1 - - AND pass1=‟‟
The SQL statement the web application would use to
The code injected in the conditional (OR 1=1)transforms the retrieve the press release might look like this (client-
entire WHERE clause into a tautology the query evaluates to supplied input is underlined):
true for each row in the table and returns all of them. In our
example, the returned set evaluates to a not null value, SELECT title, description, releaseDate, body FROM
which causes the application to conclude that the user pressReleases WHERE pressReleaseID = 5
authentication was successful. Therefore, the application
would invoke method user_main.aspx and to access the The database server responds by returning the data for the
application. fifth press release. The web application will then format
the press release data into an HTML page and send the
4.2 Union Query response to the client.
294
IJRITCC | APR 2013, Available @ http://www.ijritcc.org
______________________________________________________________________________
International Journal on Recent and Innovation Trends in Computing and Communication
. . . and if this query also returns the same press release, then The following is an example of passing two parameters
the application is susceptible to SQL injection "loginID" and "password" safely to a query:
5.4 Use the principle of least privilege Future work should focus on evaluating the techniques
precision and effectiveness in practice.Empirical evaluations
The principle of least privilege is a security cornerstone and will be performed which allow comparing the performance
it applies to SQL injections as well. For instance, when you of the different technique swhen they are subjected to real-
grant a user access only to the tables he or she needs rather world attacks and legitimate inputs. As well as precision,
to the whole database; this drastically reduces the damage accuracy and add on will be incorporated for the prevention
potential. of much complex attacks such as Linked Server, Internal
Network Attack etc.
VIII. ACKNOWLEDGEMENT
5.5 Disable shells
We would like to thank our college SIES Graduate school of
Many databases offer shell access which essentially is what Technology for their constant encouragement. We would
an attacker needs. This is why you need to close this door. also like to thank the faculties for their guidance. The
Consult your DB‟s documentation about how to disable Library staff for providing us with the resources that they
shell access for your particular database. had regarding our topic.
296
IJRITCC | APR 2013, Available @ http://www.ijritcc.org
______________________________________________________________________________