Oracle Database Access Security Guide
Oracle Database Access Security Guide
[The “class note” is the typical material I would prepare for my face-to-face class. Since
this is an Internet based class, I am sharing the notes with everyone assuming you are in
the class.]
More detailed and advanced database security and management are dealt in
a separate course, TEC 5363 Database Security and Reliability.
Chapter Prerequisites
To practice the hands-on exercises in this chapter, you need to start SQL*Plus and
run the following command script at SQL> prompt
location\Sql\[Link]
Where location is the file directory where you expanded the supplemental files
downloaded from course web site. For example, after starting SQL*Plus and connecting
as SCOTT, you can run this chapter's SQL command script using the SQL*Plus
command @, as in the following example (assuming that your [Link] file is in
C:\temp\Sql).
SQL> @C:\temp\Sql\chap09.sq1;
Once the script completes successfully, leave the current SQL*Plus session open
and use it to perform this chapter's exercises in the order that they appear.
For each database user, you must indicate how you want Oracle to authenticate
use of the new account. When someone attempts to connect to a database with a
username, Oracle authenticates that the person utilizing the username is authorized to use
the account. Oracle can authenticate users via three different techniques: password
authentication, operating system authentication, and global user authentication.
When you decide to use password authentication, it's important to have a policy in
place that ensures passwords have a certain degree of complexity and that users routinely
change them. For more information about managing user passwords, see the section
"User Account Management" later in this chapter.
Oracle can authenticate a username using the operating system of the computer
that's running the database server. When a user starts an application, the application does
not request connection information from the user. Instead, the application forwards to
Oracle the operating system account information of the user. Oracle then authenticates
the connection request by making sure that the operating system user is registered as a
user in the database. Operating system authentication is common in Oracle host-based
environments when users connect to Oracle using terminals that are directly connected to
the database server.
You create a database user using the SQL command CREATE USER. The
following is an abbreviated syntax listing of the CREATE USER command.
Notice that the CREATE USER command lets you create a user with a password,
as well as specify various other settings for the new user account that subsequent sections
of this chapter will explain. For now, just enter the following CREATE USER statement
to create a database user account for a new application developer named Larry Ellison
with an initial password of changethisnow.
Any user can change his/her own password using the following form of the SQL
command ALTER USER.
If you have the necessary privileges as a database administrator, you can also
change another user's password with the same command. For example, enter the
following ALTER USER statement to change the password for the new LELLISON
account.
Often, SQL statements require temporary work space to complete. For example, a
query that joins and sorts a large amount of data might require temporary work space to
build the result set. When necessary, Oracle allocates temporary work space for a user's
SQL statements in the user's temporary tablespace. Unless you specify otherwise, a user's
temporary tablespace is the SYSTEM tablespace.
When you create a user with the CREATE USER command, you can explicitly
set the user's default and temporary tablespace settings. Subsequently, you can alter a
user's default and temporary tablespace settings using the following form of the SQL
command ALTER USER.
Exercise 9.1 created the user LELLISON without specifying settings for the user's
default and temporary tablespaces; therefore, LELLISON's default and temporary
tablespaces are set to the SYSTEM tablespace. As you'll learn subsequently in Chapter
12 of this book, typical database users should not have their default and temporary
tablespaces set to the SYSTEM tablespace for performance reasons. Therefore, enter the
following ALTER USER statement to change LELLISON's tablespace settings.
Oracle lets you lock and unlock a user account at any time so that you can control
database access through the account without having to drop and recreate it. A user cannot
connect to Oracle after you lock the user's account. To subsequently allow a user access
through an account, you must unlock the account. Why would you want to lock and
unlock user accounts?
You might want to lock a user's account when the user takes a temporary
leave of absence from work, but plans on returning in the future.
When a person leaves your company, you might want to lock the user's
account rather than drop the account, especially if the user's schema
contains tables and other objects that you want to preserve.
You typically lock a user account that functions only as a schema for
logically organizing all of an application's database objects.
When you create a new database user, the new account is unlocked by default.
NOTE
Later in this chapter, you'll see how to configure Oracle so that it locks a
user account automatically after a user's password expires or following a
consecutive number of failed connection attempts.
In Exercise 9.1, the example CREATE USER statement created the new user
without specifying whether to lock or unlock the account. Therefore, Oracle creates the
user with the default UNLOCK option for the ACCOUNT parameter. For practice, enter
the following two ALTER USER statements to lock and then unlock the LELLISON
account.
This course on Oracle database would be remiss if it did not mention that every
Oracle database has two default database user accounts: SYS and SYSTEM.
The SYS account owns the database's data dictionary objects. You should never
connect to Oracle using the SYS account unless it is absolutely necessary to
install supplemental data dictionary objects owned by SYS. The default password
for the SYS account is CHANGE_ON_INSTALL (This might not be true for
Oracle 11g or 12c where it forces the user to specify passwords during
installation).
The SYSTEM account is the default database administrator account that you can
use to get started with a new database. For accountability, it's best to create
distinct user accounts capable of database administration rather than use the
default SYSTEM account. The default password for the SYSTEM account is
MANAGER. (This might not be true for Oracle 11g or 12c where it forces the
user to specify passwords during installation).
Both the SYS and SYSTEM accounts are all-powerful database administrator
accounts that can perform any database operation. Therefore, it is very important to
change the default passwords for the SYS and SYSTEM accounts soon after database
creation to prevent malicious users from using these accounts.
NOTE
For backward compatibility, Oracle8i also supports the special alias INTERNAL
for the SYS account. This “internal” account was desupported after Oracle9i.
A user cannot connect to an Oracle database unless the user has the CREATE
SESSION system privilege.
A user cannot create a table in his or her corresponding schema unless the user
has the CREATE TABLE system privilege.
A user cannot delete rows from a table in a different schema unless the user has
the DELETE object privilege for the table.
This short list reveals just some of the different privileges that you can use to
control access to operations and data within an Oracle database. The following sections
explain more about the different types of database privileges, as well as how to grant
them to and revoke them from users.
If you read the list in the previous section closely, you'll notice that there are two
different kinds of privileges that control access to an Oracle database: system privileges
and object privileges.
A system privilege is a powerful privilege that gives a user the ability to perform
some type of system-wide operation. For example, the following examples are just a few
of almost 100 system privileges in Oracle:
A user with the CREATE SESSION system privilege can connect to the
database server and establish a database session.
A user with the CREATE TABLE system privilege can create a table in
his or her own schema.
A user with the CREATE ANY TABLE system privilege can create a
table in any schema of the database.
A user with the CREATE ANY TYPE system privilege can create types
and associated type bodies in any schema of the database.
A user with the SELECT ANY TABLE system privilege can query any
table in the database.
A user with the EXECUTE ANY PROCEDURE system privilege can
execute any stored procedure, stored function, or packaged component in
the database.
A user with the EXECUTE ANY TYPE system privilege can reference
and execute methods of any type in the database.
Because system privileges are very powerful privileges that can affect the security
of the entire database system, carefully consider what types of users require system
privileges. For example:
A database administrator is the only type of user that should have the
powerful ALTER DATABASE system privilege, a privilege that allows
someone to alter the physical structure and availability of the database
system.
Developers typically require several system privileges, including the
CREATE TABLE, CREATE VIEW, and CREATE TYPE system
privileges to build database schemas that support front-end applications.
Every user in the system typically has the CREATE SESSION system
privilege, the privilege that allows a user to connect to the database server.
An object privilege is a privilege that gives a user the ability to perform a specific
type of operation on a specific database object, such as a table, view, or stored procedure:
A user with the SELECT object privilege for the CUST view can query
the view to retrieve information.
A user with the INSERT object privilege for the CUSTOMERS table can
insert new rows into the table.
A user with the EXECUTE privilege for the partType object type can use
the type when building other database objects and execute the type's
methods.
These examples are just a few of the object privileges that are available for tables,
views, sequences, procedures, functions, packages, object types, and server file
directories. Depending on how an application is designed, users might require object
privileges for the underlying database objects that the application uses. For example, in a
typical order-entry application, a user might need the SELECT, INSERT, UPDATE, and
DELETE privileges for the CUSTOMERS, ORDERS, and ITEMS tables, as well as the
SELECT and UPDATE privileges for the PARTS table. Because each object privilege is
focused on the operation that it permits, you can manage database access with absolute
control.
You can give a user a system or object privilege by granting the privilege to the
user with the SQL command GRANT. To withdraw a privilege from a user, you revoke
the privilege from the user with the SQL command REVOKE. Oracle does not let just
anyone grant and revoke privileges to and from users. Consider the following
requirements when managing individual system and object privileges for database users:
You can grant a user a system privilege only if you have the system
privilege with the administrative rights to grant the privilege to other
users.
You can grant a user a database object privilege only if you own the
associated database object or if you have the object privilege with the
administrative rights to grant the privilege to other users.
The following practice exercises provide you with more information about using
the GRANT and REVOKE commands.
You can grant a system privilege to a user, with or without administrative rights
for the privilege, using the following form of the SQL command GRANT.
For example, a typical application developer requires the ability to connect to the
database and then create tables, views, sequences, and other types of schema objects
necessary to support an application. Considering this, enter the following GRANT
statement to grant several system privileges to LELLISON.
GRANT CREATE SESSION, CREATE TABLE, CREATE VIEW, CREATE ANY INDEX,
CREATE SEQUENCE, CREATE TYPE
TO lellison
WITH ADMIN OPTION;
NOTE
To grant a system or object privilege to every user in the database, grant the
privilege to the keyword PUBLIC rather than to a specific user. PUBLIC is a
special group in an Oracle database that you can use to make a privilege
available quickly to every user in the system. However, use this feature carefully
so that you do not open up security holes in your database.
EXERCISE 9.6: Revoking a System Privilege from a User
If you make a mistake while granting a user some privileges, or later decide that a
user should no longer have a system privilege as part of their privilege domain (set of
available privileges), you can revoke the system privilege using the following form of the
SQL command REVOKE.
For example, the GRANT statement in the previous practice exercise grants the
user LELLISON several system privileges with the ADMIN option. Consequently,
LELLISON can use the system privileges to perform database work and can grant the
same system privileges to other users at his discretion. Typical application developers
should not have the ability to grant system privileges to other database users. Therefore,
enter the following REVOKE statement to revoke LELLISON's access to the system
privileges granted in the previous exercise.
REVOKE CREATE SESSION, CREATE TABLE, CREATE VIEW, CREATE ANY INDEX,
CREATE SEQUENCE, CREATE TYPE
FROM lellison;
Next, regrant the system privileges to LELLISON, but this time without the
ADMIN option.
GRANT CREATE SESSION, CREATE TABLE, CREATE VIEW, CREATE ANY INDEX,
CREATE SEQUENCE, CREATE TYPE
TO lellison;
You can grant an object privilege for a specific schema object to a user, with or
without the right to grant the privilege to other users, using the following form of the
SQL command GRANT.
GRANT
{ privilege [, privilege] ...
| ALL [PRIVILEGES] }}
ON {[schema.]object|DIRECTORY directory }
TO user [, user] ...
[WITH GRANT OPTION]
NOTE
To grant an object privilege, you must own the object or have been granted the
object privilege with the GRANT option.
Table 9-1 contains a list of the privileges available for the most common types of
schema objects. For example, your current practice schema (PRACTICE09) contains the
familiar CUSTOMERS, ORDERS, ITEMS, PARTS, and SALESREPS tables (in other
words, your current schema owns these tables). Enter the following statements to grant
the user LELLISON various privileges for the tables in your schema.
GRANT SELECT,
INSERT (id, lastname, firstname),
UPDATE (lastname, firstname),
REFERENCES (id)
ON salesreps
TO lellison;
The first statement grants the INSERT, UPDATE, DELETE, and SELECT
privileges for the CUSTOMERS table to LELLISON. The second statement uses the
ALL PRIVILEGES shortcut to grant all object privileges for the ORDERS table to
LELLISON with the option to grant the table privileges for the ORDERS table to other
users. The final statement grants the SELECT, INSERT, UPDATE, and REFERENCES
privileges for the SALESREPS table to LELLISON--notice that the INSERT, UPDATE,
and REFERENCES privileges are granted for specific columns only.
You can revoke an object privilege from a user with the following form of the
SQL command REVOKE.
REVOKE
{ privilege [, privilege] ...
ALL [PRIVILEGES] }
ON {[schema.]object|DIRECTORY directory }
FROM user [,user] ...
[CASCADE CONSTRAINTS]
[FORCE]
The CASCADE CONSTRAINTS option indicates that you want to drop all
referential integrity constraints created using a REFERENCES object privilege that is
being revoked. The FORCE option is necessary when revoking the EXECUTE object
privilege for an object type that has table dependencies.
For example, enter the following statement to revoke some of the privileges you
granted to LELLISON in the previous practice exercise.
The system and object privileges necessary to use a typical database application
can be numerous. When a database application supports a large user population, privilege
management can become a big job quickly if you manage each user's privileges with
individual grants. To make security administration an easier task, you can use roles. A
role is a collection of related system and object privileges that you can grant to users and
other roles. For example, when you build a new database application, you can create a
new role that has the database privileges necessary to run the program. After you grant
the role to an application user, the user can start the application to connect to the database
and accomplish work. If the privileges necessary to run the application change, all that's
necessary is a quick modification of the role's set of privileges. All grantees of the role
see the change in the role automatically and continue to have the privileges necessary to
use the application.
[Link]. Predefined Database Roles
Oracle has many predefined roles that you can use to quickly grant privileges to
common types of database users. The following is a short list of the five most commonly
used predefined database roles that you might use.
CAUTION
Although Oracle provides predefined roles to help manage privileges for typical
database users, an application that relies on these roles might not necessarily
function correctly. That's because you can change a predefined role's privilege set
or even drop the role altogether.
[Link]. User-Defined Roles
You can create as many roles as you need for an Oracle database. After creating a
role, you grant privileges and other roles to it to build the role's set of privileges. Then
you grant the role to users so that they have the privileges necessary to complete their
jobs.
A grantee of a role does not necessarily have access to the privileges of the role at
all times. Oracle allows applications to selectively enable and disable a role for each
individual. After an application enables a role for a user, the privileges of the role are
available to the user. As you might expect, after an application disables a role for a user,
the user no longer has access to the privileges of the role. Oracle's ability to dynamically
control the set of privileges available to a user allows an application to ensure that users
always have the correct set of privileges when using the application.
For example, when a user starts an order-entry application, the application can
enable the user's ORDER_ENTRY role so that the user can accomplish work. When the
user finishes working, the application can disable the user's ORDER_ENTRY role so that
the user cannot use the order-entry application privileges when working with a different
application.
Each user has a list of default roles. A default role is a role that Oracle enables
automatically when the user establishes a new database session. Default roles make it
convenient to enable roles that users always require when working with Oracle, no matter
which application they use.
To prevent unauthorized use of a role, you can protect a role with authentication.
Oracle can authenticate the use of a role using the same three authentication techniques as
with database users: password authentication, operating system authentication, and global
role authentication. Oracle authenticates role usage when a user or application attempts to
enable the role.
In the previous exercises of this chapter, you granted several system and object
privileges directly to a user account. Consider the overhead if you had to repeat this
process for 100-plus developers in a large workgroup. To help make privilege
management easier for the application developers in your system, the next few practice
exercises show you how to define a new role called APPDEV that you can grant to
application developers' accounts.
EXERCISE 9.9: Creating a Role
To create a new role, you use the SQL command CREATE ROLE. The following
is an abbreviated version of this command's syntax.
Enter the following SQL command to create a new role for application developers
in our system.
NOTE
When you create a role, Oracle automatically grants you the role with the
administrative rights to alter, drop, and grant the role to other roles and users.
Additionally, a role is owned by the creator of the role.
The syntax of the SQL command GRANT for granting system privileges and
other roles to a role is basically the same as in Exercise 9.5.
For example, enter the following statement to grant several system privileges to
the new APPDEV role.
GRANT CREATE SESSION, CREATE TABLE, CREATE VIEW, CREATE ANY INDEX,
CREATE SEQUENCE, CREATE TYPE
TO appdev;
NOTE
If you grant the ADMIN option for a role, the grantee can grant, alter, or drop the
role, and can grant the role to other users and roles. To prevent security holes in
your system, it is not wise to grant system privileges and roles with administrative
rights to other roles.
The syntax of the SQL command GRANT for granting object privileges to a role
is basically the same as in Exercise 9.7--just specify the name of one or more roles rather
than one or more users. For example, enter the following statements to grant several
object privileges to the new APPDEV role.
GRANT INSERT, UPDATE, DELETE, SELECT
ON customers
TO appdev;
GRANT SELECT,
INSERT (id, lastname, firstname),
UPDATE (lastname, firstname)
ON salesreps
TO appdev;
NOTE
Oracle does not permit you to grant the REFERENCES object privilege for a
table to a role--when a user needs this privilege, you must grant it to the user
directly.
To grant a role to a user, you use the following syntax of the SQL command
GRANT:
If you grant the ADMIN option for a role to a user, the user can grant, alter, or
drop the role, and can grant the role to other users and roles. Use this option judiciously.
For example, enter the following SQL statements to create a new database user
account for another application developer, and then grant the APPDEV role to the new
user.
With just one grant statement, the new user RLANE has the necessary privileges
to work as an application developer in your database. Furthermore, if you need to change
the privileges for application developers, all that you need to do is grant privileges to and
revoke privileges from the APPDEV role-all grantees of the APPDEV role will
automatically be subject to the new privilege domain of the role.
EXERCISE 9.13: Setting a User's Default Role
When you grant a role to a user, Oracle automatically adds the role to the user's
list of default roles. You can explicitly set a user's list of default roles using the following
syntax of the SQL command ALTER USER.
You can specify a role as a user's default role after the user has been granted the
role directly (you cannot specify roles received indirectly through other roles).
Furthermore, you cannot specify a role as a user's default role if the role is authenticated
by the operating system or by a security service--roles authenticated by passwords require
no passwords at connect time. Notice that you can specify individual roles, use the ALL
clause to specify all or all but a list of roles, or specify no default roles for the user.
NOTE
If a user does not have any default roles with the CREATE SESSION system
privilege, you must grant the CREATE SESSION system privilege directly to the
user, or else the user will not be able to establish a database session.
Enter the following ALTER USER statement to modify the list of default roles for
the new RLANE user account.
You can explicitly enable and disable access to the privileges of a role using the
SQL command SET ROLE. As discussed earlier in this section of the chapter,
applications commonly use this command to make sure that application sessions have the
appropriate set of privileges for using the application. The syntax of the SET ROLE
command is as follows:
SET ROLE
{ role [IDENTIFIED BY password] [, role [IDENTIFIED BY password] ... ]
| ALL [EXCEPT role [, role] ... ]
| NONE }
There are several important points to understand before you use the SET ROLE
command:
Your session can use the SET ROLE command with the ALL option to enable all
roles granted to your account. However, when you want to enable a role that
requires a password, you must specify the role and its password using the
IDENTIFIED BY parameter.
You can disable all roles for your session using the NONE option of the SET
ROLE command.
Oracle automatically disables any role granted to you that you do not enable with
the SET ROLE command.
To illustrate the way that the SET ROLE command functions, consider that your
current user account (PRACTICE09) has been granted the following roles: CONNECT,
RESOURCE, SELECT_CATALOG_ROLE (which has been granted the HS_ADMIN_
ROLE), and APPDEV. To display the list of the roles currently enabled by your session,
enter the following query of the SESSION_ROLES data dictionary view.
ROLE
--------------
CONNECT
RESOURCE
SELECT_CATALOG_ROLE
HS_ADMIN_ROLE
Now enter the following SET ROLE statement to enable the APPDEV role and
disable all other roles for your current SQL*Plus session.
Next, requery the SESSION_ROLES view, and you should see the following
result set:
ROLE
-------------
APPDEV
To enable all of your roles for your current session (CONNECT, RESOURCE,
and APPDEV), you must enter the following SET ROLE statement.
SET ROLE
CONNECT,
RESOURCE,
SELECT_CATALOG_ROLE,
appdev IDENTIFIED BY yeRtw;
Notice that this SET ROLE statement does not list the HS_ADMIN_ROLE,
which is part of the SELECT CATALOG_ROLE's privilege domain. That's because
Oracle automatically enables the roles granted to a role that you explicitly enable.
A user cannot create objects such as tables and indexes in a tablespace unless the
user has a quota for the tablespace. A tablespace quota limits how much space a user's
database objects can consume in the tablespace. A user can have a quota for zero, one, or
all tablespaces in the database--it's entirely up to you. When you
create or alter a user and give the user a tablespace quota, you set the quota as a specific
number of bytes in the tablespace or as an unlimited amount of space in the tablespace.
To give a current user a quota for one or more tablespaces in the system, you can
use the following form of the SQL command ALTER USER.
For example, enter the following statement to provide the user LELUSON with
the right to use 5MB of space in the USERS tablespace.
Now enter the following statement to provide the user RLANE with the right to
an unlimited amount of space in the USERS tablespace.
When a user must have an unlimited quota for every tablespace in the database,
you can grant the user the UNLIMITED TABLESPACE system privilege, rather than
giving the user an unlimited quota for each tablespace in the system. For example, enter
the following statement to grant the user RLANE the UNLIMITED TABLESPACE
system privilege.
NOTE
Oracle does not let you grant the UNLIMITED TABLESPACE system privilege to
a role.
To control the consumption of several other types of system resources, you can
use resource limit profiles. A resource limit profile is a set of specific resource limit
settings that you assign to one or more database users. Using a resource limit profile, you
can limit consumption of the following system resources:
You can use resource limit profiles to enforce several other security policies for
database users. Using a resource limit profile, you can control the following settings for
each user account that is assigned the profile:
Every Oracle database has a default resource limit profile. When you create a new
database user and do not indicate a specific profile for the user, Oracle automatically
assigns the user the database's default profile. By default, all resource limit settings of the
database's default profile are set to unlimited; account management settings vary.
When you create a resource limit profile, you can set specific resource limit
settings or defer to the corresponding setting of the database's default profile. At any
time, you can alter the settings of a database's default profile just like user-defined
profiles.
Several steps are necessary to configure and enforce resource limitation using
profiles in an Oracle database.
The following practice exercises teach you how to complete these steps for
managing resource limitation, and more.
ALTER SYSTEM
SET RESOURCE_LIMIT = {TRUE|FALSE}
To enable the enforcement of resource limitation for the current database instance,
enter the following ALTER SYSTEM statement.
ALTER SYSTEM
SET RESOURCE_LIMIT = TRUE;
NOTE
The example ALTER SYSTEM statement in this exercise enables the enforcement
of resource limitation only for the life of the current database instance--if you
shut down and restart Oracle, the enforcement of resource limitation is subject to
the setting of the RESOURCE_LIMIT parameter in your server's initialization
parameter file. If you plan to use resource limitation permanently, edit your
server's parameter file and include the following parameter: RESOURCE_LIMIT
= TRUE.
EXERCISE 9.18: Creating a Profile
In this exercise, you will create a resource limit profile that you can use with the
new application developers in your practice database. To create a new profile, you use the
SQL command CREATE PROFILE, which has the following syntax:
A profile user can have at most five concurrent database sessions open.
A profile user session can use an unlimited amount of CPU time, but only
30 seconds (set as 3,000 hundredths of a second) of CPU time per
database request. If a call reaches this CPU limit, Oracle stops the
operation to prevent further consumption of CPU time by the session.
A profile user session can remain connected to the instance for an
unlimited amount of time without being disconnected, but can remain idle
for only 30 minutes before being automatically disconnected.
A profile user session can perform an unlimited number of logical reads
(data block reads from either disk or server memory), but only 1,000
logical block reads per database request. If a call reaches this limit, Oracle
stops the operation to prevent further consumption of logical reads by the
session.
A profile user session that connects to the instance using a multithreaded
server can allocate and use up to 200K of private memory for the MTS
session.
You alter the settings of a profile using the SQL command ALTER PROFILE.
For example, when you created the new APPDEV profile in the previous exercise,
you did not specify any of the password management settings. Enter the following
ALTER PROFILE statement to specify the basic password management settings for the
new profile.
You can manually force a user's password to expire and require that the user
change the password during his or her next session. To accomplish this task, use the
following form of the SQL command ALTER USER.
In the previous exercise, you specified the basic password management settings
for a profile. You can also check the complexity of a profile user's password using the
PASSWORD_VERIFY_FUNCTION parameter of the SQL commands CREATE
PROFILE and ALTER PROFILE. To disable password complexity checking for all
profile users, set the profile's PASSWORD_VERIFY_FUNCTION parameter to NULL.
To enable password complexity checking for all profile users, set the profile's
PASSWORD_VERIFY_FUNCTION parameter to the name of a function that is
designed to check password complexity. Oracle supplies a default function that you must
create using the [Link] command script located in the
Oracle_Home\Rdbms\Admin directory, where Oracle_Home is your Oracle home
location. To run this script, start a different instance of SQL*Plus (leave your other
SQL*Plus session intact) and connect as the user SYS. Once you are connected as SYS,
run the [Link] command script. For example, the following command runs
the [Link] script assuming that the Oracle home location is
O:\Oracle\Ora81:
@O:\Oracle\Ora81\Rdbms\Admin\[Link];
As of Oracle 11g installed on my computer (in 2015), the location of the above
[Link] file is at:
G:\app\pliu\product\11.1.0\db_1\RDBMS\ADMIN
After you run the [Link] script, exit this SQL*Plus session and
return to your original SQL*Plus session.
NOTE
When you configure Oracle to check the complexity of user passwords, users
should not use the ALTER USER command to change their passwords. See your
Oracle documentation for more information about changing user passwords in
this setting.
By default, all users are assigned to use the database's default profile. To set a
user's profile to another profile, you can use the following form of the SQL command
ALTER USER.
For example, using your original SQL*Plus session, enter the following ALTER
USER statements to assign the users LELLISON and RLANE to the APPDEV resource
limit profiles.
At this point, all users in your practice database are subject to various password
management checks because the default database profile and the new APPDEV profile
have set password management options. In this exercise, let's see what happens when you
try to change the password for LELLISON to a very simple password. Enter the
following statement:
When Oracle tries to execute this statement, it should return the following errors:
Now enter the following statement to set an acceptably complex password for
LELLISON.
If you plan to use the default database profile to limit resources or enforce
password management, you should pay close attention to the default limits and password
management options set for this profile (see Exercise 9.28). You can adjust the default
database profile's settings using an ALTER PROFILE statement.
For example, you must disable the password management features of the default
database profile so that you can run the SQL command scripts for subsequent chapters
without being prompted to change the SYSTEM account's password. To disable
password management for the default database profile, enter the following ALTER
PROFILE statement.
NOTE
Once you enable the password management features for a profile, Oracle keeps
track of when each profile users' password expires, and so on, even after you
disable password management features for the profile. Consequently, in 30 days,
Oracle might request that you change the password for existing database
accounts such as SYS, SYSTEM, and SCOTT.
To display information about the users in your database, you can query the
DBA_USERS data dictionary view. For example, enter the following statement to reveal
the account settings for the LELLISON and RLANE user accounts in the practice
database.
To display information about the roles in your database, you can query the DBA
ROLES data dictionary view. For example, enter the following statement to list
information about the CONNECT, RESOURCE, DBA, and APPDEV roles in your
database.
ROLE PASSWORD
--------------- ---------
APPDEV YES
DBA NO
RESOURCE NO
CONNECT NO
The result set for this query should be similar to the following:
Notice that the MAX_BYTES column of the DBA TS_QUOTAS displays the
code "-1" when a user has an unlimited tablespace quota.
To display information about profiles and associated resource limit settings, you
can query the DBA_PROFILES data dictionary view. For example, enter the following
query:
Chapter Summary
This chapter explained the security features of Oracle that you can use to limit and
monitor access to a database.
Only a registered database user can access a database once Oracle authenticates a
connection request. You create and manage users with the SQL commands
CREATE USER and ALTER USER, respectively.
Once connected to a database, a user can perform only those operations that the
user is privileged to execute. You can grant users individual system and object
privileges or use roles to group related sets of privileges and more easily manage
user privileges. You create roles using the SQL command CREATE ROLE and
then grant and revoke privileges to users or roles using the SQL commands
GRANT and REVOKE, respectively.
Resource limit profiles let you limit a user's access to system resources, such as
CPU time, disk I/Os, and sessions. You create profiles using the SQL command
CREATE PROFILE, and then assign each user to a profile with the SQL
commands CREATE USER or ALTER USER.
When a user exceeds the allowed number of consecutive failed login attempts (such as three tries in the APPDEV profile), Oracle automatically locks their account for a specified duration (one day in this profile). This prevents unauthorized access from repeated guess attempts and adds a layer of security to protect sensitive information in the database .
Changing a user's profile, such as assigning them to the APPDEV profile, applies new resource limits and password management rules to their account. This can include restrictions on login attempts, password expiration, and complexity requirements. These changes help standardize security settings and resource usage across users, maintaining consistency and compliance with security policies .
The REFERENCES privilege allows a grantee to reference a table when declaring a referential integrity constraint. It can be granted on specific columns for the INSERT, UPDATE, and REFERENCES privileges, allowing selective control over which columns can participate in referential integrity constraints .
When a role is assigned as a DEFAULT ROLE, it is automatically enabled for a user when they start a new database session. If a user's list of default roles does not include any with the CREATE SESSION privilege, that privilege must be directly granted to the user to establish a database session. Thus, setting DEFAULT ROLE ensures essential privileges are readily available for user operations .
Oracle's password complexity checking uses a function, such as the VERIFY_FUNCTION created by the UTLPWDMG.SQL script, to enforce rules ensuring secure passwords. These rules prevent usernames matching passwords, require a combination of characters, digits, and punctuation, and mandate that new passwords differ by at least three characters from the old one. This verification process helps mitigate risks of simple or predictable passwords .
Roles simplify privilege management by grouping related system and object privileges together, allowing them to be granted to users and other roles as a single entity. This prevents the need for individual privilege management per user, easing the administrative burden and ensuring consistency. Any changes to the privileges required by an application can be propagated to all users by altering the role .
Role authentication is crucial to prevent unauthorized use of roles by employing authentication methods such as passwords, operating system, or global authentication. This prevents users from accessing roles and their associated privileges without proper credentials, reducing the risk of illicit activities within the database. Effective role authentication forms a critical component of securing database systems and controlling access .
Creating specialized roles like APPDEV aggregates the system and object privileges developers need, such as CREATE SESSION and CREATE TABLE, facilitating easier management and streamlined privilege updates. This specialization simplifies onboarding new developers, adjusting access levels, and ensuring only necessary privileges are granted, thereby enhancing security and efficiency .
Granting the ADMIN option for a role allows the grantee to grant, alter, or drop the role, and to further grant the role to other users and roles. This can create security risks since it enables users to propagate privileges at will, potentially leading to unauthorized access or privilege escalation. Careful control and judicious use of the ADMIN option are necessary to prevent security vulnerabilities .
The CASCADE CONSTRAINTS option when revoking the REFERENCES privilege ensures that all referential integrity constraints created using this privilege are also removed. This action is crucial to maintain database integrity without leaving orphaned constraints that cannot function without the appropriate privileges being in place .