OWASP Backend Security Project Oracle Hardening

= Overview =

= Description =

Installation security
This section is useful to understand how the installation will introduce vulnerabilities if it is not made “security oriented”.

Options and products
The Oracle Database installation pack contains a lot of options and products in addition to the database server, so it is suggest to do a custom installation to avoid installing options and products not needed. The Oracle components other than the list below have to be removed if not specifically required by any database applications.

Sample schemas
Oracle Corporation provides sample schemas in order to provide a common platform for examples. Review, after the installation, installed schema and remove any schema you do not need.

Patching
Apply, always, all security patches for Oracle Database itself, and for all the options and components that are installed. Periodically check the security site on Oracle Technology Network for details on security alerts released by Oracle Corporation:

http://otn.oracle.com/deploy/security/alerts.htm

Further, if you subscribe the security mailing lists you will be able to catch any new security issues that are not reported to Oracle but are announced to the public (maybe without a patch). In such cases, it will be relevant to find a way to mitigate the risk of the new vulnerability in the absence of an Oracle-supplied patch.

Initialization parameters
This section cover the Oracle Initialization parameters that are relevant for the security aspects. All the following initialization parameters have to be specified for all Oracle instances.

Example SQL for setting the REMOTE_OS_AUTHENTICATION parameter:

SQL> ALTER SYSTEM SET REMOTE_OS_AUTHENTICATION = FALSE SCOPE=BOTH

Scope:
 * MEMORY: This affects the database now; but will not remain after a restart.
 * SPFILE: This does not change the instance immediately, but it will will take effect after a restart.
 * BOTH: changes the current instance as well as the spfile.

Owner account
The Oracle OS installation account, owner of all Oracle application and datafiles, should be used only for the update and maintenance of the Oracle software and will not be used during the standard DBA activities. The individual DBAs will have to use their assigned OS personal accounts, so the auditing process will be able to actions performed with the correct OS account. The Oracle software installation account will not be a member of the administrative group.

Files and directories
All files and directories generated during the installation process of Oracle will be restricted to the Oracle software owner or the DBA OS user group, especially the file list below:

Other accounts should be denied access except to executables under the “bin” directory as specifically required. All files stored in the “bin” directory will be owned by the Oracle software installation account. These files and directories will be secured by using access control methods native to the operating system.

Lock and expire unused accounts
A number of default database server user accounts are create during the installation process so, if you do not use the Database Configuration Assistant, you should lock and expire all default database user accounts. Unlock only those accounts that need to be accessed on a regular basis and assign a strong password to each of these unlocked accounts.

Example SQL for reviewing the Oracle Default Accounts with status “OPEN”:

SQL> SELECT username FROM dba_users WHERE account_status <> ’OPEN’ ORDER BY username;

Example SQL for Locking Accounts:

SQL> ALTER USER owasp ACCOUNT lock;

Change default password
The most trivial method by which Oracle Database can be compromised is a default database server user account which still has a default password associated with it even after installation, so the passwords of all default accounts (SYS, SYSTEM, CTXSYS, MDSYS, DBSNMP, and OUTLN) should be changed.

Enforce password policy
The password policy should be enforced by password verification function setting password parameter (list below) and providing password complexity feature like minimum length, password not same as the username, the password contains repeating characters, the password differs from the previous password by at least a maximal number of letters.

Example SQL for setting a password verification function to a profile:

SQL> CREATE PROFILE  LIMIT PASSWORD_VERIFICATION_FUCTION

Example SQL for assigning profile profile to a user:

SQL> CREATE USER  IDENTIFIED BY PROFILE ;

Encrypt network logins
The password information in a connection request should be encrypted to protect against network eavesdropping. The value of the follow parameter should e review:

ORA_ENCRYPT_LOGIN (on the client machine) DBLINK_ENCRYPT_LOGIN (on the server machine)

Once these parameters have been set to TRUE, passwords will be encrypted in connection requests. On Oracle version 9.02 and later these parameter are not available, this is automatically handled when transmitting over a network. Note that the setting or changing of passwords across the network is NOT encrypted without other encryption configuration such as Oracle Advanced Security (OAS).

Protect network communications
As mentioned in the previous paragraph, administrative connections that may contain confidential information such as “account password changes” should be protected by encryption. If local encryption is not implemented (VPN), the Oracle Advanced Security (OAS) should be used and configured to use Secure Socket Layer (SSL) to encrypt network traffic between clients, databases, and application servers.

XML database (XDB) protocol server
The XML Database (XDB) offers access to the Oracle XML DB resources using the standard Internet protocols FTP, listening on TCP port 2100, and HTTP, listening on TCP port 8080. The Oracle XML DB Protocol Server is a specific type of Oracle shared server dispatcher and is specified in the Oracle database initialization parameter file for startup, so if XDB is not used it should be turned off editing the init.ora or spfile.ora (replace SID with the name of your SID) file and remove the follow line:

*.dispatchers='(PROTOCOL=TCP) (SERVICE=XDB)'

If access via the Internet protocols is required, logging will be enabled by setting the “ftp-log-level” and “http-log-level” parameters to a value of 1 instead of 0 in xdbconfig.xml file. It is also a good idea to configure the ports to a non-default port.

Password
A listener password should be set after listener configuration to avoid unauthorized users starting, stopping, and configuring the listener service. The password will be stored in encrypted format within the listener.ora file by using the LSNRCTL utility.

From the OS command prompt, type LSNRCTL and press Enter:

LSNRCTL> set password Password: (blank since there is initially no password assigned) The command completed successfully LSNRCTL> change_password Old password: (blank) New password: xxxxxx Reenter new password: xxxxxx […]  The command completed successfully LSNRCTL> save_config (required to save the password ! !) […]  Saved LISTENER configuration parameters. Listener Parameter File […] Old Parameter File […] The command completed successfully LSNRCTL> exit

The Listener password must be set on all listeners running on the system.

Admin restrictions
The remote administration of the Oracle listener should be prevent by setting to TRUE the ADMIN_RESTRICTIONS parameter in the listener.ora file:

ADMIN_RESTRICTIONS_listener_name = TRUE Replace listener_name with the name of your listener.

This will require that any configuration changes be made to the listener through direct edits to the listener.ora file.

Network address restriction
The network address restrictions should be enforced by the Oracle listener to further protect your database from unauthorized remote access. Network address restriction is required when the PLSQL EXTPROC is in use to protect against unauthenticated access to the database. To enable network address restriction, edit the SQLNET.ORA to add the follow line:

tcp.validnode_checking = YES

Then, to defines TCP/IP addresses that are allowed to connect to database add the follow line:

tcp.invited_nodes = {list of IP addresses}

At the end, to defines TCP/IP addresses that are refused connections to the database set the follow parameter

tcp.excluded_nodes = {list of IP addresses}

Inbound connection timeout
The controls of the amount of time the listener waits for a network client to complete the connection request should be configure to prevent a denial of service attack. To configure inbound connection timeout, set the follow parameter:

8i: LISTENER.ORA: CONNECT_TIMEOUT_< listener_name > = 3 9i: LISTENER.ORA: INBOUND_CONNECT_TIMEOUT_< listener_name > = 3 9i: SQLNET.ORA: SQLNET.INBOUND_CONNECT_TIMEOUT = 3

Replace listener_name with the name of your listener.

This parameter protects the listener from consuming and holding resources for client connection requests that do not complete. A malicious user could use this to flood the listener with requests that result in a denial of service to authorized users. To prevent this, secify, also, the expire_time parameter probes for dead connections and terminates them when found. This setting does cause a slight increase in network traffic.

Audit
= References =

[1] The Oracle Hacker's Handbook: Hacking and Defending Oracle by David Litchfield

[2] The Database Hacker's Handbook: Defending Database Servers by David Litchfield

[3] Database Security Technical Implementation Guide by DISA for the DOD

[4] Oracle Database Security Guide by Oracle Corporation

[5] Oracle Database Security Checklist by Oracle Corporation