We said databases, we need to talk about securing access to them,
because there's something different about databases,
while the structure in the data and how we access it.
And we talk about access control,
which is sort of something that we had discussed before.
So, are there sort of unique kind of attacks that are possible on databases?
So, that's what we want to explore next.
What kind of threats are possible,
because either the structure of the data that we have in the database, or
the way we access it through the query languages like SQL, for example.
So, we're going to talk about a couple of different possible attacks.
The first one we're talking about is what is called SQL injection.
We'll see that these are essentially someone exploiting vulnerabilities
in the code that makes up the query that is submitted to a database.
Query is written SQL, then it's an SQL query and
attack is called SQL injection.
So what really is an SQL injection is a malicious command.
This is a command this is presented to the database.
So that the database is going to actually run it.
Malicious because it's going to allow someone to do something that they
are not authorized to do.
Results, of course, are not going to be consistent with
the kind of security that you're looking to provide for this database.
These kind of injection attacks when successful,
they can disclose large amounts of data.
We talked about disclosures of customer data and so on earlier.
So if you do that, of course,
you are impacting confidentiality of the database.
You're extracting data from the database that is being made public or
going to somebody who shouldn't have access to it.
These injection attacks can also corrupt or
delete the data that's there, some set of tuples in a table or
something like that that could impact integrity of the data.
So injection attacks can corrupt, which is integrity or disclose,
which is confidentiality, and
both of these bad outcomes are possible when it kind of attacks.
We're going to discuss what they are, are successful.
For us to understand what these SQL injection attacks are,
we have to sort of learn something else,
which is a lot of times the databases are in the back end of the system.
The front end is some sort of web application environment that you
have, okay?
And the user interacts with the web application, and presents, we're
going to do an example in a minute, some sort of request to the application.
All that application then translates to a query that goes out to the database.
And the query is typically generated by a script, based on the user input.
So user wants something done, provides input for it.
There's a script that takes that input, generates a query, and
then submits that SQL query, for example, to the database.
So this is the kind of environment that we're talking about.
And what happens is that there is a vulnerability in
the web application itself.
This is web application, it's coded, it's software.
So, this is software vulnerability.
And SQL injection attacks, basically, exploit that vulnerability to
craft this injection attack that we're talking about.
So, just to make this idea of SQL injections concrete,
and the script and the web application and so on, let's do an example.
So, the example is the database that stores data about what is
shipped where and things like that.
It's a collection of the orders, for example,
that a company may have received.
Okay, orders that, whenever an order is placed, we create a tuple.
Of course, one piece of information or
attribute in that tuple is going to say where the item is going to be shipped.
And this is, let's say specified by the users.
User says, we're saving something, and I want it sent to the city.
The way the web application supports user attraction is maybe using a form.
And you fill the form with this needed information including the city that
we're talking about.
So, the user interacts with the form, fills in the various fields,
including the city that we have here.
And then, we said this web application now has to generate a query.
So the script code that generates the query
is included as sort of the example here.
So the code is going to be SQL query that we have to generate.
So the script basically is saying from the form you read the user input,
which is the city where we're going to ship a certain item.
So this statement shipcity is basically saying, from the form
you read this value and that's if you want to send it to New York, for
example, that's what we're going to have here.
Once we have that, we're saying generate the SQL query, okay, and code.
So, the query's going to say select everything from OrdersTable
where the attribute Shipcity is what this input is provided to us.
So we're going to add that.
We'll see the resulting query is actually going to be select* from
OrdersTable where Shipcity is, if you put New York City here,
it'll be shipcity = New York.
Okay, so that's an example.
I think the only thing that's important here is that the user,
the injection attack,
the way it is going to work is that somebody is going to provide bad input.
So we talked about buffer overflows through bad input before.
It's not quite the same, but it's kind of like that.
And injection is going to occur because of bad input.
So the idea here is that you are getting the input here from the user.
Based on that query, and
this query is what's going to be submitted to the database.