Understanding SQL Injection Attacks: Best Practices For Web Application Security
Understanding SQL Injection Attacks: Best Practices For Web Application Security
Abstract:- SQL (Structured Query Language) injection risks and second to suggest and assess methods to improve
represents a security weakness that enables attackers to their ability to defend against threats. t's not only the option
run SQL commands within a web applications database. to defend ourselves from the attacker but also think like them
When exploiting a designed application lacking input to check the security of the webpages from the queries of the
validation a malicious actor can control input data to attackers. By this, all the points of the security will be tested
execute SQL queries. The objective of detecting SQL and implemented carefully. For browsing the online pages
injection vulnerabilities is to identify any section of a web and make them more user friendly as well trustworthy this
application to user input exploitation, for SQL injection research will be more convenient and facilizing for the users.
attacks and confirm that the application adequately
validates user inputs. The aim of this project is to try and However, relying on these platforms also exposes us to
form an attack chain and test the same against any security risks that could compromise our information. As
website to assess the website for any weak links and students studying computer science, it's our duty to protect.
identify any entry points that an attacker could use to
penetrate the system and take control of the same. This data and keep the confidentiality of the user’s
information’s. Our study focuses on evaluating the security
From the paper it is figured that most of the tools of web applications specifically looking into vulnerabilities
only check the vulnerability for the given URL and do not such as SQL injection, Cross Site Scripting (XSS), and
crawl through the webpages and find if the vulnerability HTTP Strict Transport Security (HSTS). Our goal is to
is present in any of the other pages. In this project, we are pinpoint weaknesses and suggest ways to strengthen defence
taking the additional step to confirm that there are no mechanisms. Divided into three parts our research delves
vulnerabilities mentioned in this research present in any into testing for SQL injection XSS scripting and HSTS
of the webpages. vulnerabilities. This study aims to provide a comprehension
of web application security paradigms by combining real
Keywords:- SQL Injection, SQL Queries, Vulnerabilities, world data and theoretical perspectives. By examining these
Website, URL, Webpages. weaknesses and exploring ways to mitigate them we aim to
offer insights, for improving web application security.
I. INTRODUCTION Through this study, we aim to enhance understanding of web
application security and help stakeholders defend against
In today's era web applications are essential, in our threats while maintaining user trust in platforms. For the
lives helping us with tasks like online shopping and sharing testing environment we are going to use the following
data. The main goal of this study is two pronged; first to structure below:
examine how well web applications can withstand security
In this paper we will proceed with the steps; (II) Using these queries, we will test for each type of SQL
presenting the findings of our research and insights gained Injection attack [15].Moving from simpler use cases, we will
from them (III) demonstrating the outcomes of our study and use queries from the exhaustive list provided by the OWASP
research by outlining the challenges for our strategy, (IV) organization to test for advanced cases for our research
following by a discussion on the significance of our testing [13].For a deeper explanation of SQL Injection with
discoveries and (V) potential areas for further exploration, in the threat modelling, explain the impact of the attack and
future work. what the attacker is capable of, applications where SQL
Injection is common like PHP and ASP and the severity of
II. RELATED WORKS SQL Injection attacks. Also, briefing the occurrence and the
consequences of the attack. Making this remark makes one
Research on the use of the black-box method for wonder about how we could link a SQL Injection attack with
penetration testing, with a specific focus on SQL injection other forms of vulnerability [14]. In a blog the major
attacks. This research only gave more statistical information problem arises because there are not enough tests written to
than technical information and goes on to explain the validate all negative use cases when the code is developed.
vulnerability of every website and how it is important to Organizations might not have enough funding to dedicate a
perform penetration testing at regular intervals to better testing team or have sufficient manpower. For a persistent
safeguard the web application [1]. Oliver Moradov on SQL attacker, this is an easy target. The author suggests using
Injection Testing methods [10] mentioned in a blog, there are Feedback-Based Fuzzing to overcome the issues. This
5 types of testing for an SQL Injection: Stacked Query automates the testing process along with generating the test
Testing ( Completing an SQL query and writing a new one data based on the previous results [9].
on top of the previous), Error-Based Injection testing
(exploiting SQL error messages), Boolean-Based Injection III. PROPOSED MODEL
Testing ( adding conditional statements ), Out-of-Band
(Blind) Exploit Testing and Time Delay Exploit Testing System Construction
(monitoring server response time). The fist documentation This model is a collection of tools used for checking
for SQL injection was exploited in 1998 by a researcher and vulnerabilities in a website. This framework uses various
hacker where it was mentioned that with basic coding skills, open-source applications to identify different types of
one could use unauthorized SQL commands on legitimate vulnerabilities. We implement Vulnerability Checker using
SQL statements to extract confidential information from a Python and vulnerability testing software like SQLMap,
database. There are multiple tools to test for every one of Nmap, DirBuster, Nikto and various Python modules to test
these vulnerabilities separately and there are a lot of the website for SQL Injection attacks, Man-in-the-Middle
applications that offer tests for various vulnerabilities attacks by testing if the web application has HTTP Strict-
combined. But all these tools require basic knowledge of Transport-Policy and Cross-Site scripting attack.
how the application works and the kind of parameters that
need to be sent to execute the tests [8]. In another research SQLMap: SQLMap is an open-source penetration testing
paper network traffic patterns uses machine learning tool used for testing SQL injections which generates the
algorithms to identify unusual or suspicious traffic patterns SQL queries to test against the website. SQLMap has a
that may indicate an attempt to launch a SQL injection lot of options to choose from and it is extensive to test for
attack. The proposed detection system employs machine sql injection. Basic arguments required to execute the
learning methods to identify patterns and scrutinize gathered sqlmap command is ‘-u’ option, to specify we are going
data for indications of an SQL injection risk [3]. Since this to enter an URL and the second argument is the URL
isn't a tool there could be hurdles, in constructing the model itself.
and initiating the testing phase. Like the machine learning Nmap: Nmap short for Network mapper, is an open-
model, another proposal uses runtime validation to detect source application to discover network and audit security
and prevent SQL Injection Attacks (SQLIA). The model uses vulnerabilities. Nmap needs the URL as a mandatory
a proxy server as a middle layer between the client and argument and depending on the requirements additional
database server to check input queries and filter out any options can be provided to get the desired output.
SQLIA [12]. For an understanding of various detection and Dir buster: Dir buster is a Java application used for brute
prevention techniques like Hybridization of Knuth-Morris- forcing files and directories on a web application. It tries
Pratt (KPM) and Boyer-Moore (BM) algorithm, detection to find any hidden files or directories within the
model to scan SQL injection on the web environment for the application. Dir buster tool reads all files and directories
SQL Injection attacks like Tautology, Union Queries, Piggy- on the website and displays on the terminal. The output
Backed attack etc, which will be useful for us to write can also be redirected to an output file.
different SQL Injection attack queries [2].The cheat sheet Nikto: Nikto is an open-source application that scans web
(Invicti, n.d.), like other blogs, gives an in-depth explanation servers and common gateway interfaces. Nikto provides
of different SQL injection attacks on MySQL, Microsoft support for HTTP proxy, accepts cookies, and verifies if
SQL Server, ORACLE and PostgreSQL SQL servers [5]. the server is running on any outdated components. Nikto
SQL Injection blog gives a good introduction on how to test takes 2 inputs as arguments. First, -h to indicate host URL
for SQL Injection attacks. From this blog, we will be using and the second argument URL or the IP address of the
the examples provided for basic use cases [16]. In another web application to test.
blog, there are given examples for each testing method.
Cross-Site Scripting Testing: The cross-site scripting argument the wordlists created by CeWL and a
assessments are not limited to the initial URL provided predefined wordlist to navigate through the webpages to
by the user, but rather encompass a broader examination identify any hidden folder or files. Dirb identifies hidden
of other pages available on the website to identify those folders and files. We store these findings in an output file
that are susceptible to XSS attacks. For intermediate and use the found links to test for presence of cross-site
level users we go a level up and test all available scripting in all these webpages. Cross-site scripting for
webpages on the website. To retrieve the available intermediate level users is done not just for the given
webpages, we use dirb to find any hidden files or folders. website, but also for other files found using dirb tool. The
Custom Word List generator generates a wordlist based script iterates over the found webpages and applies cross-
on the words present on the website. Dirb takes as site scripting tests to identify the vulnerability if any.
HSTS Header Tester: Sqlmap also performs tests for technologies and components utilized in the creation of
more advanced security vulnerabilities. These tests the web application, including the version and type of
include verifying the availability of the strict-transport- database employed. These tests confirm if the specific
security header, which is an important security feature security vulnerability is present on the website. Thus,
that helps to protect against man-in-the-middle attacks. It giving the owner an idea of the security of their web
also provides valuable insight into the underlying application.
Fig 8: SSL Certification and HSTS Header Test Results for Components
Valid SSL Certification: Sqlmap also checks for the Remaining vulnerabilities testing in Expert level:
presence and configuration of SSL certificates, which are Remaining tests are like that of the intermediate user
used to encrypt communication between the client and level. Cross-site scripting tests are performed for all the
server. By verifying the SSL certificate, Sqlmap can hidden files and folders obtained through dirb. Tests for
identify potential vulnerabilities that could be exploited strict-transport-policy header, verification of valid SSL
by an attacker. Other tests that Sqlmap performs include certificate and check for any outdated components are a
checking for cross-site scripting vulnerabilities, testing part of expert level testing too. Expert level users can run
for cross-site request forgery, and validating the security any SQL query to test the website using this script. All
of session cookies. Tests for strict-transport-policy other functionalities are like intermediary users. User
header, verification of valid SSL certificate and check for enters a query that he wants to test on the vulnerable
any outdated components are a part of expert level testing server to see the response he receives. Every tool initiated
too. a sub process and the corresponding results were stored
in a log file which was further accessed to retrieve
information.
REFERENCES