44
Securing the Oracle Database 中中中中中中中中中 中 中 中

Securing the Oracle Database

Embed Size (px)

DESCRIPTION

Securing the Oracle Database. 中原大學應用數學系 劉 立 民. Introducation. Passwords and Users Oracle Password Management Features Default Oracle Users Privileges, Grants, Roles, and Views Oracle9i Security Products and Features. Password features. Password enhancements. User PROFILE - PowerPoint PPT Presentation

Citation preview

Page 1: Securing the Oracle Database

Securing the Oracle Database

中原大學應用數學系劉 立 民

Page 2: Securing the Oracle Database

Introducation

Passwords and Users Oracle Password Management Features Default Oracle Users

Privileges, Grants, Roles, and Views

Oracle9i Security Products and

Features

Page 3: Securing the Oracle Database

Password features

Page 4: Securing the Oracle Database

Password enhancements User PROFILE

Default profile Create/alter profile

SQL> describe DBA_PROFILES; 名稱 空值 ? 類型 ----------------------------------------------------------------- -------- ----------------------- PROFILE NOT NULL VARCHAR2(30) RESOURCE_NAME NOT NULL VARCHAR2(32) RESOURCE_TYPE VARCHAR2(8) LIMIT VARCHAR2(40)

SQL> select * from DBA_PROFILES;

PROFILE RESOURCE_NAME RESOURCE LIMIT------------------------------ -------------------------------- -------- -----------DEFAULT COMPOSITE_LIMIT KERNEL UNLIMITEDDEFAULT FAILED_LOGIN_ATTEMPTS PASSWORD UNLIMITEDDEFAULT SESSIONS_PER_USER KERNEL UNLIMITEDDEFAULT PASSWORD_LIFE_TIME PASSWORD UNLIMITEDDEFAULT CPU_PER_SESSION KERNEL UNLIMITEDDEFAULT PASSWORD_REUSE_TIME PASSWORD UNLIMITEDDEFAULT CPU_PER_CALL KERNEL UNLIMITEDDEFAULT PASSWORD_REUSE_MAX PASSWORD UNLIMITEDDEFAULT LOGICAL_READS_PER_SESSION KERNEL UNLIMITEDDEFAULT PASSWORD_VERIFY_FUNCTION PASSWORD NULL

Page 5: Securing the Oracle Database

Password enhancements (Con’t) Resource_type

Password Kernel

SQL> select * from dba_profiles where resource_type = 'PASSWORD'PROFILE RESOURCE_NAME RESOURCE LIMIT------------------------------ -------------------------------- -------- ---------DEFAULT FAILED_LOGIN_ATTEMPTS PASSWORD UNLIMITEDDEFAULT PASSWORD_LIFE_TIME PASSWORD UNLIMITEDDEFAULT PASSWORD_REUSE_TIME PASSWORD UNLIMITEDDEFAULT PASSWORD_REUSE_MAX PASSWORD UNLIMITEDDEFAULT PASSWORD_VERIFY_FUNCTION PASSWORD NULLDEFAULT PASSWORD_LOCK_TIME PASSWORD UNLIMITEDDEFAULT PASSWORD_GRACE_TIME PASSWORD UNLIMITED

已選取 7 個資料列 .

Execute ultpwdmg.sql at $ORACLE_HOME/rdbms/admin

@”D:\Oracle\ora92\rdbms\admin\utlpwdmg.sql”

Page 6: Securing the Oracle Database

Password enhancements (Con’t)

SQL> select * from dba_profiles where resource_type = 'PASSWORD'

PROFILE RESOURCE_NAME RESOURCE LIMIT

------------------------------ -------------------------------- -------- ---------

DEFAULT FAILED_LOGIN_ATTEMPTS PASSWORD 3

DEFAULT PASSWORD_LIFE_TIME PASSWORD 60

DEFAULT PASSWORD_REUSE_TIME PASSWORD 1800

DEFAULT PASSWORD_REUSE_MAX PASSWORD UNLIMITED

DEFAULT PASSWORD_VERIFY_FUNCTION PASSWORD VERIFY_FUNCTION

DEFAULT PASSWORD_LOCK_TIME PASSWORD .0006

DEFAULT PASSWORD_GRACE_TIME PASSWORD 10

已選取 7 個資料列 .

Page 7: Securing the Oracle Database

Aging and expiration Password_life_time

Number of days the same password can be used for authentication

Password_grace_time Number of days in the grace period

Ex: Password_life_time = 90Password_grace_time = 15

After day 90+15, the account will be locked.

Page 8: Securing the Oracle Database

Password History Parameters prevents users from avoiding

password expiration by changing a password and changing it back to the original password.

Password_reuse_time Number of days until a password cannot be

resued. Password_reuse_max

Number of password changes required before the current password can be reused.

Setting both to UNLIMITED allows passwords to be reused immediately.

Page 9: Securing the Oracle Database

Account locking Failed_login_attempts

Number of attempts to log in that can fail before the user account is locked

Password_lock_time Amount of time an account remains

locked after the specified number of consecutive failed login attempts is reached

If set to UNLIMITED, the account will no unlock automatically.

Page 10: Securing the Oracle Database

Password profile parameters

Page 11: Securing the Oracle Database

Password profile parameters (Con’t)

Page 12: Securing the Oracle Database

Enabling password parameters Create a user-defined profilecreate profile MY_PROFILE limitfailed_login_attempts 5 password_lock_time .5 password_reuse_max UNLIMITED password_life_time 90 password_reuse_time 60 password_verify_function MY_PASSWORD_FUNCT password_grace_time 15;

Create users with specific profilecreate user NELSONidentified by nel_123default tablespace USERStemporary tablespace TMPpassword expireprofile MY_PROFILE;

Page 13: Securing the Oracle Database

Default Oracle Users Several default users are created when you

create your database. Check these users via DBA_USERS

describe DBA_USERS

Lock those unused users Verify users’ granted_role, and privileges select * from dba_role_privs where grantee =

'HR';select * from dba_sys_privs where grantee = 'HR';select * from dba_tab_privs where grantee = 'HR‘;

Page 14: Securing the Oracle Database

DBA_ views that display user privileges

VIEW Description

DBA_SYS_PRIVSDBA_ROLE_PRIVSDBA_TAB_PRIVS

DBA_ROLES

Show the system privileges assigned to user and rolesShow the privileges assigned to a roleShow the users who have been granted access to insert, update, select, or delete form a table or viewShow what roles exist and whether or not they are default

Page 15: Securing the Oracle Database

Database objectsObject type

Description

Table

Index

ViewSequence

Cluster

:

Basic unit of data storage. Table data is stored in rowcomprising column.An optional database structure used to quickly locate a rowin a table. The three kinds of indexes are cluster indexes,table indexes, and bit-mapped indexes.A virtual table that does not have physical storage.A serial list of unique numbers used with in a numeric column that can be used to generate unique values.Optional groups of one or more tables stored together because they are commonly used together.

Page 16: Securing the Oracle Database

Object privilegesPrivilege

Action

Select Insert Update

Delete

Alter Execute

ReadReferenceIndex

View information within a table or view.Insert new rows of information into a table or view.Modify one or more columns of information within a table or view.Remove one or more columns of information within a table or view.Change an object’s definition.Compile, execute, or access a procedure or function referenced in a programRead files in a directoryCreate a constraint that refers to a tableCreate an index on a table

Page 17: Securing the Oracle Database

Controlling user access Product-level Security

Users access can be restricted based on the SQL*Plus product usage.

DBAs can use PRODUCT_USER_PROFILE to disable certain SQL and SQL*Plus commands in the SQL*Plus environment on a per-user basis.

PRODUCT_USER_PROFILE table consists of the following columns:

PRODUCT USERID ATTRIBUTE SCOPE NUMERIC_VALUECHAR_VALUE DATE_VALUE LONG_VALUE

NOT NULL CHAR (30) CHAR(30) CHAR(240) CHAR(240) NUMBER(15,2) CHAR(240) DATE LONG

Page 18: Securing the Oracle Database

PRODUCT_USER_PROFILE PRODUCT_USER_PROFILE table is owned by SYSTEM Commands that can be applied in PRODUCT_USER_PROFILE table

includes: ALTER, AUDIT, ANALYZE, CREATE, DELETE, DROP, INSERT, LOCK, NOAUDIT, RENAME, SELECT, UPDATE, VALIDATE, etc.

Creating the PRODUCT_USER_PROFILE table by Execute pupbld.sql at $ORACLE_HOME/sqlplus/admin

@”D:\Oracle\ora92\sqlplus\admin\pupbld.sql” Example:insert into product_user_profile(product, userid, attribute, char_value)

values('SQL*Plus', 'APPS', 'CREATE', 'DISABLED');insert into product_user_profile(product, userid, attribute, char_value)

values('SQL*Plus', 'APPS', 'UPDATE', 'DISABLED'); insert into product_user_profile(product, userid, attribute, char_value)

values('SQL*Plus', 'APPS', 'DELETE', 'DISABLED');insert into product_user_profile(product, userid, attribute, char_value)

values('SQL*Plus', 'APPS', 'INSERT', 'DISABLED');insert into product_user_profile(product, userid, attribute, char_value)

values('SQL*Plus', 'APPS', 'SELECT', 'DISABLED');

Page 19: Securing the Oracle Database

Preventing access using PL/SQL

The DELETE privilege disabled for user APPS can easily be executed through a PL/SQL block.

This can be avoided by removing the PL/SQL block creation access itself.

insert into product_profile (product, userid, attribute, char_value) values ('SQL*Plus', 'APPS', 'DECLARE', 'DISABLED');

insert into product_profile (product, userid, attribute, char_value)

values ('SQL*Plus', 'APPS', 'BEGIN', 'DISABLED'); PRODUCT_PROFILE is a synonym of

PRODUCT_USER_PROFILE exists to ensure backwards compatibility.

Page 20: Securing the Oracle Database

With Grant Option DBAs can grant different privileges to different users.SQL> CREATE USER TOM IDENTIFIED BY ICE; User created.SQL> GRANT CREATE SESSION TO TOM; Grant succeeded. SQL> GRANT CREATE TABLE TO TOM; Grant succeeded. SQL> GRANT CREATE SEQUENCE TO TOM; Grant succeeded. DBAs can also grant users “with grant option” to allow

them to grant access to other users without any action on the DBA parts.

SWL> CREATE TABLE TEST (COL NUMBER); Table created. SQL> GRANT SELECT, UPDATE ON TEST TO TOM WITH GRANT OPTION; Grant succeeded.

Page 21: Securing the Oracle Database

With Admin Option DBA can grant users administration

privileges using “with admin option”

SQL> GRANT CREATE TABLE TO TOM WITH ADMIN OPTION; Grant succeeded.

Revoke uses’ administration privilegesSQL> REVOKE CREATE TABLE FROM TOM; Revoke succeeded.

Privileges granted by TOM still retain after DBA revoke TOM’s administration privileges.

Page 22: Securing the Oracle Database

Using Role Why using roles

Grant privileges to individual directly can be very tedious.

Example, 100 objects with 100 users needs to make 10,000 grants; one people leave the company needs to make 100 revokes.

Steps of using roles Group users into categories Define one or more roles for each category Grant proper privileges to each role Assign roles to users in each category

Page 23: Securing the Oracle Database

Create roles

Assume table EMP has two kinds of users: query EMP and update EMP.SQL> create role report_writer identified by rep123;Role created.SQL> create role data_changer identified by your_pwd;Role created.

Grant privileges to rolesSQL> GRANT SELECT ON EMP TO REPORT_WRITER; Grant succeeded. SQL> GRANT UPDATE, DELETE, INSERT ON EMP TO DATA_CHANGER; Grant succeeded.

Page 24: Securing the Oracle Database

Assign roles to users Once we create roles with proper

privileges, we can assign roles to users.SQL> GRANT REPORT_WRITER TO TOM; Grant succeeded. SQL> GRANT DATA_CHANGER TO HENRY; Grant succeeded.

Revoke roles from users to maintain the proper privileges

SQL> REVOLE DATA_CHANGE FROM HENRY;Revoke succeeded.

DBA_ROLESSQL> select * from dba_roles;

Page 25: Securing the Oracle Database

Oracle-supplied roles

CONNECT Gives the user the ability to access the

database

RESOURCE Gives the user the ability to create objects

and use space in the database

DBA Gives the user administrative privileges in

the database

Page 26: Securing the Oracle Database

Querying roles

VIEW Description

USER_ROLE_PRIVSROLE_ROLE_PRIVSROLE_TAB_PRIVSROLE_SYS_PRIVSSESSION_ROLES

Show the roles granted to current userShow the roles which are granted to roles Show the table privileges granted to roles Show the system privileges granted to roles Show the roles which the user currently has enabled

Page 27: Securing the Oracle Database

Set roles

Default roles will be enabled automatically and accessible when users connect to the database

For roles requiring password, users need to use set role to enable the role privileges.SQL> set role DATA_CHANGE identified by your_pwd;

Page 28: Securing the Oracle Database

Using Views to Manage Privileges Rather than granting users privileges on a

particular table, you can give them access to a view of the table.

Views add two more levels of security: A view can limit access to only selected columns of

the base table. A view can provide value-based security for the

information in a table. Thus a WHERE clause in the definition of a view can display only selected rows of a base table.

The user need not be given privileges on base objects underlying the view.

Page 29: Securing the Oracle Database

An Example of a View

Page 30: Securing the Oracle Database

View privileges

View creationSQL> CREATE VIEW STAFF AS ( 2 SELECT EMPNO, ENAME, JOB, MGR, DEPTNO FROM EMP 3 );

View created.

Grant privileges to rolesSQL> GRANT SELECT ON STAFF TO REPORT_WRITER;

Grant succeeded.

Page 31: Securing the Oracle Database

Row Level Security

Two more effective approaches to implement row level security: Virtual Private Database (VPD), in which

you create your own implementation of row level security; and

Label-based access control, in which you customize a ready-made VPD policy to accomplish this.

Page 32: Securing the Oracle Database

Virtual Private Database (VPD) Virtual Private Database is the ability to

perform query modification based on a security policy you have defined in a package, and associated with a table, view.

You can implement VPD by writing a stored procedure to append a SQL predicate to each SQL statement to control row level access for that statement.

For example, SQL SELECT * FROM emp; will be modified, say SELECT * FROM emp where deptno = 10;

Page 33: Securing the Oracle Database

Virtual Private Database: Customers see Only Their Own Orders

Page 34: Securing the Oracle Database

Example of VPD Choose the tables or views to protect at the row

levelSQL> create table employee ( 2 trndate date, 3 credit_val number(12,2), 4 debit_val number(12,2), 5 trn_type varchar2(10), 6 cost_center varchar2(10) ) tablespace users;

Table created.

Define the business rules that will be followed for accessing data in these tables

Create a security context to manage application sessions

SQL> create or replace context vpd_test using set_vpd_context;

Context created.

Page 35: Securing the Oracle Database

Example of VPD (Con’t) Create a procedure or function to manage

setting of the security context for users SQL> CREATE TABLE emp ( empno NUMBER(4) NOT NULL, 2 ename VARCHAR2(10), 3 job VARCHAR2(9), 4 mgr NUMBER(4), 5 sal NUMBER(7,2), 6 deptno NUMBER(2));

Table created.

Define the business rules that will be followed for accessing data in these tables

Create a security context to manage application sessions CREATE OR REPLACE CONTEXT HR USING HR.Context_Package;

Page 36: Securing the Oracle Database

Example of VPD (Con’t) Create a procedure or function to manage

setting of the security context for usersCREATE OR REPLACE PACKAGE Context_Package AS PROCEDURE Set_Context;

Write a package to generate the dynamic access predicates for access to each table

CREATE OR REPLACE PACKAGE BODY Context_Package IS PROCEDURE Set_Context IS

This_PERSON_ID NUMBER;BEGINDbms_Session.Set_Context('HR','SETUP','TRUE');IF SUBSTR(SYS_CONTEXT('USERENV','SESSION_USER'),1,2)='OE' :Dbms_Session.Set_Context('HR','SETUP','FALSE');

END Set_Context;END Context_Package;

Page 37: Securing the Oracle Database

Make the packages public by executing the following sql. GRANT EXECUTE ON hr.Context_Package to Public;

Automate the setting of the security context CREATE OR REPLACE TRIGGER HR.Set_Security_ContextAFTER LOGON ON DATABASEBEGIN

HR.Context_Package.Set_Context;END;

Example of VPD (Con’t)

Page 38: Securing the Oracle Database

Label-based access control Label-based access control allows

organizations to assign sensitivity labels to data rows.

Control access to data based on those labels, and ensure that data is marked with the appropriate sensitivity label.

Oracle9i Label Security is not installed by default with the Oracle9i Enterprise Edition.

Page 39: Securing the Oracle Database

Oracle Label Security

Page 40: Securing the Oracle Database

Oracle Label Security Oracle Label Security is built on the

Virtual Private Database toolkit, Requires no programming whatsoever. Oracle Label Security delivers a data

dictionary and administrative tools you can use to construct valid labels, set user label authorizations and privileges,

and apply the resulting Oracle Label Security

policy to tables and schemes.

Page 41: Securing the Oracle Database

Oracle9i Security Products

Oracle9i Standard Edition Integrity Authentication and Access Controls in Oracle9i Privileges Roles Auditing Views, Stored Program Units, Triggers Data Encryption High Availability Proxy Authentication in Oracle9i

Page 42: Securing the Oracle Database

Oracle9i Security Products (Con’t)

Oracle9i Enterprise Edition Internet Scale Security Features Application Security Virtual Private Database in Oracle9i Secure Application Role Fine-Grained Auditing Oracle Auditing for Three-Tier Applications Java Security Implementation in the

Database

Page 43: Securing the Oracle Database

Other Oracle security products

Oracle Advanced Security Oracle Label Security Oracle Internet Directory Oracle Net Services Oracle9i Application Server

Page 44: Securing the Oracle Database

References Oracle Security Handbook by Theriault Oracle SQL*Plus: The Definitive Guide by Gennick Oracle 9i: Security Overview (9.2) by Oracle Oracle 9i Application Server: Security Guide (9.0.2) by Oracle Oracle 9i: Database Administration Guide (9.2) by Oracle Oracle 9i Net Services: Administrator’s Guide (9.2) by Oracle