Introduction To Database Security: Chapter Objectives
Introduction To Database Security: Chapter Objectives
© Digital_Art/Shutterstock CHAPTER
8
© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning,
NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBU
© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC
Introduction to
NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION
❯ How and why data Database security involves protecting the database from unauthorized
access, modification, or destruction. Since the database represents an essential
encryption is performed
corporate resource, database security is an important subcomponent of
© Jones
❯ How & Bartlett
to protect Learning,
databases LLC © Jones & Bartlett Learning, LLC
against SQLSALE any organization’s overall information systems security plan. In addition
injectionOR DISTRIBUTION
NOT FOR NOT FOR SALE OR DISTRIBUTION
to the need to preserve and protect data for the smooth functioning of the
❯ How security is enforced
organization, database designers have a responsibility to protect the privacy
in some systems
of individuals about whom data is kept. Privacy is the right of individuals to
❯ How Internet security is
have some control over information about themselves. Many countries have
implemented
Jones & Bartlett Learning, LLC © Jones
laws designed to protect & every
privacy, and Bartlett Learning,
organization LLC
that collects and stores
OT FOR SALE OR DISTRIBUTION information about individuals NOT FOR SALE
is legally OR
obliged to DISTRIBUTION
adopt policies that conform
to local privacy legislation. The database design should reflect the organization’s
commitment to the protection of individual privacy rights by including only
those items that the organization has a right to know and keeping them secure.
The security of information typically follows the CIA model, where CIA
© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning,
stands for confidentiality, integrity, and availability. Confidentiality requires
NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBU
that only authorized users have access to information in order to preserve the
privacy of individuals, business intellectual property, and national security
efforts. With the growth of social media and online business due to the Internet,
maintaining confidentiality involves using appropriate encryption techniques
© Jones & Bartlett Learning, as well LLC © Jones
as user authorization, identification, & Bartlettprocedures.
and authentication Learning, LLC
NOT FOR SALE OR DISTRIBUTION Integrity requires that only authorizedNOT FOR
users be SALE
allowed OR data,
to modify DISTRIBUTION
thus
maintaining data consistency and trustworthiness. If data is incorrect, it is no
longer useful. Incorrect data can also be harmful to individuals (such as wrong
data on a credit report) and organizations (such as invalid financial reports).
Availability requires that information be accessible by authorized users when
Jones & Bartlett Learning, LLC © Jones
needed. Security attacks against an&organization
Bartlett can Learning, LLC
cause business services to
OT FOR SALE OR DISTRIBUTION become unavailable,NOT FOR SALE OR DISTRIBUTION
leading to violations of service level agreements that are
critical to business operations.
Some of the laws and standards requiring controls on access, disclosure,
and modification of sensitive data are:
© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning,
❯ The Federal Information Security Management Act (FISMA).
NOT FOR SALE FISMA
OR DISTRIBUTION NOT
requires federal agencies in the United States FOR SALE
to develop and OR DISTRIBU
implement an agency-wide information security plan in support of
federal operations.
❯ The European General Data Protection Regulation (GDPR).
© Jones & Bartlett Learning, Th
LLC © Jonesregulations
e GDPR establishes data protection & Bartlett Learning,
for all foreign LLC
NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR
companies that process data of European Union residents. DISTRIBUTION
❯ The © Jones
U.S. Health&Insurance
BartlettPortability
Learning, andLLCAccountability Act © Jones & Bartlett Learning,
NOT FOR SALE OR DISTRIBUTION
(HIPAA). HIPAA defines requirements for health care organizations NOT FOR SALE OR DISTRIBU
for maintaining security and privacy of patient data.
❯ The U.S. Sarbanes-Oxley (SOX) Act. SOX defines strict regulations
for financial reporting activities of publically traded companies.
© Jones❯ &
ThBartlett Learning, LLC
e U.S. Gramm-Leach-Bliley Act (GLBA). GLBA establishes© Jones
pro- & Bartlett Learning, LLC
NOT FORvisions
SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION
to ensure the protection of consumers’ financial information.
❯ The Worldwide Payment Card Industry Data Security Standard
(PCI DSS). PCI DSS defines a framework for secure processing of
consumer credit card information.
Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC
Violation of these practices and regulations can lead to fraud, financial
OT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION
losses, and severe penalties.
Security threats are events or situations that could harm the system by
compromising privacy or confidentiality, or by damaging the database itself. A
vulnerability is a weakness in a system, such as inappropriate access control or
loopholes in© Jones
firewall & Bartlett
protection, Learning,
that allows a threat to LLC
occur. Security threats © Jones & Bartlett Learning,
NOT
can occur either FOR SALE
accidentally OR DISTRIBUTION
or deliberately . Putting a database security plan NOT FOR SALE OR DISTRIBU
in place should include a risk assessment process that identifies threats and
vulnerabilities and establishes appropriate controls in the context of the CIA
model.
© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC
NOT8.1.1 Accidental
FOR SALE Security Threats
OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION
Some examples of accidental security violations are the following:
Access Control
In any organization, access control methods should be defined to restrict
© Jones & company
access to Bartlett Learning,
resources as well asLLC © control
employee and client data. Access Jones & Bartlett Learning, LLC
NOTisFOR SALE OR DISTRIBUTION NOT
a fundamental component in the support of confidentiality and integrity. FOR SALE OR DISTRIBUTION
Access control must be addressed in the context of physical security as well
as information system access control. To protect the information system, the
database administrator is responsible for the following major tasks:
Jones & Bartlett Learning, LLC
❯ Installing the ©and
database management system Jones & Bartlett
configuring it securelyLearning, LLC
OT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION
❯ Creating and securing user accounts and developing appropriate
access controls for users
❯ Developing and enforcing standards for applications programs that
access the database
© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning,
❯ Encrypting
NOT sensitive data
FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBU
❯ Ensuring that network connections to the data are secure
❯ Establishing appropriate audit mechanisms for the database
❯ Protecting the database against intruders by identifying and guarding
© Jones & Bartlett
against Learning,
security threats and LLC
applying security controls and©security
Jones & Bartlett Learning, LLC
NOT FORupdates
SALEasOR DISTRIBUTION
needed NOT FOR SALE OR DISTRIBUTION
OBJECT
Student
© Jones & Bartlett Learning, LLCWrapUp Faculty
©Enroll CREATE
Jones & Bartlett Learning, LLC
SUBJECT table StuView1 Procedure table table TABLE
NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION
User U101 READ, READ EXECUTE READ YES
UPDATE
. . . . . . . . . . . . . . . . . . . . .
FIGURE 8.2(B)
CREATE VIEW StuView1 AS
Value-independent
SELECT stuId, lastName, firstName, major View
Jones & Bartlett Learning,FROM
LLCStudent; © Jones & Bartlett Learning, LLC
OT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION
© Jones & Bartlett Learning, LLC 8.6 Encryption © Jones & Bartlett Learning, LLC
NOT FOR SALE OR DISTRIBUTION
To counter the possibility of havingNOT FOR SALE
files accessed directlyOR DISTRIBUTION
through the
operating system or having files stolen, data can be stored in the database
in encrypted form. Only the database management system can unscramble
the data, so that anyone who obtains data by any other means will receive
jumbled data. When authorized users access the information properly, the
Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC
DBMS retrieves the data and decodes it automatically. Encryption should
OT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION
also be used whenever data is communicated to other sites, so that wire
tappers will also receive scrambled data. Encryption requires a cipher
system, which consists of the following components:
© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC
NOT FOR SALE OR DISTRIBUTION DES
NOT FOR SALE OR DISTRIBUTION
Encryption
Algorithm
Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC
OT FOR SALE OR DISTRIBUTION 64-bit Block of
NOT FOR SALE OR DISTRIBUTION
Ciphertext
© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC
NOT FOR SALE OR DISTRIBUTION 64-bit Block of NOT FOR SALE OR DISTRIBUTION
Plaintext
© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC
Encryption
NOT FOR SALE OR DISTRIBUTION Algorithm NOT FOR SALE OR DISTRIBUTION
Using Public
Key p*q
Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC
OT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION
Ciphertext
© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC
NOT FOR SALE OR DISTRIBUTION Plaintext NOT FOR SALE OR DISTRIBUTION
user receives an encrypted message, he or she must produce the prime factors
Jones & Bartlett Learning,
of the public key LLC © Jones
to decode it. Since there is no quick method&ofBartlett
finding theLearning, LLC
OT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION
prime factors of a large number, it is difficult for an intruder to find these
factors. However, an intruder who is determined to break the key can do
so, provided he or she is willing to commit substantial resources to the task.
This method is only as secure as the private key, so users must be given their
private keys ©in some
Jonessecure
& fashion
BartlettandLearning,
must protect the
LLC private keys against © Jones & Bartlett Learning,
disclosure. One well-known method of public-key encryption is RSA, named
NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBU
for its developers, Rivest, Shamir, and Adleman.
Users U101, U102, and U103 would then be permitted to write SQL SELECT,
INSERT, and UPDATE statements for the Student table, and to pass that
© Jones & Bartlett Learning, LLCon to other users. Because©ofJones
permission &ofBartlett
the ability users withLearning,
the grant LLC
NOT FOR SALE OR DISTRIBUTION NOT
option to authorize other users, the system FOR
must keepSALE
track of OR DISTRIBUTION
authorizations
using a grant diagram, also called an authorization graph. FIGURE 8.6
shows an authorization graph. Here, the DBA, who (we assume) is the creator
DBA
© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC
NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION
U1 U2 U3
Jones & Bartlett Learning, LLC Student
SELECT © Jones
SELECT & Bartlett Learning,
Student
SELECT
Student
LLC
OT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION
© Jones
U21 & Bartlett Learning,
U22 LLC U23 © Jones
U24 & Bartlett Learning,
SELECT SELECT SELECT SELECT
NOT FOR SALE OR
Student DISTRIBUTION
Student Student NOT FOR SALE OR DISTRIBU
Student
© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC
NOT FOR SALE OR DISTRIBUTION U31 NOT FOR SALE OR DISTRIBUTION
SELECT
Student
Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC
OT FOR SALE ORof the schema, gave a specific privilege (for example,
DISTRIBUTION NOTtoFOR
use SELECT
SALEonOR
the DISTRIBUTION
Student table) WITH GRANT OPTION to users U1, U2, and U3. We will
use a double arrowhead to mean granting with grant option, and a single
arrowhead to mean without it. A solid outline for a node will mean that the
node has received the grant option, and a dashed outline will mean it has not.
© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning,
U1 passed along the privilege to U21 and U22, both without the grant option.
NOT FOR SALE OR DISTRIBUTION
U2 also passed the privilege to U22, this time with the grant option, and U22
NOT FOR SALE OR DISTRIBU
passed the privilege to U31, without the grant option. U3 authorized U23 and
U24, both without the grant option. Note that if we give a different privilege
to one of these users, we will need a new node to represent the new privilege.
© Jones & Bartlett
Each node Learning,
on the graph represents LLC
a combination of a privilege and©a Jones
user. & Bartlett Learning, LLC
NOT FOR SQLSALE
DCL includes the capability to create user roles. A role can be
OR DISTRIBUTION NOTthought
FOR SALE OR DISTRIBUTION
of as a set of operations that should be performed by an individual or a group
of individuals as part of a job. For example, in a university, advisors may need
For example,
© Jones & Bartlett for U101, toLLC
Learning, whom we previously granted©SELECT
Jones, INSERT,
& Bartlett Learning,
and UPDATE on Student
NOT FOR SALE OR DISTRIBUTION with the grant option, we could remove some
NOT FOR SALE OR DISTRIBU
privileges by writing this:
This revokes U101’s ability both to insert Student records and to authorize
© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC
others to insert Student records. We can revoke just the grant option,
NOT FOR SALE OR DISTRIBUTION
without revoking the insert, by writingNOT
this: FOR SALE OR DISTRIBUTION
© Jones
If an individual & Bartlett
has the grant option forLearning, LLCand the privilege
a certain privilege © Jones & Bartlett Learning,
NOT FOR SALE OR DISTRIBUTION
or the grant option on it is later revoked, all users who have received the NOT FOR SALE OR DISTRIBU
privilege from that individual have their privilege revoked as well. In this
way, revocations cascade, or trigger other revocations. If a user obtained the
same privilege from two authorizers, one of whom has authorization revoked,
the user
© Jones &still retains the
Bartlett privilege from
Learning, LLCthe other authorizer. Thus, if©theJones
DBA & Bartlett Learning, LLC
revoked the authorization
NOT FOR SALE OR DISTRIBUTION of user U1 in Figure 8.6, U21 would lose all privileges,
NOT FOR SALE OR DISTRIBUTION
but U22 would retain whatever privileges were received from U2. Since U22
has the grant option, user U21 could regain privileges from U22. In this way,
unscrupulous users could conspire to retain privileges despite attempts by the
DBA to revoke them. For this reason, the DBA should be very careful about
Jones & Bartlett Learning,
passing the grantLLC
option to others. If the RESTRICT© Jones
option is&specifi
Bartlett
ed, theLearning, LLC
OT FOR SALE OR DISTRIBUTION
system checks to see if there are any cascading NOT FORand
revocations SALEreturnsORan DISTRIBUTION
error if they exist, without executing the revoke statement. CASCADE is the
default. When a privilege is revoked, the authorization graph is modified by
removing the node(s) that lose their privileges.
© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning,
8.8 Security in Oracle
NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBU
Oracle provides robust security that goes far beyond the SQL authorization
language commands. There are many different ways to set up and manage
the security
© Jones of an Oracle
& Bartlett database installation
Learning, LLC besides the methods © discussed
Jones & Bartlett Learning, LLC
here.
NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION
8.8.1 Security Features
Security features include facilities for all the following activities:
❯ Management
Jones & Bartlett Learning, LLCof user accounts. User accounts
© Jones can be
&created,
BartlettuserLearning, LLC
rights
OT FOR SALE OR DISTRIBUTIONdefined, and password and profi le policies set up in several
NOT FOR SALE OR DISTRIBUTION
ways. Strong passwords can be enforced. User views, user privileges,
and roles can be used to limit user access to data.
❯ Authentication of users can be performed for the database from the
operating system level and from a network.
© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning,
❯ Application
NOT FOR security policies
SALE ORcan be set for all applications that
DISTRIBUTION NOT FOR SALE OR DISTRIBU
access the database.
❯ Privilege analysis allows the DBA to identify privileges that are being
used, track the source of the privileges, and identify privileges that
© Jones &areBartlett
not being Learning,
used. This information
LLC can be used to tighten©security.
Jones
& Bartlett Learning, LLC
NOT FOR❯ User
SALEsession
ORinformation for applications. Information such
DISTRIBUTION NOT as the
FOR SALE OR DISTRIBUTION
user name and location can be gathered automatically and used to
control the user’s access through an application.
© Jones
for specific jobs, a concept&called
Bartlett Learning,
separation of dutiesLLC
. To this end, there are © Jones & Bartlett Learning,
NOT FOR SALE OR DISTRIBUTION
six additional administrator accounts that should be opened and assigned NOT FOR SALE OR DISTRIBU
to administrators to be used for specific tasks. They are SYSDBA, SYSOPER,
SYSASM, SYSBACKUP, SYSDG, and SYSKM.
Privileges granted to database users can be object privileges or system
privileges
© Jones An object Learning,
& .Bartlett privilege is theLLC
right to perform an action using DML & Bartlett Learning, LLC
© Jones
commands on a table,
NOT FOR SALE OR DISTRIBUTION view, procedure, function, sequence, or package.
NOTThFOR e SALE OR DISTRIBUTION
creator of a schema automatically has all object privileges on all objects in the
schema and can grant the same object privileges to other users. For tables, the
privileges include SELECT, INSERT, UPDATE, DELETE, and REFERENCES, as
described in Section 8.7, but also ALTER (the right to use the ALTER TABLE
Jones & Bartlett Learning,
command) LLC (the right to use the CREATE
and INDEX © Jones & Bartlett
INDEX command). ForLearning, LLC
OT FOR SALE OR DISTRIBUTION
updatable views, privileges are SELECT, INSERT NOT FOR, and
, UPDATE SALE OR. DISTRIBUTION
DELETE
System privileges include the right to perform actions using DDL commands
on database data, schemas, tablespaces, or other Oracle resources, as well as
the right to create user accounts.
© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning,
8.8.3 Security
NOT FOR Tools
SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBU
Some of the tools the DBA can use to secure the database installation are
Oracle Database Configuration Assistant, Oracle Enterprise Manager,
SQL*Plus, and Oracle Net Manager. Oracle Enterprise Manager is an online
tool found
© Jones on the Oracle
& Bartlett Database LLC
Learning, Home page. On a Windows installation,
© Jones & Bartlett Learning, LLC
SQL*Plus can be found
NOT FOR SALE OR DISTRIBUTION in the Application Tools subdirectory
NOT of the
FOR SALE OR DISTRIBUTION
Ora home directory, and the two other tools within the Configuration
and Migration Tools subdirectory.
There©are
Jones
236 diff&erent
Bartlett
system Learning, LLC A list of system
privileges possible. © Jones & Bartlett Learning,
NOT FOR SALE OR DISTRIBUTION
privileges can be seen by writing the following SQL command: NOT FOR SALE OR DISTRIBU
SELECT name
FROM SYSTEM_PRIVILEGE_MAP;
System
© Jones & privileges
Bartlett can be given
Learning, LLCthrough SQL*Plus using ©
a GRANT
Jones & Bartlett Learning, LLC
NOT FORcommand
SALE OR of this form:
DISTRIBUTION NOT FOR SALE OR DISTRIBUTION
GRANT systemprivilege
TO username
[WITH ADMIN OPTION];
Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC
For example, we could allow U999 to create tables by writing:
OT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION
GRANT CREATE TABLE TO U999 WITH ADMIN OPTION;
Additionally, privileges that are object privileges on single tables can
be extended to become system privileges that extend to any table by
using the keyword ANY, as in:
© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning,
GRANT SELECT
NOT FORANY TABLE
SALE ORTODISTRIBUTION
U999; NOT FOR SALE OR DISTRIBU
The WITH ADMIN OPTION clause allows the user to pass the privilege
on to others.
but not:
Jones & Bartlett Learning, LLC SELECT Salary© Jones & Bartlett Learning, LLC
OT FOR SALE OR DISTRIBUTION FROM EmployeeNOT FOR SALE OR DISTRIBUTION
WHERE empId = 'E101';
SELECT SUM(Salary)
© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC
FROM Employee
NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION
WHERE Dept = 10 AND jobTitle = 'Programmer' AND
dateHired > '01-Jan-2015';
The system can be modified to refuse to answer any query for which only one
Jones & Bartlett Learning, LLC record satisfies the predicate.
© JonesHowever, this restriction
& Bartlett Learning, is easily
LLC overcome,
since the user can ask for total salaries for the department and then ask for
OT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION
the total salary without that of E101. Neither of these queries is limited to
one record, but the user can easily deduce the salary of employee E101 from
them. To prevent users from deducing information about individuals, the
system can restrict queries by requiring that the number of records satisfying
© Jones & Bartlett Learning,
the predicate LLC
must be above some threshold and that the© Jones
number & Bartlett Learning,
of records
satisfying a pair of queries simultaneously cannot exceed some limit. ItSALE
NOT FOR SALE OR DISTRIBUTION NOT FOR can OR DISTRIBU
also disallow sets of queries that repeatedly involve the same records.
© Jones
to the fact that user input&from
Bartlett Learning,
a client through LLC interface can
the application © Jones & Bartlett Learning,
NOT FOR SALE OR DISTRIBUTION
be designed to take advantage of vulnerabilities associated with the dynamic NOT FOR SALE OR DISTRIBU
construction of SQL queries. Using SQL injection, an attacker can insert
(or inject) code into a query that can be used to retrieve information that
the attacker is not authorized to see, maliciously delete or modify data, or
insert data
© Jones that wouldLearning,
& Bartlett give an attacker
LLC unauthorized access to the ©
database.
Jones & Bartlett Learning, LLC
SQL injection was fi
NOT FOR SALE OR DISTRIBUTION rst discovered around 1998 and is now ranked
NOT FORas SALE OR DISTRIBUTION
a top software security concern by the Open Web Application Security
Project and by the Common Weakness Enumeration/SANS Top 25 Most
Dangerous Software Errors. SQL injection poses threats to confidentiality,
integrity, availability, authentication, and authorization.
Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC
OT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION
8.10.1 Examples of SQL Injection
SQL injection takes advantage of the fact that SQL queries can be dynamically
constructed in application code. As an example, consider a Web form that
allows a student to enter &
© Jones hisBartlett
or her identifier and password
Learning, LLCinto the variables © Jones & Bartlett Learning,
userID and password. The website then uses this information to retrieve
NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBU
the student’s confidential information from the Student table. Inside of
the application code, the query can be constructed dynamically through the
following statement:
Even with an incorrect userID and password, this query will always
© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning,
evaluate to true because the or condition will always be satisfied.
NOT FOR SALE OR DISTRIBUTION
Furthermore, NOTbelow,
the query will essentially evaluate as the query FORwhich
SALE OR DISTRIBU
returns information about all students:
SELECT *
FROM
© Jones & Bartlett Learning, student
LLC © Jones & Bartlett Learning, LLC
NOT FOR SALE OR DISTRIBUTION
WHERE 'a'='a'; NOT FOR SALE OR DISTRIBUTION
Since some database products allow the execution of multiple SQL
statements separated by semicolons within a single query string, attackers
can also take advantage of this vulnerability together with single quotes in
Jones & Bartlett Learning, LLC input values to enter©additional
Jones malicious
& Bartlett Learning,
statements. LLCthis type
To illustrate
OT FOR SALE OR DISTRIBUTION of attack, assume theNOT
attacker
FORentersSALE
the value
OR X asDISTRIBUTION
the userID and the value
Y' or 'a'='a'; DELETE * FROM student; -- as the password. In
this case, the query becomes:
SELECT *
© Jones & Bartlett Learning, LLC
FROM student © Jones & Bartlett Learning,
NOT FOR SALE OR DISTRIBUTION
WHERE userID = 'X' AND password = 'Y' ORNOT FOR SALE OR DISTRIBU
'a'='a';
DELETE * FROM student;
--';
Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC
8.11 Database Security and
OT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION
the Internet
Unless security software is used, all messages sent over the Internet are
© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning,
transmitted in plaintext and can be detected by intruders using packet
NOT FOR SALE OR DISTRIBUTION
sniffing software. Both senders and receivers need to be confident that
NOT FOR SALE OR DISTRIBU
their communications are kept private. Obviously, customers who wish to
purchase products need to have assurance that their credit card information
is secure when they send it over the Internet. Companies that allow Web
© Jones & Bartlett
connections to theirLearning, LLCfor access to their database
internal networks ©need
Jones
to & Bartlett Learning, LLC
NOT be
FOR SALE
able to protectOR DISTRIBUTION
it from NOT
attack. Receivers of messages need to have waysFOR
to SALE OR DISTRIBUTION
be sure that those messages are genuine and trustworthy and have not been
tampered with. Senders of messages should not be able to repudiate them,
8.11.1
© Jones & Bartlett Learning, LLCProxy Servers © Jones & Bartlett Learning, LLC
NOT FOR SALE OR DISTRIBUTION NOT FOR
A proxy server is a computer or program SALE
that acts as an OR DISTRIBUTION
intermediary
between a client and another server, handling messages in both directions.
When the client requests a service such as a connection or Web page, the
proxy evaluates it and determines whether it can fulfill the request itself. If
not, it filters the request, perhaps altering it, and requests the service from
Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC
the server or other resource. It may cache (store a copy of) the server’s
OT FOR SALE OR DISTRIBUTION response so that a subsequent
NOT FOR SALE OR DISTRIBUTION
request can be fulfilled from the stored content
without using the server again. The proxy server can be used for several
purposes, including to maintain security by hiding the actual IP address of
the server, to improve performance by caching, to prevent access to sites that
© Jones & Bartlett Learning,
an organization wishes to LLC © Jones
block from its members, to protect the server&from
Bartlett Learning,
NOT FOR SALE
malware, OR andDISTRIBUTION NOTforFOR
to protect data by scanning outbound messages SALE OR DISTRIBU
data leaks.
8.11.2 Firewalls
A firewall is a hardware and/or software barrier that is used to protect an
organization’s
© Jones & Bartlett Learning, LLC internal network (intranet) from unauthorized
© Jones & Bartlettaccess. Various
Learning, LLC
techniques are used to ensure that messages entering or leaving the intranet
NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION
comply with the organization’s standards. For example, a proxy server can
be used to hide the actual network address. Another technique is a packet
filter, which examines each packet of information before it enters or leaves
the intranet, making sure it complies with a set of rules. Various gateway
Jones & Bartlett Learning, LLC techniques can apply©security
Jones & Bartlett
mechanisms Learning,
to applications LLC
or connections.
OT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION
8.11.3 Digital Signatures
Digital signatures use a double form of public-key encryption to create secure
two-way communications that cannot be repudiated. A digital signature allows
a user to verify the authenticity of the person they are communicating with,
© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning,
and provides a means to prove that a message must have come from that person
NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBU
and that it has not been tampered with in transmission. One method of using
digital signatures is for the sender to encode a message first with his or her own
private key, and then with the public key of the receiver. The receiver decrypts
the message first using his or her private key, and then uses the sender’s public
© Jones & Bartlett Learning,
key. TheLLC
double encryption ensures that© Jones
both & authentic,
parties are Bartlettsince
Learning,
neither LLC
NOT FOR SALE OR DISTRIBUTION
one could have encoded or decoded theNOT messageFOR SALE
without ORprivate
his or her DISTRIBUTION
key.
It also ensures that the message is intact, since tampering would invalidate the
signature, making it impossible to decode the message.
© Digital_Art/Shutterstock
8.12 Chapter Summary © Digital_Art/Shutterstock
© Digital_Art/Shutterstock
view created in (b). Give that role to all clerks in the dean’s office,
which includes users 202, 203, 204, and 205.
d. Give permission to user 206, an assistant dean, to read and
© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC
modify (insert, delete, update) the Faculty and Class tables.
NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION
This user can authorize others to read and modify Class but not
Faculty.
e. User 206 authorizes user 300 to read Class. Write the command
to do this.
Jones & Bartlett Learning, LLC f. Create an©authorization
Jones & Bartlett Learning,
graph showing LLC given
all the privileges
OT FOR SALE OR DISTRIBUTION NOT
so far. You FORa SALE
will need separateOR nodeDISTRIBUTION
for each combination of
privilege and user.
g. Revoke the authorization privilege that the assistant dean was
given in (d), but keep his or her own reading and modification
privileges. How would you show this change on the authorization
© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning,
graph?
NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBU
h. Give permission to the Registrar, user 500, to read and modify
Student, Class, and Enroll, and to grant those rights to
others.
i. For all academic advisors, give permission to read all Class
© Jones & Bartlett Learning, LLC © Jones
records. For the advisor in the & Bartlett
Math department, Learning, LLC
give permission
NOT FOR SALE OR DISTRIBUTION to read the Student records NOTof students
FOR SALE majoring ORin Math and
DISTRIBUTION
to modify Enroll records for these students.
8.2 Assume you have a statistical database with the following schema.
The only legal queries are those involving COUNT, SUM, and AVERAGE.
newFaculty(facId, lastName, firstName, department,
Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC
salary, rank, dateHired)
OT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION
a. Write a legal SQL query to find the salary of the only faculty
member who is an instructor in the Art department.
b. Assume the system will refuse to answer queries for which only
one record satisfies the predicate as in (a). Write a legal set of
© Jones & Bartlett queries
Learning, LLC the user to deduce the©salary
that allows Jones & Bartlett
of the Art Learning,
NOT FOR SALE ORinstructor.
DISTRIBUTION NOT FOR SALE OR DISTRIBU
c. Assume that there are 10 faculty members in the Art department.
The system refuses to answer queries where the number of
records satisfying the query is less than six. It will also refuse to
© Jones & Bartlett Learning, LLCanswer pairs of queries where the number
© Jones of recordsLearning,
& Bartlett satisfying LLC
NOT FOR SALE OR DISTRIBUTION them simultaneously exceeds three. Would these
NOT FOR SALE OR DISTRIBUTION restrictions
make your query for (a) or (b) illegal? If so, is there another legal
instructor?
8.3 a. Using the University schema shown in Exercise 8.1, write an SQL
statement to create a value-dependent view of Student that
© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC
includes only seniors.
NOT FORb.SALE OR DISTRIBUTION
Write an SQL statement for a value-independent view of
NOT FOR SALE OR DISTRIBUTION
Faculty. Do not include the whole table.
c. Write a statement to authorize user 125 to read both views.
8.4 Write a trigger to create an audit trail that will track all updates to the
Jones & Bartlett Learning,
salary fieldLLC
of the newFaculty table shown © Jones
in Exercise&8.2.
Bartlett Learning, LLC
OT FOR SALE OR
8.5 DISTRIBUTION NOT
Log on to an e-commerce website, such as FOR
that of SALE
a large OR DISTRIBUTION
bookseller.
Locate and read the information provided about security of online
transactions. Determine whether SSL or some other secure protocol is
used. If possible, display and print the information about the Verisign
certificate for the site.
© Jones You may find
& Bartlett this in the options
Learning, LLC in your browser. © Jones & Bartlett Learning,
8.6 NOT
Examine theFOR SALE
security ORinDISTRIBUTION
features Microsoft Access by reading the NOT FOR SALE OR DISTRIBU
online Help on the topic. Then do the following:
a. Print the list of trusted publishers, locations, and documents for
your computer.
© Jones &b.Bartlett Learning,
Open an Access databaseLLC
you created and encrypt the © Jones & Bartlett Learning, LLC
database
with a password.
NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION
c. Sign your database and package it for distribution.
8.7
SQL injection is often used to exploit a database. It refers to the process
of using SQL injection to read sensitive data, modify a database, or
execute administrative operations on a database. In preparation
Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC
for an SQL injection exploitation, attackers often use SQL injection
OT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION
to discover information about the database. Investigate how SQL
injection can be used to discover information about a database. In
particular, how can SQL injection be used to discover information
such as field names, table names, or even email addresses?
8.8 © Jones
Building & Bartlett
on Exercise 8.7, assumeLearning,
you haveLLC discovered that the © Jones & Bartlett Learning,
NOT FOR SALE OR DISTRIBUTION
Student table contains the fields studentID, email, userID, NOT FOR SALE OR DISTRIBU
password, firstName, and lastName. Using the SELECT
statement from Section 8.10.1, which selects students based on their
userID and password:
© Jones &a.Bartlett
Show howLearning,
SQL injectionLLC © Jones
can be used to insert a new student into & Bartlett Learning, LLC
NOT FOR SALE OR DISTRIBUTION
the Student NOT
table. What values have to be input for the FOR SALE OR DISTRIBUTION
userID
and password to get the INSERT statement to execute?
© Digital_Art/Shutterstock
new user might fail?
c. If you know a student’s email address, show how SQL injection
can be used to change the email address to your email address.
© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC
d. Assuming you are successful at changing the student’s email
NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION
address, how can you then get access to the student’s password?
HINT: On most Web pages, how do you get your own password
when you don’t remember it?
Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC
OT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION
© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC
NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION
Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC
OT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION
© Jones & Bartlett Learning, LLC © Jones & Bartlett Learning, LLC
NOT FOR SALE OR DISTRIBUTION NOT FOR SALE OR DISTRIBUTION