UNIT - II - Database Security and Privacy
UNIT - II - Database Security and Privacy
Introduction
Authentication and Authorization are essential services for
every OS
Another service is Administration of Users
Administrators use this functionality
• Creating users
• Set Password Policies
• Grant privileges
5
Documentation of User Administration
Administration Policies
Documentation includes all policies for handling new and terminated employees,
managers, system and database administrator, database managers, operation
managers, and human resources.
A detailed document should describe guidelines for every task that is required for
all common administrative situations.
Security Procedures
This is an outline of a step-by-step process for performing administrative task
according to company policies.
This provides the full description of all predefined roles, outlining all
tasks for which the role is responsible and the role’s relationship to other
roles
9
Documentation of User Administration …
Many companies develop procedures and forms used to perform any security-related
process. The following figure presents a sample process of creating a database user account
that you can customize per your business requirements and company policies.
Document Completion
DBA Completes all the paper work and documentation for new employees
DBA provides list of access operations that are necessary for employees to
Access Identification perform their jobs
Account application
Completion DBA completes the database user account application form
10
Creating users
13
Creating users …
user
Specify the name of the user to be created. This name can contain only characters from
your database character set and must follow the rules described in the section
"Schema Object Naming Rules". Oracle recommends that the user name contain at least
one single-byte character regardless of whether the database character set also contains
multibyte characters.
IDENTIFIED Clause
The IDENTIFIED clause lets you indicate how Oracle Database authenticates the user.
BY password
The BY password clause lets you creates a local user and indicates that the user must
specify password to log on to the database. Passwords are case sensitive. Any
subsequent CONNECT string used to connect this user to the database must specify the
password using the same case (upper, lower, or mixed) that is used in
this CREATE USER statement or a subsequent ALTER USER statement. Passwords can
contain any single-byte, multibyte, or special characters, or any combination of these,
from your database character set
EXTERNALLY Clause
Specify EXTERNALLY to create an external user. Such a user must be authenticated by
an external service, such as an operating system or a third-party service. In this case,
Oracle Database relies on authentication by the operating system or third-party service to
ensure that a specific external user has access to a specific database user.
14
Creating users …
AS 'certificate_DN'
This clause is required for and used for SSL-authenticated external users only.
The certificate_DN is the distinguished name in the user's PKI certificate in the user's wallet.
GLOBALLY Clause
The GLOBALLY clause lets you create a global user. Such a user must be authorized by the
enterprise directory service (Oracle Internet Directory).
Specify the default tablespace for objects that the user creates. If you omit this clause, then
the user's objects are stored in the database default tablespace. If no default tablespace has
been specified for the database, then the user's objects are stored in the SYSTEM tablespace.
15
Creating users …
Specify the tablespace or tablespace group for the user's temporary segments. If you omit this
clause, then the user's temporary segments are stored in the database default temporary
Specify tablespace_group_name to indicate that the user can save temporary segments in any
The tablespace must be a temporary tablespace and must have a standard block size.
space management.
16
Creating users …
QUOTA Clause
Use the QUOTA clause to specify the maximum amount of space the user can
allocate in the tablespace.
A CREATE USER statement can have multiple QUOTA clauses for multiple
tablespaces.
UNLIMITED lets the user allocate space in the tablespace without bound.
Restriction on the QUOTA Clause You cannot specify this clause for a
temporary tablespace.
PASSWORD EXPIRE Clause
Specify PASSWORD EXPIRE if you want the user's password to expire. This
setting forces the user or the DBA to change the password before the user can
log in to the database.
ACCOUNT Clause
Specify ACCOUNT LOCK to lock the user's account and disable access.
Specify ACCOUNT UNLOCK to unlock the user's account and enable access to
the account.
17
Creating users …
Once the user is created you can modify a user account with an
ALTER USER statement using clause listed in the previous
example
18
DBA_USERS View
DBA_USERS describes all users of the database.
19
DBA_USERS View …
20
DBA_USERS View …
21
22
23
24
25
26
27
28
Global – all details at central oracle security server
External - OS
29
30
31
32
33
34
35
36
37
38
39
40
Creating a SQL Server User
41
Creating a SQL Server User …
Creating Windows integrated Logins
The login syntax is the fully qualified name of the Windows user account in
the form of machine_name\user_name for local Windows users.
Windows integrated login can also be associated can also be associated with
windows groups on either the local server or domain 42
Creating a SQL Server User …
For example,
43
Creating a SQL Server User from Enterprise Manager
To create a new login associated with a Windows account (Windows Integrated) in Enterprise Manager,
take the following steps
44
SQL Server Login …
2. Expand the server group in which your server is functioning
5. Click Logins
45
SQL Server Login …
9. Select the default database for the login from the Database
drop-down list.
10. Select the default language for the login from the language
drop-down list.
46
SQL Server Login …
11. Click OK
47
SQL Server Login …
48
SQL Server Login …
49
SQL Server Login …
The second type of login is a SQL Server Login, sometimes called a SQL Server
active login.
This login associated with a windows account, instead , it is a security account
created within SQL Server itself.
Creating SQL Server Logins from command line
To create a SQL Server login from the Query analyzer , you use the
SP_ADDLOGIN system stored procedure.
The syntax is as follows :
For example
To create a SQL Server login named ‘bmnantha’ with password ‘siva’ you
issue the following command
51
SQL Server Login …
52
SQL Server Login …
The following figure gives the Server login properties – new login screen (Latest Version)
53
Removing Users
Removing an ORACLE User
If the user does not have any objects , the command is successfully executed. If the user own any objects
CASECADE option should be used
To change the default database to the login mydomain\bmnantha , issue the following
statement
55
Default Users
SQL server default users, will be created at the time of SQL Server
software installation
56
Remote Users
All the DB user accounts are created and stored in the DB regardless of
whether they are connected locally or remotely.
SQL Server does not support this type of remote user authentication.
57
Database Links
It is a connection from one DB to another DB
The linked DBs can be like
Both be ORACLE10g
Both be SQL Server
Mix of ORACLE10g and SQL Server
A DB link enables a user to perform Data Manipulation Language (DML) or
any other valid SQL statements on a DB.
The following figure gives the architecture of DB Link
60
Database Links
61
Linked Servers
Linked serves allow you to connect to almost any object Linking Embedding
Database (OLEDB) or Open Database Connectivity .
Microsoft SQL Server 2000 also uses the concept of linked serves.
OLEDB is a Microsoft component that allows Windows applications to connect
and access different database systems.
ODBC is a Microsoft protocol used for connecting Windows applications to
different DB systems
The following figure represents the Linked server architecture using SQL
Server
Linked Server
62
Linked Server …
Creating a new linked server with SQL Server
63
Remote Servers
Along the same line as Linked Servers , you can communicate with
another SQL server by creating remote server
64
Best Practices for Administrators and Managers
Always change the default password and never write it, or save it in a file that
neither encrypted nor safe.
Never share the user accounts with anyone , especially DBA accounts.
Always document and create logs for changes to removals of database user
accounts.
65
Best Practices for Administrators and Managers …
These are the best practices for administrating users, privileges , and
roles…
Give access permission to users only as required and use different logins and
passwords for different applications.
Keep abreast (up-to date) of database and security technology. Should be aware
of all new vulnerabilities that may increase database security risks.
68
Defining and Using Profiles…
Creating Profiles in ORACLE
A profile in ORACLE helps define two elements of Security
1. Restrictions on Resources
2. Implementation of password policy
The following figure shows the two aspects of a profile in ORACLE
PROFILE
PASSWORD RESOURCES
Aging CPU
Usage Memory
Verification Connections
69
Defining and Using Profiles…
Create profile
70
Defining and Using Profiles…
CREATE PROFILE Profile_name
LIMIT
SESSIONS_PER_USER number
CPU_PER_SESSION hunderth of seconds
Resource Limits CPU_PER_CALL hunderth of seconds
CONNECT_TIME UNLIMITED minutes
IDLE_TIME minutes
LOGICAL_READS_PER_SESSION DEFAULT db_blocks
LOGICAL_READS_PER_CALL DEFAULT db blocks
COMPOSITE_LIMIT DEFAULT number
PRIVATE_SGA bytes
FAILED_LOGIN_ATTEMPTS number
PASSWORD_LIFE_TIME days
Password Limits
PASSWORD_REUSE_TIME number
PASSWORD_REUSE_MAX number
PASSWORD_LOCK_TIME days
PASSWORD_GRACE_TIME days
PASSWORD_VERIFY_FUNCTION function_name;
71
Defining and Using Profiles…
In this syntax:
First, specify the name of the profile that you want to create.
Second, specify the LIMIT on either database resources or password
Resource Parameters
SESSIONS_PER_USER – specify the number of concurrent sessions that a user can have when
connecting to the Oracle database.
CPU_PER_SESSION – specify the CPU time limit for a user session, represented in hundredth of
seconds. (1 hundredth of a second corresponds to 0.01 seconds or 1 second corresponds to 100
hundredths of a second)
CPU_PER_CALL – specify the CPU time limit for a call such as a parse, execute, or fetch,
expressed in hundredths of seconds.
CONNECT_TIME – specify the total elapsed time limit (execution time) for a user session,
expressed in minutes.
IDLE_TIME – specify the number of minutes allowed periods of continuous inactive time during
a user session. Note that the long-running queries and other operations will not subject to this
limit.
LOGICAL_READS_PER_SESSION – specify the allowed number of data blocks read in a user
session, including blocks read from both memory and disk.
LOGICAL_READS_PER_CALL – specify the allowed number of data blocks read for a call to
process a SQL statement.
PRIVATE_SGA – specify the amount of private memory space that a session can allocate in the
shared pool of the System Global Area (SGA). A system global area (SGA) is a group of shared
memory structures that contain data and control information for one Oracle database instance.
COMPOSITE_LIMIT – specify the total resource cost for a session, expressed in service units. The
total service units are calculated as a weighted sum of CPU_PER_SESSION
CONNECT_TIME, LOGICAL_READS_PER_SESSION, and PRIVATE_SGA.
Defining and Using Profiles…
Password_parameters
You use the following clauses to set the limits for password parameters:
FAILED_LOGIN_ATTEMPTS – Specify the number of consecutive failed login
attempts before the user is locked. The default is 10 times.
PASSWORD_LIFE_TIME – specify the number of days that a user can use the same
password for authentication. The default value is 180 days.
PASSWORD_REUSE_TIME – specify the number of days before a user can reuse a
password.
PASSWORD_REUSE_MAX – specify the number of password changes required before
the current password can be reused. Note that you must set values for
both PASSWORD_REUSE_TIME and PASSWORD_REUSE_MAX parameters make
these parameters take effect.
PASSWORD_LOCK_TIME – specify the number of days that Oracle will lock an
account after a specified number of a consecutive failed login. The default is 1 day if
you omit this clause.
PASSWORD_GRACE_TIME – specify the number of days after the grace period starts
during which a warning is issued and login is allowed. The default is 7 days when you
omit this clause.
Note that to create a new profile, your user needs to have the CREATE PROFILE system
privilege.
73
Defining and Using Profiles…
74
Defining and Using Profiles…
To view all profiles created in the database , query the data dictionary view,
DBA_PROFILES
In SQL Server 2000 or 2005 profiles of similar objects are not available
76
Designing and Implementing password policies
The stronger the password, the longer it takes a hacker to break it.
77
Designing and Implementing password policies …
Password policy is a set of guidelines that enhances the robustness of
the password and reduces the likelihood of its being broken
79
Designing and Implementing password policies …
80
Designing and Implementing password policies …
81
Designing and Implementing password policies …
83
Designing and Implementing password policies …
Microsoft SQL Server 2000 as a stand-alone product, does not provide for password policy
enforcement when logging on a SQL Server
In this method all the server applications and the resources they provide are tightly integrated
with the Windows server system and its security architecture.
Password policy enforcement in a SQL Server environment handled by implementing SQL server
in Windows authentication mode and applying polices within the Windows Server System
84
Designing and Implementing password policies …
When the user attempt to access a resource , the server hosting the resource
“challenges” , user to prove his / her identity.
The server goes through an authorization process for the requested resource.
85
Designing and Implementing password policies …
Authentication process consists of three messages
Message 1 : Sent from the client to the server and is the initial request for authentication
Message 2 : Sent from the server to client, contains challenge ( Eight bytes of Random
Data)
Message 3 : Sent from client to server , contains response to the challenge
Workstation Server
Message 1
Message 2
Message 3
The response is a 24-byte DES encrypted hash of the 8 byte challenge that can be decrypted
only by a set of DES keys created using the user’s password.
The benefit to NTLM is that password are verified without ever actually sending the
password across the Web
86
Designing and Implementing password policies …
Kerberos
Instead of using password encrypt / decrypt challenge / response messages, a secret key,
known only to the server and client and also unique to the session, used to encrypt the
handshake data.
This allows not only for the server to validate the authenticity of client , but for the client to
validate the authenticity of the server.
This is an important difference and is one the reason Kerberos is more secure than NTLM
Kerberos authentication requires a trusted third resource known as Key Distribution Center
(KDC).
The KDC generates the secret key for each session established.
The new session ticket , containing the new key, has a time-out value associated with it.
87
Designing and Implementing password policies …
The client encrypts its request for a resource with the secret key.
The server decrypts the message using the same key, decrypts just
on time stamp on the message and send back to client.
This tells the server and the client has the same key for the session
which is established.
88
Designing and Implementing password policies …
The following figures explain the authentication process in Kerberos
Workstation Server
Clients wants to access a Server
KDC issues key : Kclient {Scs for Server} , ticket = Kserver {Scs for Client}
Workstation Server
Scs { Client Credentials , time}, ticket = Kserver { Scs for Client }
Scs { time }
89
Granting and Revoking User Privileges
Privileges in ORACLE
90
Granting and Revoking User Privileges …
System Privileges :
There are more than 100
system privileges in ORACLE ,
these are some important
frequently used privileges Object Privileges:
All DML are come
CREATE USER into object privileges
CREATE SESSION
CREATE ROLE INSERT
CREATE PROCEDURE UPDATE
CREATE TRIGGER DELETE
CREATE TABLESPACE SELECT
INDEX
CREATE TYPE
REFERENCES
CREATE DATABASE LINK
CREATE TABLE
CREATE VIEW
CREATE SEQUENCE
DROP VIEW
DROP USER
DROP TABLE
91
Granting and Revoking User Privileges …
SQL GRANT Command
SQL GRANT is a command used to provide access or privileges on
the database objects to the users.
The Syntax for the GRANT command is:
GRANT privilege_name ON object_name TO {user_name |PUBLIC
|role_name} [WITH GRANT OPTION];
privilege_name is the access right or privilege granted to the user. Some of the access rights
are ALL, EXECUTE, and SELECT.
object_name is the name of an database object like TABLE, VIEW, STORED PROC and
SEQUENCE.
user_name is the name of the user to whom an access right is being granted.
PUBLIC is used to grant access rights to all users.
ROLES are a set of privileges grouped together.
WITH GRANT OPTION - allows a user to grant access rights to other users.
Eaxmple :
SQL > GRANT select on emp to sivas;
Grant succeeded
The schema owner of emp object gave select privilege to user sivas
92
Granting and Revoking User Privileges …
The schema owner of emp object get back the select privilege to user
sivas
93
Granting and Revoking User Privileges …
94
Granting and Revoking User Privileges …
95
Granting and Revoking User Privileges …
CREATE VIEW
CREATE PROCEDURE
CREATE FUNCTION
CREATE DEFAULT
CREATE ROLE
BACKUP DATABASE
BACKUP LOG
97
Granting and Revoking User Privileges …
98
Creating , Assigning and Revoking User Roles
99
Creating , Assigning and Revoking User Roles
Creating role with ORACLE
NOT IDENTIFIED Clause - Specify NOT IDENTIFIED to indicate that this role is
authorized by the database and that no password is
required to enable the role.
100
Creating , Assigning and Revoking User Roles …
Creating role with ORACLE – Example
Users who are subsequently granted the dw_manager role will inherit all of the
privileges that have been granted to this role.
Users who are subsequently granted the dw_manager role must specify the
password warehouse to enable the role with the SET ROLE statement.
CREATE
The following ROLE warehouse_user
statement creates the sameIDENTIFIED EXTERNALLY;
role as an external role:
101
Creating , Assigning and Revoking User Roles …
Grant succeeded
Grant succeeded
102
Creating , Assigning and Revoking User Roles …
use northwind
exec sp_addrole ‘sales’
103
Creating , Assigning and Revoking User Roles …
Example : To drop the user ‘bm_nantha’ from the role sales, issue the following
statement
use northwind
exec sp_droprolemember ‘sales’ , ‘sivas’
104
Creating , Assigning and Revoking User Roles
Best Practices
Never store passwords in plain text, make sure it is encrypted
Change passwords frequently
Make sure the passwords are complex
Pick password that you can remember
Use roles to control administer privileges
Should report the compromise or loss of password security
Should report to security any violation of company guidelines like roles, profiles,
privileges, passwords, etc.,
Never give / share the password
Never give the password over the phone
Never type your password in an e-mail
Use Windows integrated security mode for securing SQL Server
Use Kerberos
When Configuring Policies:
Require complex passwords , Set an account lockout threshold Do not allow
passwords to automatically reset , Expire end-user passwords , Enforce password
history
105
References :
2) Charu C. Aggarwal, Philip S Yu, “Privacy Preserving Data Mining”: Models and
Algorithms, Kluwer Academic Publishers, 2008
3) Ron Ben Natan, ”Implementing Database Security and Auditing”, Elsevier Digital
Press, 2005.
106