Database Security Tutorial: Oracle Tutorials, June 4 2012
Database Security Tutorial: Oracle Tutorials, June 4 2012
tutorial
Part I
Oracle Tutorials, June 4th 2012
CERN IT Department
CH-1211 Geneva 23
Switzerland
www.cern.ch/it
Agenda
• Authentication
• Roles and privileges
• Auditing
CERN IT Department
CH-1211 Geneva 23
Switzerland 2
www.cern.ch/it
Authentication
• Basis of any security model
• Process of confirming the correctness of the claimed identity
• User account
– Unique username (associated schema)
– Authentication method (password, global or external)
– Default and temporary tablespaces
– User profile
– Account status
• Predefined administrative accounts
– SYS
– SYSTEM
– DBSNMP
– SYSMAN
• Least privilege principle
• Syntax
CREATE USER username IDENTIFIED BY user_password
CERN IT Department
DEFAULT TABLESPACE tblspc QUOTA 10M ON tblspc
CH-1211 Geneva 23 TEMPORARY TABLESPACE tmpspc QUOTA 5M on tmpspc
Switzerland 3
www.cern.ch/it PROFILE sec_prof PASSWORD EXPIRE;
Authentication: passwords
• Often far too easy to crack (default, empty, simple)
• Do
– Use mixed-case letters
– Use numbers
– Use punctuation marks
– At least 8 characters
• Don’t
– Use same password all over the place
– Use username as password or any permutation
– Use dictionary words
– Use easily obtained information
– Use dates
• Password checking tools
– Oracle Auditing Tool (OAT) – Oracle Password Guesser
• http://www.vulnerabilityassessment.co.uk/oat.htm
– Oracle Password Cracker by Pete Finnigan
• http://www.petefinnigan.com/oracle_password_cracker.htm
CERN IT Department
CH-1211 Geneva 23
Switzerland
• Enforce use of password profiles and account lockouts 4
www.cern.ch/it
Authentication: profiles
• Profiles impose limits on DB usage and manage account status and
password management rules
• Account locking
– FAILED_LOGIN_ATTEMPS
– PASSWORD_LOCK_TIME
• Password aging and expiration
– PASSWORD_LIFE_TIME
– PASSWORD_GRACE_TIME
• Password history
– PASSWORD_REUSE_TIME
– PASSWORD_REUSE_MAX
• Password complexity verification
– PASSWORD_VERIFY_FUNCTION
• Syntax
CREATE PROFILE sec_prof LIMIT
FAILED_LOGIN_ATTEMPS 5;
ALTER USER username PROFILE secprof;
CERN IT Department
CH-1211 Geneva 23
Switzerland 5
www.cern.ch/it
Roles and privileges: privileges
• Object privileges
– Enable users to access and manipulate a specific object
– GRANT <object_privilege> ON <object> TO <grantee_clause> [WITH
GRANT OPTION]
– REVOKE <object_privilege> FROM <grantee_clause>
CERN IT Department
CH-1211 Geneva 23
Switzerland 6
www.cern.ch/it
Roles and privileges: revoking privileges
Privilege
Object
Privilege
Object
CERN IT Department
CH-1211 Geneva 23
Switzerland 7
www.cern.ch/it
Roles and privileges: roles
• A role is a named group of related privileges that are granted
to users or to other roles
• Privileges granted to and revoked from roles as users
GRANT <privilege> TO <role> [WITH ADMIN/GRANT OPTION]
1 Enable auditing
DBA Parameter User
file
Execute command
Database
2 Specify audit options
Server
Audit process
options
CERN IT Department
CH-1211 Geneva 23
Switzerland 11
www.cern.ch/it
Auditing: FGA
• Fine-Grained Auditing (FGA)
– Data access monitoring base on content
– Audits SELECT, INSERT, UPDATE, DELETE and MERGE
– Can be set to audit specific columns
– May execute procedures
– Administered with DBMS_FGA package
• An FGA policy defines the audit criteria and action
dbms_fga.add_policy (
object_schema => 'schema',
object_name => 'table',
policy_name => 'audit_example',
audit_condition => 'id=10',
audit_column => 'column_name',
handler_schema => 'secure',
handler_module => 'log_example',
enable => TRUE,
statement_types=> 'SELECT,UPDATE');
• Considerations
– DELETE statements are audited regardless of specified columns
CERN IT Department – MERGE statements are audited with the corresponding INSERT, UPDATE and
CH-1211 Geneva 23
Switzerland DELETE statements 12
www.cern.ch/it
Auditing: value based auditing
CERN IT Department
CH-1211 Geneva 23
Switzerland 14
www.cern.ch/it
Auditing: securing audit information
CERN IT Department
CH-1211 Geneva 23
Switzerland 15
www.cern.ch/it
Database security
tutorial
Part II
Oracle Tutorials, June 4th 2012
Szymon Skorupinski
CERN IT Department
CH-1211 Geneva 23
Switzerland
www.cern.ch/it
Agenda
CERN IT Department
CH-1211 Geneva 23
Switzerland 17
www.cern.ch/it
Encryption in Oracle DBs (1/2)
CERN IT Department
CH-1211 Geneva 23
Switzerland 19
www.cern.ch/it
SQL injection defined
CERN IT Department
CH-1211 Geneva 23
Switzerland 22
www.cern.ch/it
SQL injection – be prepared!
Source: niebezpiecznik.pl
CERN IT Department
CH-1211 Geneva 23
Switzerland 23
www.cern.ch/it
SQL injection inputs example (1/7)
SQL> create table users (
login varchar2(20),
pass varchar2(20)
);
Table created.
SQL> insert into users values ('admin','pass');
1 row created.
SQL> commit;
Commit complete.
OUT
--------------
1
CERN IT Department
CH-1211 Geneva 23
Switzerland 25
www.cern.ch/it
SQL injection inputs example (3/7)
SQL> variable usr varchar2(20);
SQL> variable pwd varchar2(20);
SQL> select 1 out from users where login = :usr and pass
= :pwd;
no rows selected
CERN IT Department
CH-1211 Geneva 23
Switzerland 26
www.cern.ch/it
SQL injection inputs example (4/7)
SQL> create or replace procedure add_user (p_login
varchar2, p_pass varchar2) as
l_cmd varchar2(1000);
begin
l_cmd := '
begin
insert into users values (''' || p_login ||
''',''' || p_pass || ''');
commit;
end;';
dbms_output.put_line(l_cmd);
execute immediate l_cmd;
end;
/
Procedure created.
CERN IT Department
CH-1211 Geneva 23
Switzerland 27
www.cern.ch/it
SQL injection inputs example (5/7)
SQL> set serveroutput on
SQL> select * from users;
LOGIN PASS
-------------------- --------------------
admin pass
CERN IT Department
CH-1211 Geneva 23
Switzerland 30
www.cern.ch/it
SQL injection no inputs example (1/6)
SQL> create table users (
login varchar2(30),
pass varchar2(30),
expire timestamp
);
Table created.
Session altered.
CERN IT Department
CH-1211 Geneva 23
Switzerland 31
www.cern.ch/it
SQL injection no inputs example (2/6)
SQL> insert into users values ('UserExpired',
'pass1234', systimestamp - 1);
1 row created.
SQL> commit;
Commit complete.
Thank you!
Source: xkcd.com
CERN IT Department
CH-1211 Geneva 23
Switzerland 37
www.cern.ch/it