Oracle Database Vault (part2)


Oracle database Vault Access Control Components

  • REALM  is a basically group of database schemas, objects or rolls that need to be secured in the database. For example: You may have table called EMP which contains employee salaries in schema called HR and you don’t want all the users to access this table specifically by SYS user which have an administrative access. If you want to prevent SYS user from accessing this particular table in the HR schema, then you can protect this table by configuring realm. So that this table will be protected from the administrators access.
  • COMMAND RULE  can be created to control execution of SQL statements. For example : You don’t want to create a table in HR schema, but user has system privilege create any table that means user can create table in any of the schemas of the database. As you want to restrict this user from running create table statement you can configure command rule and restrict the execution of create table statement. The SQL statements can be DDL’s or DML’s and you can restrict the execution all of this statements.
  • FACTOR- there are certain situations in which you will have to prevent access based on the user location, IP address or a particular user. In that scenario you configure variable called factor and this name attribute will recognize the components such as user locations, database IP addresses or session user and secures the area of database which you want to prevent from being accessed by the administrative users
  • RULE SET is a collection of one or more rules. You can associate this rule with realm authorization, command rules, factor assignments and also secure application roles
  • SECURE APPLICATION ROLE can be enabled based on the evaluation of the Oracle Database Vault rule set, the rule set evaluates to true or false depending on the evaluation of the rule which is associated with the rule set

.

Changes  after database vault installation:

Changes in initialization and Password Parameter settings:

  • AUDIT_SYS_OPERATIONS value changes from FALSE to TRUE – This means all operations performed by sys user will be audited
  • OS_ROLES paraeter values changes to FALSE- by default this is not configured, after you instal database vault this will be set to FALSE . This will disable operating system granting and revoking roles and privileges to users
  • RECYCLEBIN parameters values changes from ON to OFF- is this parameter Turned ON, the dropped objects in the database will be moved to recyclebean.By default recycle ben is turned on. When we enable database vault this parameter is turned off
  • REMOTE_LOGIN_PASSWORDFILE-this parameter is set to EXCLUSIVE by default, after installation od Database Vault value of this parameter is set to EXCLUSIVE again.
  • SQL92_SECURITY parameters value changes from FALSE to TRUE – if a user is granted update and delete privileges on a table, select privilege must enable that user from updating and deleting the table. SQL92_SECURITY enforces this functionality when update and delete privileges are granted to a user.
    .
    .New Database Roles
  • DV_OWNER-Oracle Database Vault Owner
  • DV_ACCTMGR-Oracle Database Vault Account Manager
    .
    .Changes to Database Auditing
  • After installing Database Vault $AUD table moved to SYSTEM schema from SYS schema
  • Modified audit settings- yo can also see certain change in the audit settings. dv will configure certain audit settings in the database. this again depends on the setting of audit_trail initialization parameter, if it set to none audit settings not configured, if it set db os os then audit setings can configured in the database vault in management.
    .
    .Privileges prevented for existing users:
  • ALTER PROFILE
  • ALTER USER
  • CREATE PROFILE
  • CREATE USER
  • DROP PROFILE
  • DROP USER
    .
    Basically this privileges are prevented from execution for sys and sysdba users . in database vault and management this privileges are granted to the special user who has DV_ACCTMGR privilege and this is will long be able perform any of the create user, drop user or any alter user operations in a database vault and management.
    .

      Privileges revoked from existing users and roles

  • DBA
  • PUBLIC
  • IMP_FULL_DATABASE
  • EXECUTE_CATALOG_ROLE
  • SCHEDULER_ADMIN
    .

Oracle Database Vault Schemas

When you install Database Vault two schemas (DVSYS and DVF)  are created during configuration.

  • DVSYS
    DVSYS schema basically contains Oracle database vault database objects in which Oracle Database Vault configuration information is stored
  • DVF
    There is a function called DBMS_MACSEC_FUNCTION package, this contains functions which can retrieve factor identitis. This package is owned by DVF schema.
    .

Oracle Database Vault Roles

  • DV_OWNER
    During the database vault installation and configuration when we were confiring it using DBCA we got the option to specify DV owner and DV account manager. We had provided DV account owner name as DVOWNER. This DVOWNER has a dv_owner role , this rule basically manages oracle database vault rules and its configuration
  • DV_ADMIN
    This role controls database vault PL/SQL packages
  • DV_ACCTMGR
    This role granted to Oracle Database Vault account manager account. This basically creates and manages database accounts and profiles. In the database vault and management sys user will not be able to perform any database account relatively activity such as creating user, altering user  to change the password, drop a user, create profile to maintain database users. So such a scenario dv_acctmgr will perform all this operations. A user who has DV_ACCTMGR rule will be performing all this operations in the database vault and management.
  • DV_SECANALYST
    User with this role can run reports in the Database Vault  administrative console
  • DV_PATCH_ADMIN
    This role granting to a user which performing patching the database vault and management. When applying patches in the database vault and management in earliest version database vault had to be disabled, this new role was introduced to avoid this step. Whenever yo needs to apply the patch in a database vault and management temporarily this rule is granted to the user. After the application of the patch this rule will be revoked from the user.

DBMS_MACADM Package
This package basically contains the procedures and the functions to create and configure the different components of the database vault such as realms, command rules, factors, rule sets and secure application roles. This package can be executed by the users who a granted dv_owner or dv_admin roles. Configuration of realms, command rules, factors also can be done using database vault administrative console. Below I will show you how to create and configure realms, command rules, factors and rule sets using database vault administrative console, I am also providing an example how it can be done using dbms_macadm package:

Creating a Realm

DBMS_MACADM.CREATE_REALM(
realm_name IN VARCHAR2,
description IN VARCHAR2,
enabled IN VARCHAR2,
audit_options IN NUMBER);

Creating a Comman rule

DBMS_MACADM.CREATE_COMMAND_RULE(
command IN VARCHAR2,
rule_set_name IN VARCHAR2,
object_owner IN VARCHAR2,
object_name IN NUMBER
enabled IN VARCHAR2);

Let’s test DV configuration and management:

SQL> conn dvacctmgr/<<your password >>
Connected.
SQL> create user demo identified by demo quota unlimited on users;
User created.
SQL> conn sys as sysdba
Enter password: 
Connected.
SQL> 
SQL> grant create session, select any table to demo;

Grant succeeded.
SQL> grant create session, select any table to demo;
Grant succeeded.
SQL> conn demo/demo
Connected.

SQL> select count(*) from hr.employees;

COUNT(*)
----------
107

As you can see user DEMO can fetch the records from EMPLOYEES table in HR schema. Let me configure REALM to restrict access to this particular table.
When you access the DV administration console you give the hostname or the IP address, the port number and slash DVA:

https://database_ip_adress: port_number/dva

Type your URL in your browser and press ok:

bp9

This is the login page database DV administration console.
Here we specify user name for the database vault owner dvowner and specify the password, hostname   or ip address of the my database server, and default port of oracle 1521. You can specify SID or service name in my example I am specifying SID name  which is DB11G and click login.

bp10

You can see different tabs on the console – Administration, Database Vault Reports, General Security Reports and Monitor. To Configure Realm click on  Administration tab and select Realms:

bp11

There are certain default realms which are configured during database vault installation. These are 4 realms which are default realms offered by oracle database vault.

  • Database Vault Account Management realm defines realm for users who perform account management activities in the database
  • Oracle Data Dictionary this defines the realm for catalog users
  • Oracle Database Vault this defines realm for oracle database vault users such as DVF and DVSYS schemas
  • Oracle Enterpise Manager this is basically for the enterprise manager users such as SYSMAN and DBSNMP who wants to access oracle database information

Now let’s create new realm for securing EMPLOYEES table in the HR schema, click create. In the create realm page enter the name of the realm, the description of the realm, status  and different auditing options( Audit on failure – will generate an audit record when there is a realm failure) and click OK to create realm.

bp12

Now you can see HR_realm in this list:

bp12

To protect the objects of the HR schema, select HR_realm and click edit .

bp14

In this realm   under the Realm Secured Objects you can see there are no objects which are protected. Click create and specify object owner, object type and object name which need to be secured.  As I am securing the object of HR schema,  i am specifying object owner as HR, object type as Table and object name as %-this will protect all the tables in the HR schema and click OK.

bp15

Now all tables under HR are protected. Let’s go to database and test how the securing objects of HR_realm has affected access of user demo to this tables .Earlier when the realm was not created demo user was able to access to table EMPLOYEES of HR schema.

Connect as DEMO user and again perform select statement :

SQL> select * from HR.EMPLOYEES;

ERROR at line 1:
ORA-01031: insufficient privileges

And you will get error “insufficient privileges” this means HR.EMPLOYEES table is protected by the REALM. This is how the REALM authorization or REALM protection  works. Lets go back database vault administration console.

bp16

We saw that some of object are protected here, but users not authorized to access the objects of this realm. To authorize users to access objects of this realm select HR_realm , click  edit , go to section Realm Authorizations and click the create button. In the create Realm Authorization page you can see Grantee, Authorization type and Authorization Rule Set. I am specifying Grantee as Demo user , authorization type is participant-that means this user will be able to access the objects of this realm, if  I specify the Authorization Options as OWNER I would have same functionality as Participant along with that it will have  additional privilege to grantee access to the objects authorized by this realm and  Authorization Rule Set – not specifying any rule set here:

bp17

Now let’s see how a Command rule functions in the DV and management.

Connect as sysdba, grantee create any table privilege to demo user.
Then create table SCOTT.TBL_TEST with user demo.

[oracle@orcl ~]$ sqlplus / as sysdba
SQL> grant create any table to demo ;
Grant succeeded.
SQL> conn demo/demo
Connected.
SQL> create table SCOTT.TBL_TEST(NAME VARCHAR2(10),MARKS NUMBER);
Table created.

Now let’s go to Database Vault console and click on Command rules.

bp18

As we had default realms we also have certain default command rules offered by oracle database vault . This command rules is to restrict execution of following commands in the database. To create new command rule, click create button. In the create command rule page, you can select the command which you want to restrict. Here I want to restrict creating any table in SCOTT schema by user demo:

bp19

And click OK to create command rule. Here you can see that  there is new command rule created.

bp20

Now let’s go back to database and test how create table statement works now:

SQL> conn demo/demo
Connected.
SQL> create table SCOTT.TEST as select * from ALL_OBJECTS;
create table SCOTT.TEST as select * from ALL_OBJECTS
                                         *
ERROR at line 1:
ORA-47400: Command Rule violation for CREATE TABLE on SCOTT.TEST

Here I try to create table under SCOTT, but I get  command rule violation for CREATE TABLE on SCOTT

Let’s look to small example how we can restrict access from a certain programs or modules.
Lets create Factor click on Factors and select create:

bp21

In the create new factor page fill specified name, description and Factor type.
Here we will create factor to find name the application from which database is going to connect and where we are going to block access from SQL*PLUS.

bp22

Now I will configure rule set:
bp23

Click create and  specify name, description for rule set , select status enabled and Evaluation Options All True – which means all the conditions which you specified should be evaluated to true, auditing options disabled. Then click OK.

bp24

After creating rule set edit it and click on create button to create Rules Associated to The Rule Set. Here we specified Rule Expression as DVF.F$MODULE=’SQL*PLUS.EXE’ and DVF.F$SESSION_USER IN(‘SCOTT’). DVF.F$MODULE here means that we created factor called MODULE, ‘SQL*PLUS.EXE’ here means any connections coming from sqlplus, DVF.F$SESSION_USER IN(‘SCOTT’)- means session user as SCOTT. All this means that if the user is SCOTT and SCOTT is connecting to the database using SQLPLUS it should be allowed to connect and none of the other users should be allowed to connect. Click ok and create rule.

bp25

Now I will create command rule to restrict connection to the database:

bp26

Now let’s go back to my database and test how this command rule works:

SQL> conn scott
Enter password: <your password>
Connected.
SQL> conn demo
Enter password: <your password>
ERROR:
ORA-47400: Command Rule violation for CONNECT on LOGON
Warning: You are no longer connected to ORACLE.
SQL>

During the connect with demo user we get ERROR Command Rule violation. This means that any user other than scott are not allowed to connect to the database using SQLPLUS.

ORACLE DATABASE VAULT REPORTS

There are two categories of DV reports- Oracle database Vault reports and General Security reports

  • Database Vault Reports are basically to give the information about the different components of the database vault such as Realms, their authorization violations, command rule violations, factors, rule sets and security application rules.
  • General Security Reports are the general reports such as user authorization, privileges, rules, object and system privileges and also it gives special reports for the security vulnerability issues

To see this reports login to the Database Vault Administration console and click on the Database Vault Reports tab:

bp27

Click on Realm Audit Report and Run Report, now you can see report which shows you different kind of realm violations:

bp28

Now let’s look command rule audit reports, here we can see command and returned error codes:

bp29

Let’s see General Security Reports:

bp30

Similarly you can select and run different reports.

Oracle Database Vault (part1)


1593501

Database Vault restricts access to the specific areas of the database from different users in the database as well as the administrative users. It also helps us to protect the database against insider threats. Insider threats, meaning the protecting database from the access users who have sysdba and sysoper privileges. Using database vault we can also enforce separation of duties where we can allocate different accounts for database account management and other database activities.

Database vault installation

Installation of the database vault includes two steps, enabling the database vault at the binary level and the registering database vault using dbca:
Enabling the database vault at the binary level
First of all, stop database console, listener and shutdown database. Database vault is dependent on oracle label security, so beforeinstallation of database vault you must enable label security.

Execute following  command :
For enabling label security component Chopt enable lbac
For enabling  database vault components Chopt enable dv

SQL> SHUTDOWN IMMEDIATE
SQL> EXIT
[oracle@orcl ~]$ emctl stop dbconsole
[oracle@orcl ~]$ lsnrctl stop
[oracle@orcl ~]$ chopt enable lbac 
Writing to /u01/app/oracle/product/11.2/db_1/install/enable_lbac.log...
%s_unixOSDMakePath% -f /u01/app/oracle/product/11.2/db_1/rdbms/lib/ins_rdbms.mk lbac_on
%s_unixOSDMakePath% -f /u01/app/oracle/product/11.2/db_1/rdbms/lib/ins_rdbms.mk ioracle

[oracle@orcl ~]$ chopt enable dv
Writing to /u01/app/oracle/product/11.2/db_1/install/enable_dv.log...
%s_unixOSDMakePath% -f /u01/app/oracle/product/11.2/db_1/rdbms/lib/ins_rdbms.mk dv_on
%s_unixOSDMakePath% -f /u01/app/oracle/product/11.2/db_1/rdbms/lib/ins_rdbms.mk ioracle

Run the following commands. The make command enables both Oracle Database Vault (dv_on) and Oracle Label Security (lbac_on). You must enable Oracle Label Security before you can use Database Vault.

[oracle@orcl Datafiles]$ cd $ORACLE_HOME/rdbms/lib
[oracle@orcl lib]$ make -f ins_rdbms.mk dv_on lbac_on
/usr/bin/ar d /u01/app/oracle/product/11.2/db_1/rdbms/lib/libknlopt.a kzvndv.o
/usr/bin/ar cr /u01/app/oracle/product/11.2/db_1/rdbms/lib/libknlopt.a /u01/app/oracle/product/11.2/db_1/rdbms/lib/kzvidv.o 
/usr/bin/ar d /u01/app/oracle/product/11.2/db_1/rdbms/lib/libknlopt.a kzlnlbac.o
/usr/bin/ar cr /u01/app/oracle/product/11.2/db_1/rdbms/lib/libknlopt.a /u01/app/oracle/product/11.2/db_1/rdbms/lib/kzlilbac.o 
[oracle@orcl lib]$ cd $ORACLE_HOME/bin
[oracle@orcl bin]$ relink all
writing relink log to: /u01/app/oracle/product/11.2/db_1/install/relink.log

Start the database, database control console process, and listener. Then run DBCA command to register Database Vault

[oracle@orcl ~]$ emctl start dbconsole
[oracle@orcl ~]$ lsnrctl start
SQL> startup;
ORACLE instance started.
Total System Global Area  534462464 bytes
Fixed Size		    2254952 bytes
Variable Size		  213911448 bytes
Database Buffers	  314572800 bytes
Redo Buffers		    3723264 bytes
Database mounted.
Database opened.

[oracle@orcl ~]$ dbca

Select configure database option to configure database vault

bp1

Select the database which will be configured for database vault

bp2

Select label security component and dv components click next

bp3

Also we can select this options when installing oracle database :

bp4

In the next screen you must specify the username and password for database vault owner and account manager.

bp5

And click next, select dedicated server mode , click ok and then finsh database vault configuration.

bp6

bp7

bp8

You can check if Oracle Database Vault is enabled or disabled by querying the V$OPTION data dictionary view. If Oracle Database Vault is enabled, the query returns TRUE. Otherwise, it returns FALSE.

Remember that the PARAMETER column value is case sensitive. For example:

SQL> SELECT * FROM V$OPTION WHERE PARAMETER = 'Oracle Database Vault';

PARAMETER                                                                   VALUE
---------------------------------------------------------------- ---------------
Oracle Database Vault                                                      TRUE

In the next blog post i will write about Oracle database Vault Access Control Components, changes happened after Database Vault installation and management of Database Vault.

Using Password Files


Password files allow you to set passwords that are stored outside the database and that are used for authenticating administrators. These passwords are stored in an external file that is encrypted by Oracle. Password files can be even used if the database is down-so. You can use this passwords even if database is down .

To create a password file use the ORAPWD utility:

[oracle@orcl ~]$ orapwd file=./test_pwd entries=100 ignorecase=n
Enter password for SYS: 
[oracle@orcl ~]$ 

After creating the password file, you must set the REMOTE_LOGIN_PASSWORDFILE initialization parameter to an appropriate value (  NONE, EXCLUSIVE and SHARED ).
NONE-causing Oracle to behave as though a password file does not exist. EXCLUSIVE means that the password file is being used only by your database and that you can modify it from within the database . SHARED-allows you to use a single password file for multiple databases, but none of them can update the password file. If you need to update the password file then you need to switch this parameter to EXCLUSIVE in one of the databases, change the password file and then change it back to be used as SHARED.

SQL> show parameter remote_login_passwordfile;

NAME				        TYPE	   VALUE
--------------------------  ----------- ---------------
remote_login_passwordfile	  string	   EXCLUSIVE

Now try connect to oracle as sysdba from other machine

C:UsersValeh>sqlplus sys@db11g as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Sun Jul 5 00:17:21 2015
Copyright (c) 1982, 2010, Oracle.  All rights reserved.
Enter password:

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>

OS Authentication


OS authentication is used to  authenticate user  at the OS level to connect  to the database. For OS authentication OS username must be mapped to the Oracle user name. The initialization parameter OS_AUTHENT_PREFIX controls that mapping. This value is concatenated with the OS username and used as the database user. Default value for OS_AUTHENT_PREFIX parameter ops$. If the default value is not changed, then database user of the OS user valeh will be ops$valeh.If this value is set to null then you will log onto the database as user valeh.

SQL> show parameter os_authent_prefix;

NAME				  TYPE	 VALUE
-------------------- ---------- -------------
os_authent_prefix     string	 ops$
SQL> 

To allow access from OS users, you must enable remote OS authentication, create a user and grant privileges :

--Fisrt create OS user for testing

[root@orcl ~]# useradd valeh
[root@orcl ~]# passwd valeh
Changing password for user valeh.
New password: 
Retype new password: 
passwd: all authentication tokens updated successfully.

SQL> show parameter remote_os_authent;
NAME 		      	TYPE 		VALUE
------------------ ----------- ----------------
remote_os_authent     boolean	FALSE

SQL> alter system set remote_os_authent=true scope=spfile;
SQL> shutdown
SQL> startup
 
SQL> show parameter remote_os_authent;
NAME			     TYPE	      VALUE
------------------  ---------- --------------
remote_os_authent    boolean     TRUE

SQL> create user ops$valeh identified externally;

User created.
SQL> grant create session to ops$valeh;

Grant succeeded.
 

Log in to the new created user, set oracle environment variables and run sqlplus, you don’t need to specify a username or a password to logon to Oracle:

[root@orcl ~]# su - valeh
[valeh@orcl ~]$ sqlplus /

SQL*Plus: Release 11.2.0.1.0 Production on Thu Jul 2 19:56:37 2015
Copyright (c) 1982, 2009, Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> show user
USER is "OPS$VALEH"

Oracle Wallet


What is Oracle Wallet

Oracle wallet is a password-protected container for authentication and signing credentials, including private keys, certificates and other secrets that you need to secure over time.

How to create Oracle wallets

Wallets are created using OWM or orapki utility.  To use orapki you can run orapki wallet command (orapki wallet create -wallet  )
Password for walet must be strong :

[oracle@orcl]$ orapki wallet create -wallet /u01/app/oracle/product/11.2/db_1/wallets
Oracle PKI Tool : Version 11.2.0.1.0 - Production
Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved.
Enter password:            
Enter password again: 

[oracle@orcl]$ ls /u01/app/oracle/product/11.2/db_1/wallets/
ewallet.p12

To display the contents of a wallet:


[oracle@orcl wallets]$ orapki wallet display -wallet /u01/app/oracle/product/11.2/db_1/wallets
Oracle PKI Tool : Version 11.2.0.1.0 - Production
Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved.

Enter wallet password:            

Requested Certificates: 
User Certificates:
Trusted Certificates: 
Subject:        OU=Class 1 Public Primary Certification Authority,O=VeriSign, Inc.,C=US
Subject:        OU=Class 3 Public Primary Certification Authority,O=VeriSign, Inc.,C=US
Subject:        OU=Class 2 Public Primary Certification Authority,O=VeriSign, Inc.,C=US
Subject:        OU=Secure Server Certification Authority,O=RSA Data Security, Inc.,C=US
Subject:        CN=GTE CyberTrust Global Root,OU=GTE CyberTrust Solutions, Inc.,O=GTE Corporation,C=US
[oracle@orcl wallets]$ 

All of these operations also can be performed by Oracle Wallet Manager (OWM) utility.
Just call owm from command line, then select wallet-> open from wallet manager, select wallets directory and type your password.

2

To create self-signed root certificate use wallet add command:

[oracle@orcl ~]$ orapki wallet add -wallet $ORACLE_HOME/wallets -dn 
"CN=testsecurity Root,O=testsecurity,C=US" -self_signed -validity 365 -keysize 1024
Oracle PKI Tool : Version 11.2.0.1.0 - Production
Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved.

Enter wallet password:            

[oracle@orcl ~]$ 

When you use self_signed keyword your certificate will created immediately because you are acting as the Certificate Authority(CA).
Let’s display self signed certificate from orapki and OWM:

[oracle@orcl ~]$ orapki wallet display -wallet $ORACLE_HOME/wallets
Oracle PKI Tool : Version 11.2.0.1.0 - Production
Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved.

Enter wallet password:            

Requested Certificates: 
User Certificates:
Subject:        CN=testsecurity Root,O=testsecurity,C=US
Trusted Certificates: 
Subject:        OU=Class 1 Public Primary Certification Authority,O=VeriSign, Inc.,C=US
Subject:        OU=Secure Server Certification Authority,O=RSA Data Security, Inc.,C=US
Subject:        CN=testsecurity Root,O=testsecurity,C=US
Subject:        CN=GTE CyberTrust Global Root,OU=GTE CyberTrust Solutions, Inc.,O=GTE Corporation,C=US
Subject:        OU=Class 3 Public Primary Certification Authority,O=VeriSign, Inc.,C=US
Subject:        OU=Class 2 Public Primary Certification Authority,O=VeriSign, Inc.,C=US

In OWM you will see the new certificate as shown bellow:


To create and sign certificate request:

[oracle@orcl ~]$ orapki wallet add -wallet $ORACLE_HOME/wallets -dn "CN=test,O=testsecurity,C=US" -keysize 1024
Oracle PKI Tool : Version 11.2.0.1.0 - Production
Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved.
 
Enter wallet password:            
 
[oracle@orcl ~]$ 

 

If look at the contents of the wallet now you’ll see the new certificate request:

[oracle@orcl ~]$ orapki wallet display -wallet $ORACLE_HOME/wallets
Oracle PKI Tool : Version 11.2.0.1.0 - Production
Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved.

Enter wallet password:            

Requested Certificates: 
Subject:        CN=test,O=testsecurity,C=US
User Certificates:
Subject:        CN=testsecurity Root,O=testsecurity,C=US
Trusted Certificates: 
Subject:        OU=Class 2 Public Primary Certification Authority,O=VeriSign, Inc.,C=US
Subject:        OU=Secure Server Certification Authority,O=RSA Data Security, Inc.,C=US
Subject:        CN=GTE CyberTrust Global Root,OU=GTE CyberTrust Solutions, Inc.,O=GTE Corporation,C=US
Subject:        CN=testsecurity Root,O=testsecurity,C=US
Subject:        OU=Class 3 Public Primary Certification Authority,O=VeriSign, Inc.,C=US
Subject:        OU=Class 1 Public Primary Certification Authority,O=VeriSign, Inc.,C=US

 

Export the certificate request so that you can sign it anywhere:

[oracle@orcl ~]$ orapki wallet export -wallet /u01/app/oracle/product/11.2/db_1/wallets/ -dn "CN=test,O=testsecurity,C=US" -request ./test.req
Oracle PKI Tool : Version 11.2.0.1.0 - Production
Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved.

Enter wallet password:            

[oracle@orcl ~]$ ls -l ./test.req 
-rw-------. 1 oracle oinstall 584 Jun 28 18:53 ./test.req

 

Create signed certificate from request:

[oracle@orcl ~]$ orapki cert create -wallet /u01/app/oracle/product/11.2/db_1/wallets/ -request ./test.req -cert ./test.cert -validity 365
Oracle PKI Tool : Version 11.2.0.1.0 - Production
Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved.
Enter wallet password:            

[oracle@orcl ~]$ ls -l ./test.cert 
-rw-------. 1 oracle oinstall 706 Jun 28 19:28 ./test.cert

 

Certificate file is created but it is not in any wallet. If you display wallet you will not see the certificate there:

[oracle@orcl ~]$ orapki wallet display -wallet /u01/app/oracle/product/11.2/db_1/wallets/
Oracle PKI Tool : Version 11.2.0.1.0 - Production
Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved.
Enter wallet password:            

Requested Certificates: 
Subject:        CN=test,O=testsecurity,C=US
User Certificates:
Subject:        CN=testsecurity Root,O=testsecurity,C=US
Trusted Certificates: 
Subject:        OU=Class 2 Public Primary Certification Authority,O=VeriSign, Inc.,C=US
Subject:        OU=Secure Server Certification Authority,O=RSA Data Security, Inc.,C=US
Subject:        CN=GTE CyberTrust Global Root,OU=GTE CyberTrust Solutions, Inc.,O=GTE Corporation,C=US
Subject:        CN=testsecurity Root,O=testsecurity,C=US
Subject:        OU=Class 3 Public Primary Certification Authority,O=VeriSign, Inc.,C=US
Subject:        OU=Class 1 Public Primary Certification Authority,O=VeriSign, Inc.,C=US

 

You need to add the certificate into a wallet .Both certificate request and the certificates are text files which you can copy over to any other server:


[oracle@orcl ~]$ cat test.cert 
-----BEGIN CERTIFICATE-----
MIIB3zCCAUgCAQAwDQYJKoZIhvcNAQEEBQAwPjELMAkGA1UEBhMCVVMxFDASBgNVBAoTC2RiYXNl
Y3VyaXR5MRkwFwYDVQQDExBkYmFzZWN1cml0eSBSb290MB4XDTE1MDYyODE0MjgwNloXDTE2MDYy
NzE0MjgwNlowMjELMAkGA1UEBhMCVVMxFDASBgNVBAoTC2RiYXNlY3VyaXR5MQ0wCwYDVQQDEwR0
ZXN0MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCvmRabzSLBNcL6GjYK4baLezp3yAq9bGGI
jqAGG4T/XNX0kpIEG3jV9xcrMCiInC56YjZ8FuC1ITmdqqlfn9BxE/ImGJcHLCVJtxXL8GDDqiZK
hgCoT16vOYbIaq4VpQJPwqttaK2JEnlRMUcTkemhMa5NzfmJHmB9p9NI/FG/hwIDAQABMA0GCSqG
SIb3DQEBBAUAA4GBADNUZX4MdP8tPYAxR/dpzQiDAJwrG6ohtSRmLbvRsBHyB86d0pM03yt4bAW5
5QLebXH5VVkzOVaizBDrN/gfL8WJlf/qoMCntGxudOT1Wdn3osGRPOhsT/+q+yBnPribcOCz7N9T
E2aZhJYACULMZfh2n/Jk477/O90CXUfn8mRZ
-----END CERTIFICATE-----
[oracle@orcl ~]$ cat test.req 
-----BEGIN NEW CERTIFICATE REQUEST-----
MIIBcTCB2wIBADAyMQswCQYDVQQGEwJVUzEUMBIGA1UEChMLZGJhc2VjdXJpdHkxDTALBgNVBAMT
BHRlc3QwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAK+ZFpvNIsE1wvoaNgrhtot7OnfICr1s
YYiOoAYbhP9c1fSSkgQbeNX3FyswKIicLnpiNnwW4LUhOZ2qqV+f0HET8iYYlwcsJUm3FcvwYMOq
JkqGAKhPXq85hshqrhWlAk/Cq21orYkSeVExRxOR6aExrk3N+YkeYH2n00j8Ub+HAgMBAAGgADAN
BgkqhkiG9w0BAQQFAAOBgQB+v4nCX/9HhCoqdimfznyVxPeDg6uspLo1uteqxPBkmqSyASWxafob
h+tZaFXY7cDw0VFlycjuot5wCWLqXejMpnAmGiJwi6VgziJt7TUpfJw6k3Ga1uarRCV22OWpNt43
tWvApcY0Z4MJXjFFzCpFFI8teeA146i422Zln0HgWQ==
-----END NEW CERTIFICATE REQUEST-----
[oracle@orcl ~]$ 

 

You can add the certificate  either as a user certificate or as a trusted certificate. For example , to add the certificate as user certificate:

[oracle@orcl ~]$ orapki wallet add -wallet /u01/app/oracle/product/11.2/db_1/wallets/ -user_cert -cert ./test.cert 
Oracle PKI Tool : Version 11.2.0.1.0 - Production
Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved.

Enter wallet password:            

[oracle@orcl ~]$ 

 

Now certificates will show up in the user session:

[oracle@orcl ~]$ orapki wallet display -wallet /u01/app/oracle/product/11.2/db_1/wallets/
Oracle PKI Tool : Version 11.2.0.1.0 - Production
Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved.

Enter wallet password:            

Requested Certificates: 
User Certificates:
Subject:        CN=test,O=testsecurity,C=US
Subject:        CN=testsecurity Root,O=testsecurity,C=US
Trusted Certificates: 
Subject:        OU=Secure Server Certification Authority,O=RSA Data Security, Inc.,C=US
Subject:        OU=Class 2 Public Primary Certification Authority,O=VeriSign, Inc.,C=US
Subject:        CN=testsecurity Root,O=testsecurity,C=US
Subject:        OU=Class 3 Public Primary Certification Authority,O=VeriSign, Inc.,C=US
Subject:        OU=Class 1 Public Primary Certification Authority,O=VeriSign, Inc.,C=US
Subject:        CN=GTE CyberTrust Global Root,OU=GTE CyberTrust Solutions, Inc.,O=GTE Corporation,C=US
[oracle@orcl ~]$ 

 

If you want to this certificate to be part of trust  hierarchy you can add it as a trusted certificate  into the wallet:

[oracle@orcl ~]$ orapki wallet add -wallet /u01/app/oracle/product/11.2/db_1/wallets/ -trusted_cert -cert ./test.cert 
Oracle PKI Tool : Version 11.2.0.1.0 - Production
Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved.

Enter wallet password: 

 

The certificate will now show up in the trusted certificate section:

[oracle@orcl ~]$ orapki wallet display -wallet /u01/app/oracle/product/11.2/db_1/wallets/
Oracle PKI Tool : Version 11.2.0.1.0 - Production
Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved.

Enter wallet password:            

Requested Certificates: 
User Certificates:
Subject:        CN=test,O=testsecurity,C=US
Subject:        CN=testsecurity Root,O=testsecurity,C=US
Trusted Certificates: 
Subject:        OU=Class 1 Public Primary Certification Authority,O=VeriSign, Inc.,C=US
Subject:        CN=testsecurity Root,O=testsecurity,C=US
Subject:        CN=GTE CyberTrust Global Root,OU=GTE CyberTrust Solutions, Inc.,O=GTE Corporation,C=US
Subject:        OU=Class 3 Public Primary Certification Authority,O=VeriSign, Inc.,C=US
Subject:        CN=test,O=testsecurity,C=US
Subject:        OU=Secure Server Certification Authority,O=RSA Data Security, Inc.,C=US
Subject:        OU=Class 2 Public Primary Certification Authority,O=VeriSign, Inc.,C=US
[oracle@orcl ~]$ 

Limit connections to listener by source


1If you want to limit access to database from specific host names or ip addresses you must use feature called valid node checking. This feature allows you to define two lists :

  • invited nodes defines a set of nodes from which connections will be accepted
  • excluded_nodes – defines a list from which connections will be rejected

If you use invited_nodes then any node not in this list will be rejected by listener or if you use excluded_nodes then any node not in this list will be accepted by the listener. If you both of these lists, then invited_nodes take precedence over the excluded_nodes. To test invited_nodes list you must add following lines to the sqlnet.ora file:

[oracle@orcl ~]$ vi /u01/app/oracle/product/11.2/db_1/network/admin/sqlnet.ora 
# sqlnet.ora Network Configuration File: /u01/app/oracle/product/11.2/db_1/network/admin/sqlnet.ora
# Generated by Oracle configuration tools.
ADR_BASE = /u01/app/oracle
tcp.validnode_checking=YES
tcp.invited_nodes=(ValehPC,192.168.100.13)

[oracle@orcl u01]$ lsnrctl stop
[oracle@orcl u01]$ lsnrctl start

After changes applied, when you try to connect from any node apart from these two you will get an error like bellow:

when trying to connect with SQL Plus

C:UsersValeh>sqlplus test/test@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.100.177)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=db11g)))

SQL*Plus: Release 11.2.0.1.0 Production on Thu Jun 18 05:01:57 2015

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

ERROR:
ORA-12537: TNS:connection closed

when trying connect with Oracle SQL Developer

1

Secure access to listener


Listener-ə müraciətin təhlükəsiz təşkili listenerin vacib təhlükəsizlik tədirləridən biridir, çunki serverinizə şəbəkə vasitəsilə hücum təşkil edib listeneri ələ keçirən şəxslər listeneri idarə edərək sizin sizin DB-nı sondürə bilər. Lsnrctl vasitəsilə listeneri idarə etməyin qarşısını almaq üçün şifrə təyin olunmalıdır. Əgər lsnrctl status komandasının nəticəsində Security sətrində OFF yazılıbsa deməli listener üçün şifrə təyin olunmamışdır.Oracle 10g and 11g-də listener  üçün susmaya görə Local OS authentication adlanan təhlükəsizlik növü təyin olunur. Local OS authentication o deməkdir ki, siz listeneri  idarə edə bilmək üçün listenerin işlədiyi host-a login olmuş olmalısınız. Biz bunu lsnrctl status komandasını işlədərək  aşağıdakı nəticədə görə bilərik

[pcsh lang=”plain” tab_size=”4″ message=”” hl_lines=”” provider=”manual”]

[oracle@orcl ~]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 09-JUN-2015 01:44:59

::::::::::::::output trimmed::::::::::::::

------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                09-JUN-2015 01:17:51
Uptime                    0 days 0 hr. 27 min. 8 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
::::::::::::::output trimmed::::::::::::::

[/pcsh]

Local OS Authentication-un ləğv edilməsi

Local OS Authentication ləğv etmək üçün listener.ora faylını redaktə edərək local_os_authentication_LISTENER parameterinə OFF  qiymətini mənimsətmək lazımdır:

[pcsh lang=”plain” tab_size=”4″ message=”” hl_lines=”” provider=”manual”]

[oracle@orcl ~]$ vi /u01/app/oracle/product/11.2/db_1/network/admin/listener.ora
#---- OUTPUT TRIMMED ----#
local_os_authentication_LISTENER=off
 

[/pcsh]

Listener-ə açıq tekst formatında şifrənin təyini

Listener-ə açığ text tipli şifrə təyin etmək üçün $ORACLE_HOME/network/admin/listener.ora faylını redaktə edib PASSWORDS_{LISTENER_ADI}=sizinşifrə sətrini əlavə etmək lazımdır.
Biz həmşinin listener-ə bir neçə şifrədə təyin edə bilərik:   PASSWORDS_LISTENER=(password1,password2)

Nümunə:

[pcsh lang=”plain” tab_size=”4″ message=”” hl_lines=”” provider=”manual”]

[oracle@orcl ~]$ vi /u01/app/oracle/product/11.2/db_1/network/admin/listener.ora

# listener.ora Network Configuration File: /u01/app/oracle/product/11.2/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = orcl.localdomain)(PORT = 1521))
    )
  )

ADR_BASE_LISTENER = /u01/app/oracle

#clear type password
PASSWORDS_LISTENER=(test123,test654)

[/pcsh]

Listenerə heşlənmiş şifrənin təyin olunması

Listenerə heşlənmiş şifrə təyin etmək və ya redaktə etmək və yadda saxlamaq üçün set password, change_password və save_config komandalarından aşağıdakı qaydada istifadə etmək lazımdır :

[pcsh lang=”plain” tab_size=”4″ message=”” hl_lines=”” provider=”manual”]

#using set password
LSNRCTL> set password
Password: 
The command completed successfully
LSNRCTL> save_config
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=orcl.localdomain)(PORT=1521)))
No changes to save for LISTENER.
The command completed successfully
LSNRCTL> 

#using change password
LSNRCTL> change_password 
Old password:  
New password:  
Reenter new password:  
Connecting to 
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=orcl.localdomain)(PORT=1521))) 
Password changed for LISTENER 
The command completed successfully 
LSNRCTL> save_config 
Connecting to 
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=orcl.localdomain)(PORT=1521))) 
Saved LISTENER configuration parameters. 
Listener Parameter File   /u01/app/oracle/product/11.2/db_1/network/admin/listener.ora 
Old Parameter File   /u01/app/oracle/product/11.2/db_1/network/admin/listener.bak 
The command completed successfully 

[/pcsh]

Şifrə təyin edildikdən sonra  security sətri ​Password or Local OS authentication yazısına dəyişir.

[pcsh lang=”plain” tab_size=”4″ message=”” hl_lines=”” provider=”manual”]

LSNRCTL> status 
::::::::::::::output trimmed:::::::::::::: 
Security                  ON: Password or Local OS Authentication 
SNMP                      OFF 
::::::::::::::output trimmed:::::::::::::: 

[/pcsh]

Şifrə listener.ora faylında heşlənmiş formatda saxlanılır, listener.ora faylının işinə baxmaqla bunu görmək olar:

[pcsh lang=”plain” tab_size=”4″ message=”” hl_lines=”” provider=”manual”]

 
[oracle@orcl ~]$ vi /u01/app/oracle/product/11.2/db_1/network/admin/listener.ora 
 
LISTENER = 
  (DESCRIPTION_LIST = 
    (DESCRIPTION = 
      (ADDRESS = (PROTOCOL = TCP)(HOST = orcl.localdomain)(PORT = 1521)) 
    ) 
  ) 
ADR_BASE_LISTENER = /u01/app/oracle 
 
#----ADDED BY TNSLSNR 09-JUN-2015 01:56:41--- 
PASSWORDS_LISTENER = 9BD20802761D432E 
#-------------------------------------------- 

[/pcsh]

Listener üçün təyin olunmuş şifrəni ləğv etmək üçün aşağıdakı addımları etmək lazımdır:

İlk olaraq listeneri aşağıdakı komanda vasitəsilə dayandırıq

[pcsh lang=”plain” tab_size=”4″ message=”” hl_lines=”” provider=”manual”]

LSNRCTL> stop
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC0)))
The command completed successfully
LSNRCTL>   

[/pcsh]

Daha sonra listener.ora faylını redaktə edərək şifrə olan sətri silirik və listeneri restart edirik.
Securing access to the listener is a one of the important aspects of listener security, because if the attacker can access to control the lsnrctl he can shut down your database. To limit access to the ability to control the listener through the lsnrctl you must set a password. If a security row is OFF in the result of the lsnrctl status command it means that there is no password set for the listener. In Oracle 10g and 11g the listener is securing by default using an option called Local OS authentication. Local OS authentication means that, you can control the listener if you are logged on to the account on the host where the listener is running. You can see it with lsnrctl status command:

[pcsh lang=”plain” tab_size=”4″ message=”” hl_lines=”” provider=”manual”]

[oracle@orcl ~]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 09-JUN-2015 01:44:59

::::::::::::::output trimmed::::::::::::::

------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                09-JUN-2015 01:17:51
Uptime                    0 days 0 hr. 27 min. 8 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
::::::::::::::output trimmed::::::::::::::

[/pcsh]

Disable Local OS Authentication

To disable Local OS Authentication you must set local_os_authentication_LISTENER parameter to OFF in listener.ora file:

[pcsh lang=”plain” tab_size=”4″ message=”” hl_lines=”” provider=”manual”]

[oracle@orcl ~]$ vi /u01/app/oracle/product/11.2/db_1/network/admin/listener.ora
#---- OUTPUT TRIMMED ----#
local_os_authentication_LISTENER=off
 

[/pcsh]

Setting clear text format  password for listener

To set a listener password in clear text format open the  $ORACLE_HOME/network/admin/listener.ora file and add a line to this file with the following format: PASSWORDS_{LISTENER_NAME}=yourpassword
If you want, you  can set multiple passwords for listener:   PASSWORDS_LISTENER=(password1,password2)

for example:

[pcsh lang=”plain” tab_size=”4″ message=”” hl_lines=”” provider=”manual”]

[oracle@orcl ~]$ vi /u01/app/oracle/product/11.2/db_1/network/admin/listener.ora

# listener.ora Network Configuration File: /u01/app/oracle/product/11.2/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = orcl.localdomain)(PORT = 1521))
    )
  )

ADR_BASE_LISTENER = /u01/app/oracle

#clear type password
PASSWORDS_LISTENER=(test123,test654)

[/pcsh]

Setting an encrypted  password for listener

To set, change and save password you can use set password or change_password and save_config commands as shown above :

[pcsh lang=”plain” tab_size=”4″ message=”” hl_lines=”” provider=”manual”]

#using set password
LSNRCTL> set password
Password: 
The command completed successfully
LSNRCTL> save_config
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=orcl.localdomain)(PORT=1521)))
No changes to save for LISTENER.
The command completed successfully
LSNRCTL> 

#using change password
LSNRCTL> change_password 
Old password:  
New password:  
Reenter new password:  
Connecting to 
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=orcl.localdomain)(PORT=1521))) 
Password changed for LISTENER 
The command completed successfully 
LSNRCTL> save_config 
Connecting to 
(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=orcl.localdomain)(PORT=1521))) 
Saved LISTENER configuration parameters. 
Listener Parameter File   /u01/app/oracle/product/11.2/db_1/network/admin/listener.ora 
Old Parameter File   /u01/app/oracle/product/11.2/db_1/network/admin/listener.bak 
The command completed successfully 

[/pcsh]

After setting password  security option of the listener changes to ​Password or Local OS authentication

[pcsh lang=”plain” tab_size=”4″ message=”” hl_lines=”” provider=”manual”]

LSNRCTL> status 
::::::::::::::output trimmed:::::::::::::: 
Security                  ON: Password or Local OS Authentication 
SNMP                      OFF 
::::::::::::::output trimmed:::::::::::::: 

[/pcsh]

The password is saved in listener.ora file as a hashed entry, you can check what was generated by looking in the listener.ora file:

[pcsh lang=”plain” tab_size=”4″ message=”” hl_lines=”” provider=”manual”]

 
[oracle@orcl ~]$ vi /u01/app/oracle/product/11.2/db_1/network/admin/listener.ora 
 
LISTENER = 
  (DESCRIPTION_LIST = 
    (DESCRIPTION = 
      (ADDRESS = (PROTOCOL = TCP)(HOST = orcl.localdomain)(PORT = 1521)) 
    ) 
  ) 
ADR_BASE_LISTENER = /u01/app/oracle 
 
#----ADDED BY TNSLSNR 09-JUN-2015 01:56:41--- 
PASSWORDS_LISTENER = 9BD20802761D432E 
#-------------------------------------------- 

[/pcsh]

To remove the listener password you should  do the following:

First stop the listener

[pcsh lang=”plain” tab_size=”4″ message=”” hl_lines=”” provider=”manual”]

LSNRCTL> stop
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC0)))
The command completed successfully
LSNRCTL>   

[/pcsh]

Then edit the listener.ora file and remove the lines added above and restart the listener.