INFS 311 Assignment
INFS 311 Assignment
1. SQL injection
1.1. Introduction to SQL injection
1.2. SQL injection
1.3. How SQL Injection Works Vision
1.4. Understanding How It Occurs
1.5. Understanding Web Application Operation
1.6. Different types of SQL Injection.
1.7. A list of six steps that can assist you avoid SQL injection
1.8. Practices for avoiding SQL injection flaws
2. NoSQL Database
2.1. NoSQL Database
2.2. Different types NoSQL databases
2.3. Difference between Relationship Database Management Systems and NoSQL databases
2.4. Summary comparison between NoSQL and RDMS
3. Conclusion
3.1. Referencing
4. Referencing
4.1. Conclusion
2
30354617 Database Systems, Final year assignment
DG MOSHANE
1. SQL injection
3
30354617 Database Systems, Final year assignment
DG MOSHANE
other databases/system on the same server connected, or even other servers connected to the network, may
become exposed. Since the fields displayed for user’s input and output allow SQL statements to access
directly the database, website features for input and output are all vulnerable to SQL injection attacks. An
attacker/hacker first need to find an input or output in the web database application that is located inside a
SQL query, for a hacker/attacker to execute harmful SQL queries against a web app database server
(Invicti, 2022). The attack must include user input in SQL statement for SQL injection attack to
successful. An attacker can now insert malicious files to the SQL query, which will be executed against
the web app database server.
1.4 Understanding How It Occurs
The most common cause of SQL injection exposures is when a databases developer fails to authenticate or
change values received through an input or output before taking them to SQL queries that will be executed
by a web application database server (Gitbook, 2021).
Attackers/hackers can only have access to run code on the web application database server, if their able to
control input data provided to a SQL query and modify it, thus, input data will be recognized as normal
code than data.
In most cases databases developers develops insecure web application database that are more vulnerable
to SQL injection, without a clear understanding and awareness of the possible safety issues of the code
that is being created to penetrate web application database server (Snyk, 2022).
Below is a picture and explanation showing a SQL Injection Attack at between an attacker/hacker,
database input text fields and database/server.
4
30354617 Database Systems, Final year assignment
DG MOSHANE
1.5 Understanding web application database operations
Web application – According to O’Leary et al. (2017:8) is an application or program that runs on
an internet or network, and can be accessed through a Web application browser. Furthermore, it
also a computer application that is programmed in a browser supported language such C++, C#,
JavaScript, HTML and CSS and operates in a Web browser.
A basic web application database has a back end database system and Website forms with server
side commands programmed in a language that is capable of retrieving specific portion of data or
information from a database system on several connections (Clarke, 2012:24).
According to Clarke (2012:24) web application is characterised into 3 tiered database driven
dynamic namely:
1. The tier of presentation or Web browser
2. The tier of logic or programming language
3. As well as a storage layer
Requests are sent from the Web browser to the middle tier, which responds by querying and updating the
database.
5
30354617 Database Systems, Final year assignment
DG MOSHANE
focus on the errors displayed. They are
explained in detail below:
Union based SQL Error based SQL
This technique is found under in band SQL it This technique is found under in band SQL it
leverages the union SQL operator to join the depends on error messages retrieved from the
out of two or more select statement into one database server to access data or information
output which is returned as a portion HHTP about the organization/structure of the
response (Invicti, 2022). database system (Invicti, 2022). It is important
for developers to disable this error on a live
website to avoid this type of attack.
This technique is found under Inferential SQL it This technique is found under Inferential SQL it
relies on transferring an SQL query to the is responsible for sending a SQL query to the
database which forces the web application to web application database which cause the web
return different results depending on the application database to wait for certain specific
CONDITION statement of query returns a true duration(seconds) before sending a response
or false output (Invicti, 2022). This method is (Invicti, 2022). This method is also considered
also considered slow since attackers have to slow since attackers have to enter character by
enter character by character. character, especial large web application
database.
Depending on the output retrieved, data or
information in HTTP results will change or
remain unchanged (Invicti, 2022). This allows
the hacker/attacker to infer if the SQL query
used returned true or false, even if the no
information returned from the database.
6
30354617 Database Systems, Final year assignment
DG MOSHANE
prevent it on the web application database
server. This attack occurs when a
hacker/attacker the results of the hacker’s
activities is received using another channel
(Invicti, 2022). If this technique succeed it can
also give an attacker access to time based
attack, this can only occurs if the response
from server is not stable enough.
The picture below shows steps on how Error based SQL injection is used to retrieve data from the web
application database:
Preventing SQL Injection is not easy. The type of SQL vulnerability, web application database, and the
programming language used to program the web application: all hinders the prevention strategies
implemented Clarke (2012:42). But their still some proven strategic rules that web application database
can follow in order to reduce the attacks used to keep the web application database secure Clarke
(2012:24).
1.7 A list of six steps that can assist you avoid SQL injection
7
30354617 Database Systems, Final year assignment
DG MOSHANE
1.8 Here are some practices for avoiding SQL injection flaws
8
30354617 Database Systems, Final year assignment
DG MOSHANE
Different Practices Explanations
9
30354617 Database Systems, Final year assignment
DG MOSHANE
Escaping All User-Supplied Input Before entering user input into a query, this
approach is used to escape it (Ingalls, 2021). In
terms of implementation, it's fairly database
specific (Ingalls, 2021). Retrofitting legacy code is
usually only recommended when implementing
input validation isn't cost effective. Parameterized
queries, stored procedures, or any form of Object
Relational Mapper that constructs your queries for
you should be used to build or rewrite applications
that are created from the ground up or require a low
risk tolerance (Ingalls, 2021).
10
30354617 Database Systems, Final year assignment
DG MOSHANE
2. NoSQL Database
11
30354617 Database Systems, Final year assignment
DG MOSHANE
Main 4 types NoSQL database
Column Oriented
A database management system (DBMS) that traditional save data tables as columns not rows is known as
a column oriented DBMS (MongoDB, 2022). The table name, row key, column, and timestamp are
typically multidimensional components of column oriented systems. A column usually contains two parts:
a column qualifier and column family (MongoDB, 2022). Instead of browsing and deleting unneeded data
in rows, the database may accurately access the data it needs to accomplish a SQL query by storing it this
method (MongoDB, 2022). As a result, query performance is frequently improved, particularly in large
sets of data.
Google's BigTable is an example. Bigtable is a distributed column-oriented NoSQL database service for
massive analytical and operational workloads with great performance. Bigtable, according to Google,
provides a wide range of applications, scalability, high performance, and high availability.
Document Oriented
MongoDB, for example, is a schema-free document-oriented NoSQL database system that stores
documents in BSON format. MongoDB Inc., originally known as 10gen Inc., created it, and it was first
released in 2009. Documents with a similar structure are grouped together as collections in MongoDB,
and each document can have several fields. A new field can be introduced to a document without affecting
other papers in the system by updating the central system catalog. This method is called dynamic schema.
Key-value Stores
This data model stores data in a key-value structure, as the name of this type of NOSQL database suggests
(MongoDB, 2022). The key is a one-of-a-kind object associated with a data item that is used to quickly
locate the data item on physical drives (MongoDB, 2022). In real-time operations, this key-value format
allows for high-speed read and write processing (MongoDB, 2022). Furthermore, to achieve scalability
12
30354617 Database Systems, Final year assignment
DG MOSHANE
and availability, data can be horizontally partitioned and replicated throughout a cluster. Complex query
languages, on the other hand, cannot be implemented on the structure.
For example, Amazon's DynamoDB is a cloud-based NoSQL database built on key-value store principles.
Except for the primary key, DynamoDB is schemaless, which means there is no preset schema for table
names, column names, or data types. A name-value pair in an item is a single-valued or multi-valued set
of values.
Since key value pairs are designed with simpler and less restrictive data structures than RDBMS,
DynamoDB is extremely scalable with low latency and great speed.
Graph-Oriented
The design of a graph-oriented database takes use of the node-edge relationship's simple structure and
turns it into a well-defined database system (MongoDB, 2022). The data in a graph database is represented
as a collection of nodes and edges. Labelling nodes and edges to indicate the types of things and
relationships they represent is possible (MongoDB, 2022). Data relationships, like RDBMs, are often
stored in data and accessed using the SQL keyword 'join.' When a database contains a lot of relationships,
however, it slows down since joining tables costs a lot of time and money. Graph databases, on the other
hand, explicitly store relationships, allowing for simple and quick retrieval of complicated hierarchical
systems.
2.3. Difference between Relationship Database Management Systems and NoSQL databases.
13
30354617 Database Systems, Final year assignment
DG MOSHANE
The table below shows the differences between Relationship Database Management Systems and
NoSQL databases.
14
30354617 Database Systems, Final year assignment
DG MOSHANE
Features NoSQL Databases RDMS
Performance High Low
Scalability High High but is more expensive
Data Storage Designed to handle large Large to medium-sized
amounts of data
Consistency Poor Good
Availability Good Good
Reliability Poor Good
3. Conclusion
3.1 Conclusion
15
30354617 Database Systems, Final year assignment
DG MOSHANE
In this documents we discussed SQL injection as an attack, and how it works/occurs, and different types
of approach that can be used to perform this attack. And we highlighted practices that can be used to
improve the security of the web application database, however this practices do not guarantee full security
to the database server, since more tools are being continuous programmed by attackers.
We also discussed NoSQL Database, how they work and provided the different between RDMS and
NoSQL. According to Oracle (2022: 29) NoSQL is better that RDMS since is more secure compared to
RDMS, the weakness is that it complicated to develop compared to NoSQL.
4. Referencing
4.1Referencing
16
30354617 Database Systems, Final year assignment
DG MOSHANE
Clarke, J., 2012. SQL Injection Attacks, Waltham: Elsevier.
O'Leary, L.J., O'Leary, L.D., O'Leary, D.A., 2017. COMPUTING ESSENTIALS. New York: McGraw-Hill
Education.
Joshi, S., 2005. SQL injection attack and defense: Web Application and SQL injection.
http://www.securitydocs.com/library/3587 Date of Access: 09 June. 2022.
17
30354617 Database Systems, Final year assignment
DG MOSHANE