Database security tutorial. Part I



Similar documents
Fine Grained Auditing In Oracle 10G

Oracle Database 11g: Security Release 2. Course Topics. Introduction to Database Security. Choosing Security Solutions

All About Oracle Auditing A White Paper February 2013

Oracle Database 11g: Administration Workshop I 11-2

D50323GC20 Oracle Database 11g: Security Release 2

Oracle Database 11g: Security Release 2

An Oracle White Paper August Oracle Database Auditing: Performance Guidelines

Virtual Private Database Features in Oracle 10g.

Database Auditing Report submitted by: D. Murali Krishna S.M Siva Rama Krishna

Oracle. Brief Course Content This course can be done in modular form as per the detail below. ORA-1 Oracle Database 10g: SQL 4 Weeks 4000/-

All About Oracle Auditing Everything You Need to Know

Securing Data in Oracle Database 12c

Oracle Database: SQL and PL/SQL Fundamentals NEW

Oracle Database 11g: Security. What you will learn:

Advanced SQL Injection in Oracle databases. Esteban Martínez Fayó

Oracle Database 11g: Security

Security Analysis. Spoofing Oracle Session Information

New Oracle 12c Security Features Oracle E-Business Suite Perspective

<Insert Picture Here> Oracle Database Security Overview

DBMS Questions. 3.) For which two constraints are indexes created when the constraint is added?

Oracle 11g Security. Summary of new features (1) Agenda. Summary of new features (3) Summary of new features (2) Introduction - commercial slide.

Oracle Audit in a Nutshell - Database Audit but how?

Oracle Database. Security Guide 11g Release 1 (11.1) B

Restore and Recovery Tasks. Copyright 2009, Oracle. All rights reserved.

Oracle Database 10g Express

Copyright 2013, Oracle and/or its affiliates. All rights reserved.

Oracle Database Security

Oracle Database 11g: Security

Identity Management and Access Control

Monitoring Audit Trails Using Enterprise Manager

Oracle Database Security. Paul Needham Senior Director, Product Management Database Security

Oracle Database Security Features in the Banking Environment. Dr. Matthias Mann, DOAG

Copyright 2013, Oracle and/or its affiliates. All rights reserved.

Oracle Database Security Solutions

MySQL Security: Best Practices

news from Tom Bacon about Monday's lecture

Best Practices for Oracle Databases Hardening Oracle /

Oracle Database 11g: Administration Workshop I

Oracle Audit Vault and Database Firewall

Security Target for. Security Evaluations Oracle Corporation 500 Oracle Parkway Redwood Shores, CA 94065

Security and Control Issues within Relational Databases

Oracle 11g Database Administration

Informatica Data Replication FAQs

Oracle Database. Security Guide 11g Release 2 (11.2) E

Configuring an Alternative Database for SAS Web Infrastructure Platform Services

Oracle Database. 2 Day + Security Guide 11g Release 1 (11.1) B

Protecting Data Assets and Reducing Risk

Oracle Database 12c: Introduction to SQL Ed 1.1

Microsoft SQL Server Security & Auditing. March 23, 2011 ISACA Chapter Meeting

Oracle Database 10g: Introduction to SQL

MyOra 3.0. User Guide. SQL Tool for Oracle. Jayam Systems, LLC

Oracle 1Z0-528 Exam Questions & Answers

Division of IT Security Best Practices for Database Management Systems

COURCE TITLE DURATION. Oracle Database 11g: Administration Workshop I

Setting up SQL Translation Framework OBE for Database 12cR1

Oracle Database 11g: Security

Safeguard Sensitive Data in EBS: A Look at Oracle Database Vault, Transparent Data Encryption, and Data Masking. Lucy Feng

Oracle Database Auditing Performance Guidelines

Database Administration with MySQL

Oracle PL/SQL Injection

Database 10g Edition: All possible 10g features, either bundled or available at additional cost.

Oracle Database 11g Security Essentials

Securing Data on Microsoft SQL Server 2012

MyOra 3.5. User Guide. SQL Tool for Oracle. Kris Murthy

Credit Cards and Oracle E-Business Suite Security and PCI Compliance Issues

Oracle Health Sciences Network. 1 Introduction. 1.1 General Security Principles

Database Programming with PL/SQL: Learning Objectives

2015 Jože Senegačnik Oracle ACE Director

Oracle Database 11g: Administration I

ORACLE DATABASE SECURITY. Keywords: data security, password administration, Oracle HTTP Server, OracleAS, access control.

ORACLE DATABASE 11G: COMPLETE

Database Assessment. Vulnerability Assessment Course

Developing Value from Oracle s Audit Vault For Auditors and IT Security Professionals

GUIDE TO SYBASE SECURITY

Oracle Database 10g: Security Release 2

Best Practices for Dynamic SQL

Microsoft SQL Server Security Best Practices

Oracle EXAM - 1Z Oracle Database 11g Security Essentials. Buy Full Product.

Oracle Database 12c: Admin, Install and Upgrade Accelerated

SharePlex for SQL Server

Tivoli Security Compliance Manager. Version rel. 2 July, Collector and Message Reference Windows Oracle Addendum

Oracle Database: SQL and PL/SQL Fundamentals NEW

D12C-AIU Oracle Database 12c: Admin, Install and Upgrade Accelerated NEW

Guide to Auditing and Logging in the Oracle E-Business Suite

SQL Injection. The ability to inject SQL commands into the database engine through an existing application

Introduction to IT Security

Sophos Enterprise Console Auditing user guide. Product version: 5.2

Fixing Common Problems in Data Storage - A Review

Duration Vendor Audience 5 Days Oracle End Users, Developers, Technical Consultants and Support Staff

PUBLIC Installation: SAP Mobile Platform Server for Linux

Database Security. Oracle Database 12c - New Features and Planning Now

An Oracle White Paper June Oracle Database 11g: Cost-Effective Solutions for Security and Compliance

Basic Unix/Linux 1. Software Testing Interview Prep

DATABASE SECURITY MECHANISMS AND IMPLEMENTATIONS

Securing Oracle E-Business Suite in the Cloud

Oracle Database 11g: Administration Workshop I

Using RMAN to restore a database to another server in an ASM environment

Transcription:

Database security tutorial Part I Oracle Tutorials, June 4 th 2012 Daniel Gómez Blanco

Agenda Authentication Roles and privileges Auditing 2

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 DEFAULT TABLESPACE tblspc QUOTA 10M ON tblspc TEMPORARY TABLESPACE tmpspc QUOTA 5M on tmpspc PROFILE sec_prof PASSWORD EXPIRE; 3

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 Enforce use of password profiles and account lockouts 4

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; 5

Roles and privileges: privileges A privilege is a right to execute a particular type of SQL statement or to access another user s object System privileges Enable users to perform actions in the database GRANT <system_privilege> TO <grantee_clause> [WITH ADMIN OPTION] REVOKE <system_privilege> FROM <grantee_clause> 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> 6

Roles and privileges: revoking privileges Revoking system privilege User DBA Joe Emily Privilege Object Revoking object privileges User DBA Joe Emily Privilege Object 7

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] Roles granted to and revoked from users as system privileges GRANT <role> TO <user> [WITH ADMIN OPTION] Predefined roles (CONNECT, RESOURCE, SCHEDULER_ADMIN, DBA, SELECT_CATALOG_ROLE) Roles can be secured Set password to enable roles Make roles non-default Create roles than can be enabled only through PL/SQL procedures Syntax CREATE ROLE secure_application_role [IDENTIFIED USING <security_procedure_name>]; ALTER USER username DEFAULT ROLE (role NONE ALL [EXCEPT role1, role2, ]); 8

Auditing Capturing and storing information about what is happening Identifying unusual database activity Several configurations Mandatory auditing Standard database auditing Fine-grained auditing (FGA) Value-based auditing Administrator auditing DBA 1 Enable auditing Parameter file User 2 Specify audit options Database Audit options Audit trail Server process Execute command Generate audit trail 3 Review audit information OS or XML audit trail 9

Auditing: standard auditing Set AUDIT_TRAIL parameter to storage location OS On Windows: event log On UNIX or Linux: AUDIT_FILE_DEST parameter DB (or DB, EXTENDED): DBA_AUDIT_TRAIL view, part of the SYS schema XML (or XML, EXTENDED): AUDIT_FILE_DEST parameter V$XML_AUDIT_TRAIL view contains XML files in directory Audit trail must be maintained (might reduce performance) Oracle recommends OS audit trails SQL statement auditing (DDL) AUDIT TABLE; AUDIT TABLE BY user WHENEVER NOT SUCCESSFUL; System-privilege auditing AUDIT SELECT ANY TABLE, CREATE ANY TRIGGER; AUDIT SELECT ANY TABLE BY USER BY SESSION; Object-privilege auditing AUDIT ALL ON schema.table; AUDIT UPDATE,DELETE ON schema.table BY user BY ACCESS; 10

Auditing: default auditing Some privileges and statements audited by default ALTER ANY PROCEDURE ALTER ANY TABLE ALTER DATABASE ALTER PROFILE ALTER SYSTEM ALTER USER AUDIT SYSTEM CREATE ANY JOB SYSTEM AUDIT BY ACCESS ROLES BY ACCESS Privileges Audited by Default CREATE ANY LIBRARY CREATE ANY PROCEDURE CREATE ANY TABLE CREATE EXTERNAL JOB CREATE PUBLIC DATABASE LINK CREATE SESSION CREATE USER GRANT ANY OBJECT PRIVILEGE Statements audited by Default GRANT ANY PRIVILEGE GRANT ANY ROLE DROP ANY PROCEDURE DROP ANY TABLE DROP PROFILE DROP USER EXEMPT ACCESS POLICY 11

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 MERGE statements are audited with the corresponding INSERT, UPDATE and DELETE statements 12

Auditing: value based auditing Capture changed values, not just executed actions Database triggers are used (degraded performance) To be used in special cases Logic behind Standard database auditing is not sufficient Parameters obtained using SYS_CONTEXT function Example CREATE OR REPLACE TRIGGER system.example_audit END; AFTER UPDATE OF column_name ON schema.table REFERENCING NEW AS NEW OLD AS OLD FOR EACH ROW BEGIN IF :old.column_name < :new.column_name THEN END IF; INSERT INTO system.audit_example VALUES (sys_context('userenv','os_user'), sysdate, sys_context('userenv','ip_address'), :new.id changed from ' :old.column_name ' to ' :new.column_name); 13

Auditing: administrator auditing Users with SYSDBA and SYSOPER privileges can connect when database is closed Connections AS SYSDBA and AS SYSOPER are always audited Other actions can be audited AUDIT_SYS_OPERATIONS=TRUE in parameters file Audit trail stored outside the database On Windows: event log On UNIX or Linux: AUDIT_FILE_DEST parameter 14

Auditing: securing audit information Archived audit information must be secured Extract data to location on local disk Encrypt data (digitally signed by the auditing system) Audit the audit system Oracle Audit Vault Collects and consolidates audit data, beginning with Oracle 9i Database Release 2 Microsoft SQL Server 2000 & 2005 IBM DB2 Unix, Linux, Windows 8.2 & 9.5 Sysbase ASE 12.5 15.0 Built-in and custom reports Open audit schema to be accessed from Oracle BI Publisher Oracle Application Express Third-party reporting tools Secure and scalable audit warehouse 15

Database security tutorial Part II Oracle Tutorials, June 4 th 2012 Szymon Skorupinski

Agenda Encryption in Oracle databases SQL injection attacks in Oracle Questions 17

Encryption in Oracle DBs (1/2) Way to increase protection for sensitive data Oracle Enterprise Edition with Advanced Security option required Transparent Data Encryption (TDE) No application changes needed Encryption of data before it s written to storage Decryption of data when it s read from storage Two modes supported Tablespace encryption (11g) hardware acceleration possible Column encryption (10gR2) 18

Encryption in Oracle DBs (2/2) Additional protection for data in transit Network encryption to protect communication to and from the database Rejecting connections from clients without encryption Additional protection for backups TDE encrypted data remains encrypted Entire backup and export dump files encryption possibility 19

SQL injection defined Kind of attack with adding and executing unintended code from untrusted source Manipulate select statements Run DML or even DDL Run stored procedures Virtually anything could be done in context of connected user privileges Even more with definer s right procedures Caused by Wrong input handling not only strings! Implicit types conversions dangerous 20

SQL injection prevention (1/2) Design security into your application from day 1 Detection very hard and time consuming in post-development phase Could procedure without any input parameters be injected? Yes... Use bind variables! You ll be secure......and will get better performance and scalability If not... then you must submit your code for review to at least five people who do not like you - they must be motivated to rip your code apart, critically review it, make fun of it - so they find the bugs Tom Kyte 21

SQL injection prevention (2/2) If you really have very good technical reasons not to use binds Are you sure? Use DBMS_ASSERT package to sanitize user inputs Are you 100% sure? Don t use implicit types conversions......and don t rely on defaults Application logic unintended change besides SQL injections 22

SQL injection be prepared! Source: niebezpiecznik.pl 23

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. SQL> select 1 out from users where login = 'admin' and pass ='fake'; no rows selected SQL> select 1 out from users where login = 'admin' and pass = 'pass'; OUT -------------- 1 24

SQL injection inputs example (2/7) SQL> select 1 out from users where login = '&usr' and pass = '&pwd'; Enter value for usr: admin Enter value for pwd: fake' or 'a'='a old new 1: select 1 out from users where login = '&usr' and pass = '&pwd' 1: select 1 out from users where login = 'admin' and pass = 'fake' or 'a'='a' OUT -------------- 1 25

SQL injection inputs example (3/7) SQL> variable usr varchar2(20); SQL> variable pwd varchar2(20); SQL> exec :usr := 'admin'; PL/SQL procedure successfully completed. SQL> exec :pwd := 'fake'' or ''a'' = ''a'; PL/SQL procedure successfully completed. SQL> select 1 out from users where login = :usr and pass = :pwd; no rows selected 26

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. 27

SQL injection inputs example (5/7) SQL> set serveroutput on SQL> select * from users; LOGIN PASS -------------------- -------------------- admin pass SQL> exec add_user('newlogin','newpass'); begin insert into users values ('NewLogin','NewPass'); commit; end; PL/SQL procedure successfully completed. SQL> select * from users; LOGIN PASS -------------------- -------------------- admin pass NewLogin NewPass 28

SQL injection inputs example (6/7) SQL> exec add_user('newerlogin','newerpass''); insert into users values (''FakeUser'', ''FakePass'');--'); begin insert into users values ('NewerLogin', 'NewerPass'); insert into users values ('FakeUser', 'FakePass');--'); commit; end; PL/SQL procedure successfully completed. SQL> select * from users; LOGIN PASS -------------------- -------------------- NewerLogin NewerPass admin pass NewLogin NewPass FakeUser FakePass 29

SQL injection inputs example (7/7) SQL> exec add_user('newestlogin','newestpass''); execute immediate ''drop table users'';--'); begin insert into users values ('NewestLogin','NewestPass'); execute immediate 'drop table users';--'); commit; end; PL/SQL procedure successfully completed. SQL> select * from users; select * from users * ERROR at line 1: ORA-00942: table or view does not exist 30

SQL injection no inputs example (1/6) SQL> create table users ( login varchar2(30), pass varchar2(30), expire timestamp ); Table created. SQL> alter session set nls_timestamp_format = 'DD-MM- YYYY HH24:MI:SS'; Session altered. 31

SQL injection no inputs example (2/6) SQL> insert into users values ('UserExpired', 'pass1234', systimestamp - 1); 1 row created. SQL> insert into users values ('UserNotExpired', '4567pass', systimestamp + 1); 1 row created. SQL> commit; Commit complete. SQL> select * from users; LOGIN PASS EXPIRE -------------- -------------- ------------------- UserExpired pass1234 25-05-2012 22:07:35 UserNotExpired 4567pass 27-05-2012 22:07:35 32

SQL injection no inputs example (3/6) SQL> create or replace procedure list_expired_users is l_query varchar2(300); l_query_bind varchar2(300); l_time l_cur l_login timestamp; sys_refcursor; varchar2(30); begin l_time := systimestamp; l_query := 'select login from users where expire <= ''' l_time ''''; l_query_bind := 'select login from users where expire <= :b_var'; dbms_output.put_line('concatenated query with implicit conversions: ' l_query); open l_cur for l_query; 33

SQL injection no inputs example (4/6) loop fetch l_cur into l_login; exit when l_cur%notfound; dbms_output.put_line(l_login); end loop; close l_cur; dbms_output.put_line('bind variable query: ' l_query_bind); open l_cur for l_query_bind using l_time; loop fetch l_cur into l_login; exit when l_cur%notfound; dbms_output.put_line(l_login); end loop; close l_cur; end; / 34

SQL injection no inputs example (5/6) SQL> show parameter nls_timestamp_format NAME TYPE VALUE -------------------- ----------- ----------------------- nls_timestamp_format string DD-MM-YYYY HH24:MI:SS SQL> set serverout on SQL> exec list_expired_users; Concatenated query with implicit conversions: select login from users where expire <= '26-05-2012 22:14:24' UserExpired Bind variable query: select login from users where expire <= :b_var UserExpired PL/SQL procedure successfully completed. 35

SQL injection no inputs example (6/6) SQL> alter session set nls_timestamp_format = '"'' union select login '' '' pass from users--"'; Session altered. SQL> exec list_expired_users; Concatenated query with implicit conversions: select login from users where expire <= '' union select login ' ' pass from users--' UserExpired pass1234 UserNotExpired 4567pass Bind variable query: select login from users where expire <= :b_var UserExpired PL/SQL procedure successfully completed. 36

Questions? Thank you! Source: xkcd.com 37