Oracle® Database Security Guide 11g Release 1 (11.1) Part Number B28531-01 |
|
|
View PDF |
Authorization includes primarily two processes:
Permitting only certain users to access, process, or alter data.
Applying varying limitations on user access or actions. The limitations placed on (or removed from) users can apply to objects such as schemas, tables, or rows or to resources such as time (CPU, connect, or idle times).
This chapter discusses the following topics:
A user privilege is the right to run a particular type of SQL statement, or the right to access an object that belongs to another user, run a PL/SQL package, and so on. The types of privileges are defined by Oracle Database.
Roles are created by users (usually administrators) to group together privileges or other roles. They are a way to facilitate the granting of multiple privileges or roles to users.
This section describes the following general categories:
System privileges. These privileges allow the grantee to perform standard administrator tasks in the database. Restrict them only to trusted users. "Managing System Privileges" describes system privileges in detail.
User roles. A role groups several privileges and roles, so that they can be granted to and revoked from users simultaneously. You must enable the role for a user before the user can use it. See "Managing User Roles" for more information.
Object privileges. Each type of object has privileges associated with it. "Managing Object Privileges" describes how to manage privileges for different types of objects.
You grant privileges to users so they can accomplish tasks required for their jobs. You should grant a privilege only to a user who requires that privilege to accomplish the necessary work. Excessive granting of unnecessary privileges can compromise security. For example, you never should grant SYS
or SYSDBA
privileges to users who do not perform administrative tasks.
A user can receive a privilege in two different ways:
You can grant privileges to users explicitly. For example, you can explicitly grant to user SCOTT
the privilege to insert records into the employees
table.
You also can grant privileges to a role (a named group of privileges), and then grant the role to one or more users. For example, you can grant the privileges to select, insert, update, and delete records from the employees
table to the role named clerk
, which in turn you can grant to users SCOTT
and ROBERT
.
Because roles allow for easier and better management of privileges, you should usually grant privileges to roles and not to specific users.
See Also:
"Guidelines for Securing User Accounts and Privileges" for best practices to follow when granting privileges
Oracle Database SQL Language Reference for the complete list of system privileges and their descriptions
This section covers the following topics about system privileges:
A system privilege is the right to perform a particular action or to perform an action on any schema objects of a particular type. For example, the privileges to create tablespaces and to delete the rows of any table in a database are system privileges.
There are over 100 distinct system privileges. Each system privilege allows a user to perform a particular database operation or class of database operations. Remember that system privileges are very powerful. Only grant them when necessary to roles and trusted users of the database. You can find a complete list of system privileges and their descriptions in Oracle Database SQL Language Reference.
Because system privileges are so powerful, you should configure your database to prevent typical (non-administrative) users from exercising the ANY
system privileges (such as UPDATE ANY TABLE
) on the data dictionary. See "Guidelines for Securing User Accounts and Privileges" for additional guidelines about restricting system privileges.
To secure the data dictionary, set the O7_DICTIONARY_ACCESSIBILITY
initialization parameter to FALSE
, which is the default value. This feature is called the dictionary protection mechanism.
The O7_DICTIONARY_ACCESSIBILITY
initialization parameter controls restrictions on system privileges when you upgrade from Oracle Database release 7 to Oracle8i and later releases. If the parameter is set to TRUE
, then access to objects in the SYS
schema is allowed (Oracle Database release 7 behavior). Because the ANY
privilege applies to the data dictionary, a malicious user with ANY
privilege could access or alter data dictionary tables.
To set the O7_DICTIONARY_ACCESSIBILTY
initialization parameter, modify it in the init
SID
.ora
file. Alternatively, you can log on to SQL*Plus as SYS
/AS SYSDBA
and then enter an ALTER SYSTEM
statement, assuming you have started the database using a server parameter file (SPFILE).
Example 4-1 shows how to set the O7_DICTIONARY_ACCESSIBILTY
initialization parameter to FALSE
by issuing an ALTER SYSTEM
statement in SQL*Plus.
Example 4-1 Setting O7_DICTIONARY_ACCESSIBILITY to FALSE
ALTER SYSTEM SET O7_DICTIONARY_ACCESSIBILITY=FALSE SCOPE=SPFILE;
When you set O7_DICTIONARY_ACCESSIBILITY
to FALSE
, system privileges that enable access to objects in any schema (for example, users who have ANY
privileges, such as CREATE ANY PROCEDURE
) do not allow access to objects in the SYS
schema. This means that access to the objects in the SYS
schema (data dictionary objects) is restricted to users who connect as SYS
or connect using the SYSDBA
privilege.
System privileges that provide access to objects in other schemas do not give other users access to objects in the SYS
schema. For example, the SELECT ANY TABLE
privilege allows users to access views and tables in other schemas, but does not enable them to select dictionary objects (base tables of dynamic performance views, regular views, packages, and synonyms). You can, however, grant these users explicit object privileges to access objects in the SYS
schema.
See Oracle Database Reference for more information about the O7_DICTIONARY_ACCESSIBILITY
initialization parameter.
The CREATE EXTERNAL JOB
privilege is automatically created in the schema of the grantee user so that operating system jobs can run outside the database. To support backward compatibility, by default, this privilege is granted to all existing users who have the CREATE JOB
privilege. For greater security, grant the CREATE EXTERNAL JOB
privilege only to SYS
, database administrators, and those users who need it.
Users with explicit object privileges or those who connect with administrative privileges (SYSDBA
) can access objects in the SYS
schema.
Table 4-1 lists roles that you can grant to users who need access to objects in the SYS
schema.
Table 4-1 Roles to Allow Access to SYS Schema Objects
Role | Description |
---|---|
Grant this role to allow users |
|
Grant this role to allow users |
|
Grant this role to allow users to delete records from the system audit table ( |
Additionally, you can grant the SELECT ANY DICTIONARY
system privilege to users who require access to tables created in the SYS
schema. This system privilege allows query access to any object in the SYS
schema, including tables created in that schema. It must be granted individually to each user requiring the privilege. It is not included in GRANT ALL PRIVILEGES
, but it can be granted through a role.
Caution:
You should grant these roles and theSELECT ANY DICTIONARY
system privilege with extreme care, because the integrity of your system can be compromised by their misuse.You can grant or revoke system privileges to users and roles. If you grant system privileges to roles, then you can use the roles to exercise system privileges. For example, roles permit privileges to be made selectively available.
Note:
In general, you should grant system privileges only to administrative personnel and application developers. End users usually do not require and should not have the associated capabilities.Use either of the following methods to grant or revoke system privileges to users and roles:
GRANT
and REVOKE
SQL statements
Oracle Enterprise Manager Database Control
See Also:
Oracle Database 2 Day DBA for more information about Database Control
Only two types of users can grant system privileges to other users or revoke those privileges from them:
Users who were granted a specific system privilege with the ADMIN
OPTION
Users with the system privilege GRANT
ANY
PRIVILEGE
For this reason, only grant these privileges to trusted users.
System privileges that use the ANY
keyword enable you to set privileges for an entire category of objects in the database. For example, the CREATE ANY PROCEDURE
system privilege allows a user to create a procedure anywhere in the database. The behavior of an object created by users with the ANY
privilege is not restricted to the schema in which it was created. For example, if user MALCOEUR
has the CREATE ANY PROCEDURE
privilege and creates a procedure in the schema JONES
, then the procedure will run as JONES
. However, JONES
may not be aware that the procedure MALCOEUR
created is running as him (JONES
). If JONES
has DBA
privileges, letting MALCOEUR
run a procedure as JONES
could pose a security violation.
PUBLIC
privileges are granted to every user in an Oracle database, and can be granted to roles and as users. Because objects created with the PUBLIC
privilege are accessible to everyone, they can pose a security risk similar to ANY
objects. For example, if MALCOEUR
has the CREATE PUBLIC SYNONYM
privilege, he could redefine an interface that he knows everyone else uses, and then point to it with the PUBLIC SYNONYM
that he created. Instead of accessing the correct interface, users would access the interface of MALCOEUR
, which could possibly perform illegal activities such as stealing the login credentials of users.
As you can see, these types of privileges are very powerful and could pose a security risk if given to the wrong person. Be careful about granting privileges using ANY
or PUBLIC
. As with all privileges, you should follow the principles of "least privilege" when granting these privileges to users.
To protect the data dictionary for SYS
against users who have ANY
privileges, set the O7_DICTIONARY_ACCESSIBILITY
initialization parameter is set to FALSE
. You can set this parameter by using an ALTER SYSTEM statement (see Example 4-1, "Setting O7_DICTIONARY_ACCESSIBILITY to FALSE") or by modifying the init
SID
.ora
file. See "Guidelines for Securing a Database Installation and Configuration" for additional guidelines.
This section describes how to manage user roles:
Managing and controlling privileges is easier when you use roles, which are named groups of related privileges that you grant as a group to users or other roles. Within a database, each role name must be unique, different from all user names and all other role names. Unlike schema objects, roles are not contained in any schema. Therefore, a user who creates a role can be dropped with no effect on the role.
This section explores the following topics:
Table 4-2 describes the properties of roles that enable easier privilege management within a database.
Table 4-2 Properties of Roles and Their Description
Property | Description |
---|---|
Reduced privilege administration |
Rather than granting the same set of privileges explicitly to several users, you can grant the privileges for a group of related users to a role, and then only the role needs to be granted to each member of the group. |
Dynamic privilege management |
If the privileges of a group must change, then only the privileges of the role need to be modified. The security domains of all users granted the group's role automatically reflect the changes made to the role. |
Selective availability of privileges |
You can selectively enable or disable the roles granted to a user. This allows specific control of a user's privileges in any given situation. |
Application awareness |
The data dictionary records which roles exist, so you can design applications to query the dictionary and automatically enable (or disable) selective roles when a user attempts to execute the application by way of a given user name. |
Application-specific security |
You can protect role use with a password. Applications can be created specifically to enable a role when supplied the correct password. Users cannot enable the role if they do not know the password. |
Database administrators often create roles for a database application. You should grant a secure application role all privileges necessary to run the application. You then can grant the secure application role to other roles or users. An application can have several different roles, each granted a different set of privileges that allow for more or less data access while using the application.
The DBA can create a role with a password to prevent unauthorized use of the privileges granted to the role. Typically, an application is designed so that when it starts, it enables the proper role. As a result, an application user does not need to know the password for an application role.
See Also:
"How Roles Aid or Restrict DDL Usage" for information about restrictions for proceduresIn general, you create a role to serve one of two purposes:
To manage the privileges for a database application (see "Common Uses of Application Roles")
To manage the privileges for a user group (see "Common Uses of User Roles")
Figure 4-1 and the sections that follow describe the two uses of roles.
Grant an application role all privileges necessary to run a given database application. Then, grant the secure application role to other roles or to specific users. An application can have several different roles, with each role assigned a different set of privileges that allow for more or less data access while using the application.
Each role and user has its own unique security domain. The security domain of a role includes the privileges granted to the role plus those privileges granted to any roles that are granted to the role.
The security domain of a user includes privileges on all schema objects in the corresponding schema, the privileges granted to the user, and the privileges of roles granted to the user that are currently enabled. (A role can be simultaneously enabled for one user and disabled for another.) This domain also includes the privileges and roles granted to the user group PUBLIC
. The PUBLIC
user group represents all users in the database.
The use of roles in a PL/SQL block depends on whether it is an anonymous block or a named block (stored procedure, function, or trigger), and whether it executes with definer's rights or invoker's rights.
All roles are disabled in any named PL/SQL block (stored procedure, function, or trigger) that executes with definer's rights. Roles are not used for privilege checking and you cannot set roles within a definer's rights procedure.
The SESSION_ROLES
view shows all roles that are currently enabled. If a named PL/SQL block that executes with definer's rights queries SESSION_ROLES
, then the query does not return any rows.
See Also:
Oracle Database ReferenceNamed PL/SQL blocks that execute with invoker's rights and anonymous PL/SQL blocks are executed based on privileges granted through enabled roles. Current roles are used for privilege checking within an invoker's rights PL/SQL block, and you can use dynamic SQL to set a role in the session.
See Also:
Oracle Database PL/SQL Language Reference for an explanation of invoker's and definer's rights
Oracle Database PL/SQL Language Reference for information about dynamic SQL in PL/SQL
A user requires one or more privileges to successfully execute a DDL statement, depending on the statement. For example, to create a table, the user must have the CREATE
TABLE
or CREATE
ANY
TABLE
system privilege. To create a view of a table that belongs to another user, the creator requires the CREATE VIEW
or CREATE
ANY
VIEW
system privilege and either the SELECT
object
privilege for the table or the SELECT
ANY
TABLE
system privilege.
Oracle Database avoids the dependencies on privileges received by way of roles by restricting the use of specific privileges in certain DDL statements. The following rules outline these privilege restrictions concerning DDL statements:
All system privileges and schema object privileges that permit a user to perform a DDL operation are usable when received through a role. For example:
System privileges: CREATE
TABLE
, CREATE
VIEW,
and CREATE
PROCEDURE
privileges
Schema object privileges: ALTER
and INDEX
privileges for a table
All system privileges and object privileges that allow a user to perform a DML operation that is required to issue a DDL statement are not usable when received through a role. For example, a user who receives the SELECT
ANY
TABLE
system privilege or the SELECT
object
privilege for a table through a role can use neither privilege to create a view on a table that belongs to another user.
The following example further clarifies the permitted and restricted uses of privileges received through roles.
Assume that a user is:
Granted a role that has the CREATE
VIEW
system privilege
Granted a role that has the SELECT
object
privilege for the employees
table, but also indirectly granted the SELECT
object
privilege for the employees
table
Directly granted the SELECT
object
privilege for the departments
table
Given these directly and indirectly granted privileges:
The user can issue SELECT
statements on both the employees
and departments
tables.
Although the user has both the CREATE
VIEW
and SELECT
privilege for the employees
table through a role, the user cannot create a usable view on the employees
table, because the SELECT
object
privilege for the employees
table was granted through a role. Any views created will produce errors when accessed.
The user can create a view on the departments
table, because the user has the CREATE
VIEW
privilege through a role and the SELECT
privilege for the departments
table directly.
In some environments, you can administer database security using the operating system. The operating system can be used to grant and revoke database roles and to manage their password authentication. This capability is not available on all operating systems.
See Also:
Your operating system-specific Oracle Database documentation for details about managing roles through the operating systemWhen you use roles in a distributed database environment, ensure that all needed roles are set as the default roles for a distributed (remote) session. These roles cannot be enabled when the user connects to a remote database from within a local database session. For example, the user cannot execute a remote procedure that attempts to enable a role at the remote site.
Oracle Database provides a set of predefined roles to help in database administration. These roles, listed in Table 4-3, are automatically defined for Oracle databases when you run the standard scripts that are part of database creation. If you install other options or products, then other predefined roles may be created. You can grant privileges and roles to, and revoke privileges and roles from, these predefined roles in the same way as you do with any role you define.
Table 4-3 Oracle Database Predefined Roles
Predefined Role | Created by Script | Description |
---|---|---|
|
Provides privileges to administer Advanced Queuing. Includes |
|
|
Obsolete, but kept mainly for release 8.0 compatibility. Provides |
|
|
Provides the This role is provided for compatibility with previous releases of Oracle Database. You can determine the privileges encompassed by this role by querying the Note: Oracle recommends that you design your own roles for database security rather than relying on this role. This role may not be created automatically by future releases of Oracle Database. See Also: Oracle Database Reference for a description of the |
|
|
Provides all system privileges This role is provided for compatibility with previous releases of Oracle Database. You can determine the privileges encompassed by this role by querying the Note: Oracle recommends that you design your own roles for database security rather than relying on this role. This role may not be created automatically by future releases of Oracle Database. See Also: Oracle Database Reference for a description of the |
|
|
Provides the |
|
|
Provides |
|
|
Provides the privileges required to perform full and incremental database exports, and includes: This role is provided for convenience in using the export and import utilities. See Also: Oracle Database Utilities for more information about these roles |
|
|
Provides privileges for DBAs who need to use the Used to protect access to the Heterogeneous Services (HS) data dictionary tables (grants See Also: Oracle Database Heterogeneous Connectivity Administrator's Guide for more information |
|
|
Provides the privileges required to perform full database imports. Includes an extensive list of system privileges (use view This role is provided for convenience in using the export and import utilities. See Also: Oracle Database Utilities for more information about these roles |
|
|
Provides privileges for owner of the recovery catalog. Includes: |
|
|
Provides the following system privileges: This role is provided for compatibility with previous releases of Oracle Database. You can determine the privileges encompassed by this role by querying the Note: Oracle recommends that you design your own roles for database security rather than relying on this role. This role may not be created automatically by future releases of Oracle Database. See Also: Oracle Database Reference for a description of the |
|
|
Allows the grantee to execute the procedures of the See Also: Oracle Database Administrator's Guide for more information about the |
|
|
Provides |
|
|
Allows the grantee to register an XML schema globally, as opposed to registering it for use or access only by its owner. It also lets the grantee bypass access control list (ACL) checks when accessing Oracle XML DB Repository. See Also: Oracle XML DB Developer's Guide for information about XML schemas and the XML DB Repository |
|
|
Allows the grantee to define invoker's rights handlers and to create or update the resource configuration for XML repository triggers. By default, Oracle Database grants this role to the See Also: Oracle XML DB Developer's Guide for information about Oracle Database XML repository triggers |
|
|
Allows the grantee to access Oracle Database Web services over HTTPS. However, it does not provide the user access to objects in the database that are public. To allow public access, you need to grant the user the See Also: Oracle XML DB Developer's Guide for information about Oracle Database Web services |
|
|
Allows the grantee to access Oracle Database Web services over HTTP. However, it does not provide the user access to objects in the database that are public. To allow public access, you need to grant the user the See Also: Oracle XML DB Developer's Guide for information about Oracle Database Web services |
|
|
Allows the grantee access to public objects through Oracle Database Web services. See Also: Oracle XML DB Developer's Guide for information about Oracle Database Web services |
Note:
Each installation should create its own roles and assign only those privileges that are needed, thus retaining detailed control of the privileges in use. This process also removes any need to adjust existing roles, privileges, or procedures whenever Oracle Database changes or removes roles that Oracle Database defines. For example, theCONNECT
role now has only one privilege: CREATE SESSION
. Both CONNECT
and RESOURCE
roles will be deprecated in future Oracle Database releases.You can create a role using the CREATE ROLE
statement, but you must have the CREATE ROLE
system privilege to do so. Typically, only security administrators have this system privilege.
Note:
Immediately after creation, a role has no privileges associated with it. To associate privileges with a new role, you must grant privileges or other roles to the new role.You must give each role you create a unique name among existing user names and role names of the database. Roles are not contained in the schema of any user. In a database that uses a multibyte character set, Oracle recommends that each role name contain at least one single-byte character. If a role name contains only multibyte characters, then the encrypted role name and password combination is considerably less secure. See Guideline 1 in "Guidelines for Securing Passwords" for password guidelines.
Example 4-2 creates the clerk
role, which is authorized by the database using the password morework2do
.
Example 4-2 Creating a User Role Authorized by a Password
CREATE ROLE clerk IDENTIFIED BY morework2do;
The IDENTIFIED BY
clause specifies how the user must be authorized before the role can be enabled for use by a specific user to which it has been granted. If this clause is not specified, or NOT IDENTIFIED
is specified, then no authorization is required when the role is enabled. Roles can be specified to be authorized by:
The database using a password
An application using a specified package
Externally by the operating system, network, or other external source
Globally by an enterprise directory service
These authorizations are discussed in the following sections.
You can set or change the authorization method for a role using the ALTER ROLE
statement.
Example 4-3 shows how to alter the clerk
role to specify that the user must have been authorized by an external source before enabling the role.
Example 4-3 Altering a Role to be Authorized by an External Source
ALTER ROLE clerk IDENTIFIED EXTERNALLY;
To alter the authorization method for a role, you must have the ALTER ANY ROLE
system privilege or have been granted the role with the ADMIN OPTION
.
See Also:
Oracle Database SQL Language Reference for syntax, restrictions, and authorization information about the SQL statements used to manage roles and privilegesThe methods of authorizing roles are presented in this section. A role must be enabled for you to use it.
This section describes the following ways you can authorize roles:
See Also:
"When Do Grants and Revokes Take Effect?" for a discussion about enabling rolesYou can protect a role authorized by the database by assigning the role a password. If a user is granted a role protected by a password, then you can enable or disable the role by supplying the proper password for the role in a SET ROLE
statement. However, if the role is made a default role and enabled at connection time, then the user is not required to enter a password.
Example 4-2, "Creating a User Role Authorized by a Password" shows a CREATE ROLE
statement that creates a role called clerk
. When it is enabled, the password morework2do
must be supplied.
Note:
In a database that uses a multibyte character set, passwords for roles must include only single-byte characters. Multibyte characters are not accepted in passwords. See Guideline 1 in "Guidelines for Securing Passwords" for password guidelines.An application role (secure application role) can be enabled only by applications using an authorized PL/SQL package. Application developers do not need to secure a role by embedding passwords inside applications. Instead, they can create an application role and specify which PL/SQL package is authorized to enable the role.
To create a role enabled by an authorized PL/SQL package, use the IDENTIFIED USING
package_name
clause in the CREATE ROLE
SQL statement.
Example 4-4 indicates that the role admin_role
is an application role and the role can only be enabled by any module defined inside the PL/SQL package hr.admin
.
Example 4-4 Creating a Role Authorized by a PL/SQL Package for an Application
CREATE ROLE admin_role IDENTIFIED USING hr.admin;
When you enable the default roles of the user at login as specified in the user profile, Oracle Database performs no checking for application roles.
See the following for more information about secure application roles:
You can create roles that are authorized by the operating system or network clients.
Example 4-5 creates a role named accts_rec
and requires that the user is authorized by an external source before it can be enabled:
Example 4-5 Creating a Role Authorized by an External Source
CREATE ROLE accts_rec IDENTIFIED EXTERNALLY;
Role authentication through the operating system is useful only when the operating system is able to dynamically link operating system privileges with applications. When a user starts an application, the operating system grants an operating system privilege to the user. The granted operating system privilege corresponds to the role associated with the application. At this point, the application can enable the application role. When the application is terminated, the previously granted operating system privilege is revoked from the operating system account of the user.
If a role is authorized by the operating system, then you must configure information for each user at the operating system level. This operation is operating system dependent.
If roles are granted by the operating system, then you do not need to have the operating system authorize them also.
See Also:
"Granting Roles Using the Operating System or Network" for more information about roles granted by the operating systemIf users connect to the database over Oracle Net, then by default, their roles cannot be authenticated by the operating system. This includes connections through a shared server configuration, as this connection requires Oracle Net. This restriction is the default because a remote user could impersonate another operating system user over a network connection. Oracle recommends that you set REMOTE_OS_ROLES
to FALSE
, which is the default.
If you are not concerned with this security risk and want to use operating system role authentication for network clients, then set the initialization parameter REMOTE_OS_ROLES
in the database initialization parameter file to TRUE
. The change will take effect the next time you start the instance and mount the database.
A role can be defined as a global role, where a (global) user can only be authorized to use the role by an enterprise directory service. You define the global role locally in the database by granting privileges and roles to it, but you cannot grant the global role itself to any user or other role in the database. When a global user attempts to connect to the database, the enterprise directory is queried to obtain any global roles associated with the user.
Example 4-6 creates a global role.
Global roles are one component of enterprise user security. A global role only applies to one database, but you can grant it to an enterprise role defined in the enterprise directory. An enterprise role is a directory structure that contains global roles on multiple databases and can be granted to enterprise users.
See "Configuring Global User Authentication and Authorization" for a general discussion of global authentication and authorization of users, and its role in enterprise user management.
See Also:
Oracle Database Enterprise User Security Administrator's Guide for information about implementing enterprise user managementYou can grant system or schema object privileges to a role, and any role can be granted to any database user or to another role (but not to itself). However, a role cannot be granted circularly, that is, role X
cannot be granted to role Y
if role Y
has previously been granted to role X
.
To provide selective availability of privileges, Oracle Database permits applications and users to enable and disable roles. Each role granted to a user is, at any given time, either enabled or disabled. The security domain of a user includes the privileges of all roles currently enabled for the user and excludes the privileges of any roles currently disabled for the user.
A role granted to a role is called an indirectly granted role. You can explicitly enable or disable it for a user. However, whenever you enable a role that contains other roles, you implicitly enable all indirectly granted roles of the directly granted role.
You grant roles to (or revoke roles from) users or other roles by using either of the following methods:
Privileges are granted to and revoked from roles using the same options.
See Also:
Oracle Database 2 Day DBA for more information about Database Control
Any user with the GRANT
ANY
ROLE
system privilege can grant or revoke any role except a global role to or from other users or roles of the database. (A global role is managed in a directory, such as Oracle Internet Directory, but its privileges are contained within a single database.) By default, the SYS
or SYSTEM
user has this privilege. You should grant this system privilege conservatively because it is very powerful.
Any user granted a role with the ADMIN
OPTION
can grant or revoke that role to or from other users or roles of the database. This option allows administrative powers for roles on a selective basis.
See Also:
Oracle Database Enterprise User Security Administrator's Guide for information about global rolesIn some cases, it may be appropriate to drop a role from the database. The security domains of all users and roles granted a dropped role are immediately changed to reflect the absence of the dropped role privileges. All indirectly granted roles of the dropped role are also removed from affected security domains. Dropping a role automatically removes the role from all user default role lists.
Because the creation of objects is not dependent on the privileges received through a role, tables and other objects are not dropped when a role is dropped.
You can drop a role using the SQL statement DROP ROLE
. To drop a role, you must have the DROP ANY ROLE
system privilege or have been granted the role with the ADMIN OPTION
.
The following statement drops the role CLERK
:
DROP ROLE clerk;
This section describes features that you can use to restrict SQL*Plus users from using database roles and thus, prevent serious security problems.
Prebuilt database applications explicitly control the potential actions of a user, including the enabling and disabling of user roles while using the application. By contrast, ad hoc query tools such as SQL*Plus, permit a user to submit any SQL statement (which may or may not succeed), including enabling and disabling a granted role.
Potentially, an application user can exercise the privileges attached to that application to issue destructive SQL statements against database tables by using an ad hoc tool.
For example, consider the following scenario:
The Vacation application has a corresponding vacation
role.
The vacation
role includes the privileges to issue SELECT
, INSERT
, UPDATE
, and DELETE
statements against the emp_tab
table.
The Vacation application controls the use of privileges obtained through the vacation
role.
Now, consider a user who has been granted the vacation
role. Suppose that, instead of using the Vacation application, the user executes SQL*Plus. At this point, the user is restricted only by the privileges granted to him explicitly or through roles, including the vacation
role. Because SQL*Plus is an ad hoc query tool, the user is not restricted to a set of predefined actions, as with designed database applications. The user can query or modify data in the emp_tab
table as he or she chooses.
You can use the PRODUCT_USER_PROFILE
table, which is in the SYSTEM
schema, to disable certain SQL and SQL*Plus commands in the SQL*Plus environment for each user. SQL*Plus, not the Oracle Database, enforces this security. You can even restrict access to the GRANT
, REVOKE
, and SET ROLE
commands to control user ability to change their database privileges.
The PRODUCT_USER_PROFILE
table enables you to list roles that you do not want users to activate with an application. You can also explicitly disable the use of various commands, such as SET ROLE
.
For example, you could create an entry in the PRODUCT_USER_PROFILE
table to:
Disallow the use of the clerk
and manager
roles with SQL*Plus
Disallow the use of SET ROLE
with SQL*Plus
Suppose user Marla connects to the database using SQL*Plus. Marla has the clerk
, manager
, and analyst
roles. As a result of the preceding entry in PRODUCT_USER_PROFILE
, Marla is only able to exercise her analyst
role with SQL*Plus. Also, when Ginny attempts to issue a SET ROLE
statement, she is explicitly prevented from doing so because of the entry in the PRODUCT_USER_PROFILE
table prohibiting use of SET ROLE
.
Be aware that the PRODUCT_USER_PROFILE
table does not completely guarantee security, for multiple reasons. In the preceding example, while SET ROLE
is disallowed with SQL*Plus, if Marla had other privileges granted to her directly, then she could exercise these using SQL*Plus.
See Also:
SQL*Plus User's Guide and Reference for more information about thePRODUCT_USER_PROFILE
tableStored procedures encapsulate the use of privileges with business logic so that privileges are only exercised in the context of a well-formed business transaction. For example, an application developer can create a procedure to update the employee name and address in the employees
table, which enforces that the data can only be updated in normal business hours. Also, rather than grant a human resources clerk the UPDATE
privilege on the employees
table, a security administrator may grant the privilege on the procedure only. Then, the human resources clerk can exercise the privilege only in the context of the procedures, and cannot update the employees
table directly.
A secure application role is a role that can be enabled only by an authorized PL/SQL package. The PL/SQL package itself reflects the security policies needed to control access to the application.
This method of role creation restricts the enabling of such roles to the invoking application. For example, the application can perform authentication and customized authorization, such as checking whether the user has connected through a proxy.
This type of role strengthens security because passwords are not embedded in application source code or stored in a table. This way, the actions the database performs are based on the implementation of your security policies, and these definitions are stored in one place, the database, rather than in your applications. If you need to modify the policy, you do so in one place without having to modify your applications. No matter how many users connect to the database, the result is always the same, because the policy is bound to the role.
When you enable the secure application role, Oracle Database verifies that the authorized PL/SQL package is on the calling stack, that is, it verifies that the authorized PL/SQL package is issuing the command to enable the role. Also, when you enable the default user roles, Oracle Database performs no checking for application roles. So, it is important that you do not make the secure application role the default role of the user, for the role to be checked by the security policy before being granted.
You can use secure application roles to ensure a database connection. Because a secure application role is a role implemented by a package, the package can validate that users can connect to the database through a middle tier or from a specific IP address. In this way, the secure application role prevents users from accessing data outside an application. They are forced to work within the framework of the application privileges that they have been granted.
This section describes how to manage object privileges:
An object privilege is a right to execute a particular type of SQL statement or to access another user's object. Some examples of privileges include the right to:
Connect to the database (create a session)
Create a table
Select rows from another user's table
Execute a stored procedure of another user
Each type of object has different privileges associated with it.
You can specify ALL
[PRIVILEGES
] to grant or revoke all available object privileges for an object. ALL
is not a privilege; rather, it is a shortcut, or a way of granting or revoking all object privileges with one GRANT
and REVOKE
statement. If all object privileges are granted using the ALL
shortcut, then individual privileges can still be revoked.
Similarly, you can revoke all individually granted privileges by specifying ALL
. However, if you REVOKE ALL
, and revoking causes integrity constraints to be deleted (because they depend on a REFERENCES
privilege that you are revoking), then you must include the CASCADE CONSTRAINTS
option in the REVOKE
statement.
Example 4-7 revokes all privileges on the orders table in the HR
schema using CASCADE CONSTRAINTS
.
A schema object privilege is the permission to perform a particular action on a specific schema object.
Different object privileges are available for different types of schema objects. The privilege to delete rows from the departments
table is an example of an object privilege.
Some schema objects, such as clusters, indexes, triggers, and database links, do not have associated object privileges. Their use is controlled with system privileges. For example, to alter a cluster, a user must own the cluster or have the ALTER
ANY
CLUSTER
system privilege.
The following sections discuss granting and revoking such privileges:
The following sections discuss object privileges that apply to specific schema objects:
Sequences (see Oracle Database Administrator's Guide for information on managing sequences)
Functions and Packages(Oracle Database Administrator's Guide for information on managing object dependencies)
Schema object privileges can be granted to and revoked from users and roles. If you grant object privileges to roles, then you can make the privileges selectively available.
You can grant or revoke object privileges for users and roles using the following:
The GRANT
and REVOKE
SQL statements
Oracle Enterprise Manager Database Control
See Also:
Oracle Database 2 Day DBA for more information about Database ControlA user automatically has all object privileges for schema objects contained in his or her schema. A user can grant any object privilege on any schema object the user owns to any other user or role. A user with the GRANT
ANY
OBJECT
PRIVILEGE
can grant or revoke any specified object privilege to another user with or without the GRANT
OPTION
of the GRANT
statement. Otherwise, the grantee can use the privilege, but cannot grant it to other users.
See Also:
Oracle Database SQL Language Reference for information aboutGRANT
and GRANT ANY OBJECT PRIVILEGE
A schema object and its synonym are equivalent with respect to privileges. That is, the object privileges granted for a table, view, sequence, procedure, function, or package apply whether referencing the base object by name or by using a synonym.
For example, assume there is a table jward.emp
with a synonym named jward.employee
. The user jward
issues the following statement:
GRANT SELECT ON emp TO swilliams;
The user swilliams
can query jward.emp
by referencing the table by name or by using the synonym jward.employee
:
SELECT * FROM jward.emp; SELECT * FROM jward.employee;
If you grant object privileges on a table, view, sequence, procedure, function, or package to a synonym for the object, then the effect is the same as if no synonym were used. For example, if jward
wanted to grant the SELECT
privilege for the emp
table to swilliams
, then jward
could issue either of the following statements:
GRANT SELECT ON emp TO swilliams; GRANT SELECT ON employee TO swilliams;
If a synonym is dropped, then all grants for the underlying schema object remain in effect, even if the privileges were granted by specifying the dropped synonym.
Schema object privileges for tables enable table security at the DML (data manipulation language) or DDL (data definition language) level of operation.
The following sections discuss table privileges and DML and DDL operations:
How Table Privileges Affect Data Manipulation Language Operations
How Table Privileges Affect Data Definition Language Operations
You can grant privileges to use the DELETE
, INSERT
, SELECT
, and UPDATE
DML operations on a table or view. Grant these privileges only to users and roles that need to query or manipulate data in a table.
You can restrict INSERT
and UPDATE
privileges for a table to specific columns of the table. With a selective INSERT
privilege, a privileged user can insert a row with values for the selected columns. All other columns receive NULL
or the default value of the column. With a selective UPDATE
privilege, a user can update only specific column values of a row. You can use selective INSERT
and UPDATE
privileges to restrict user access to sensitive data.
For example, if you do not want data entry users to alter the salary
column of the employees
table, then selective INSERT
or UPDATE
privileges can be granted that exclude the salary
column. Alternatively, a view that excludes the salary
column could satisfy this need for additional security.
See Also:
Oracle Database SQL Language Reference for more information about DML operationsThe ALTER
, INDEX
, and REFERENCES
privileges allow DDL operations to be performed on a table. Because these privileges allow other users to alter or create dependencies on a table, you should grant these privileges conservatively.
A user attempting to perform a DDL operation on a table may need additional system or object privileges. For example, to create a trigger on a table, the user requires both the ALTER
TABLE
object privilege for the table and the CREATE
TRIGGER
system privilege.
As with the INSERT
and UPDATE
privileges, you can grant the REFERENCES
privilege on specific columns of a table. The REFERENCES
privilege enables the grantee to use the table on which the grant is made as a parent key to any foreign keys that the grantee wishes to create in his or her own tables. This action is controlled with a special privilege because the presence of foreign keys restricts the data manipulation and table alterations that can be done to the parent key. A column-specific REFERENCES
privilege restricts the grantee to using the named columns (which, of course, must include at least one primary or unique key of the parent table).
See Also:
"Data Integrity" in Oracle Database Concepts for more information about primary keys, unique keys, and integrity constraintsThis section discusses how to manage view privileges. It explores the following topics:
A view is a presentation of data selected from one or more tables, possibly including other views. A view shows the structure of the underlying tables. Its selected data can be thought of as the result of a stored query. A view contains no actual data but rather derives what it shows from the tables and views on which it is based. You can query a view, and change the data it represents. Data in a view can be updated or deleted, and new data inserted. These operations directly alter the tables on which the view is based, and are subject to the integrity constraints and triggers of the base tables.
You can apply DML object privileges to views, similar to tables. Schema object privileges for a view allow various DML operations, which as noted affect the base tables from which the view is derived.
To create a view, you must meet the following requirements:
You must have been granted one of the following system privileges, either explicitly or through a role:
The CREATE
VIEW
system privilege (to create a view in your schema)
The CREATE
ANY
VIEW
system privilege (to create a view in the schema of another user)
You must have been explicitly granted one of the following privileges:
The SELECT
, INSERT
, UPDATE
, or DELETE
object privileges on all base objects underlying the view
The
SELECT
ANY
TABLE
, INSERT
ANY
TABLE
, UPDATE
ANY
TABLE
, or DELETE
ANY
TABLE
system privileges
In addition, to grant other users access to your view, you must have received object privileges to the base objects with the GRANT
OPTION
clause or appropriate system privileges with the ADMIN
OPTION
clause. If you have not, then grantees cannot access your view.
See Also:
Oracle Database SQL Language ReferenceTo use a view, you require appropriate privileges only for the view itself. You do not require privileges on base objects underlying the view.
Views add two more levels of security for tables, column-level security and value-based security:
A view can provide access to selected columns of base tables. For example, you can define a view on the employees
table to show only the employee_id
, last_name
, and manager_id
columns:
CREATE VIEW employees_manager AS SELECT last_name, employee_id, manager_id FROM employees;
A view can provide value-based security for the information in a table. A WHERE
clause in the definition of a view displays only selected rows of base tables. Consider the following two examples:
CREATE VIEW lowsal AS SELECT * FROM employees WHERE salary < 10000;
The lowsal
view allows access to all rows of the employees
table that have a salary value less than 10000. Notice that all columns of the employees
table are accessible in the lowsal
view.
CREATE VIEW own_salary AS SELECT last_name, salary FROM employees WHERE last_name = USER;
In the own_salary
view, only the rows with an last_name
that matches the current user of the view are accessible. The own_salary
view uses the user
pseudocolumn, whose values always refer to the current user. This view combines both column-level security and value-based security.
This section discusses how to manage procedure privileges. It explores the following topics:
EXECUTE
is the only schema object privilege for procedures, including standalone procedures and functions and as packages. Grant this privilege only to users who need to run a procedure or to compile another procedure that calls a desired procedure.
A user with the EXECUTE
object privilege for a specific procedure can execute the procedure or compile a program unit that references the procedure. Oracle Database does not perform a run-time privilege check when the procedure is called. A user with the EXECUTE
ANY
PROCEDURE
system privilege can execute any procedure in the database. Privileges to run procedures can be granted to a user through roles.
How Procedure Privileges Affect Definer's Rights
The owner of a procedure, called the definer, must have all the necessary object privileges for referenced objects. If the owner grants to another user the right to use that procedure, then the owner of the object privileges for the objects referenced by the procedure apply to that user's exercise of the procedure. These are termed definer's rights.
The user of a procedure who is not its owner is called the invoker. Additional privileges on referenced objects are required for invoker's rights procedures, but not for definer's rights procedures.
See Also:
"How Roles Work in PL/SQL Blocks"A user of a definer's rights procedure requires only the privilege to execute the procedure and no privileges on the underlying objects that the procedure accesses. This is because a definer's rights procedure operates under the security domain of the user who owns the procedure, regardless of who is executing it. The owner of the procedure must have all the necessary object privileges for referenced objects. Fewer privileges have to be granted to users of a definer's rights procedure. This results in stronger control of database access.
You can use definer's rights procedures to control access to private database objects and add a level of database security. By writing a definer's rights procedure and granting only EXECUTE
privilege to a user, the user can be forced to access the referenced objects only through the procedure.
At run time, Oracle Database checks the privileges of the owner of a definer's rights stored procedure before the procedure is executed. If a necessary privilege on a referenced object was revoked from the owner of a definer's rights procedure, then the procedure cannot be run by the owner or any other user.
Note:
Trigger processing follows the same patterns as definer's rights procedures. The user runs a SQL statement, which that user is privileged to run. As a result of the SQL statement, a trigger is fired. The statements within the triggered action temporarily execute under the security domain of the user that owns the trigger.See Also:
"Triggers" in Oracle Database ConceptsHow Procedure Privileges Affect Invoker's Rights
An invoker's rights procedure executes with all of the invoker's privileges. Oracle Database enables roles unless a definer's rights procedure calls the invoker's rights procedure directly or indirectly. A user of an invoker's rights procedure needs privileges (either directly or through a role) on objects that the procedure accesses through external references that are resolved in the schema of the invoker.
The invoker needs privileges at run time to access program references embedded in DML statements or dynamic SQL statements, because they are effectively recompiled at run time.
For all other external references, such as direct PL/SQL function calls, Oracle Database checks the privileges of the owner at compile time, and does not performs a run-time check. Therefore, the user of an invoker's rights procedure does not need privileges on external references outside DML or dynamic SQL statements. Alternatively, the developer of an invoker's rights procedure only needs to grant privileges on the procedure itself, not on all objects directly referenced by the invoker's rights procedure.
You can create a software bundle that consists of multiple program units, some with definer's rights and others with invoker's rights, and restrict the program entry points (controlled step-in). A user who has the privilege to run an entry-point procedure can also execute internal program units indirectly, but cannot directly call the internal programs.
See Also:
Oracle Database PL/SQL Packages and Types Reference for detailed documentation of the Oracle Database supplied packages
To create a procedure, a user must have the CREATE
PROCEDURE
or CREATE
ANY
PROCEDURE
system privilege. To alter a procedure, that is, to manually recompile a procedure, a user must own the procedure or have the ALTER
ANY
PROCEDURE
system privilege.
The user who owns the procedure also must have privileges for schema objects referenced in the procedure body. To create a procedure, you need to have been explicitly granted the necessary privileges (system or object) on all objects referenced by the procedure. You cannot obtain the required privileges through roles. This includes the EXECUTE
privilege for any procedures that are called inside the procedure being created.
Note:
Triggers also require that privileges to referenced objects be granted explicitly to the owner of the trigger. Anonymous PL/SQL blocks can use any privilege, whether the privilege is granted explicitly or through a role.A user with the EXECUTE
object privilege for a package can execute any public procedure or function in the package, and can access or modify the value of any public package variable. You cannot grant specific EXECUTE
privileges for individual constructs in a package. Therefore, you may find it useful to consider two alternatives for establishing security when developing procedures, functions, and packages for a database application. The following examples describe these alternatives.
Procedure Privileges and Packages and Package Objects: Example 1
Example 4-8 shows four procedures created in the bodies of two packages.
Example 4-8 Package Objects Affected by Procedure Privileges
CREATE PACKAGE BODY hire_fire AS PROCEDURE hire(...) IS BEGIN INSERT INTO employees . . . END hire; PROCEDURE fire(...) IS BEGIN DELETE FROM employees . . . END fire; END hire_fire; CREATE PACKAGE BODY raise_bonus AS PROCEDURE give_raise(...) IS BEGIN UPDATE employees SET salary = . . . END give_raise; PROCEDURE give_bonus(...) IS BEGIN UPDATE employees SET bonus = . . . END give_bonus; END raise_bonus;
The following GRANT EXECUTE
statements enable the big_bosses
and little_bosses
roles to run the appropriate procedures:
GRANT EXECUTE ON hire_fire TO big_bosses; GRANT EXECUTE ON raise_bonus TO little_bosses;
Note:
GrantingEXECUTE
privilege for a package provides uniform access to all package objects.Procedure Privileges and Packages and Package Objects: Example 2
This example shows four procedure definitions within the body of a single package. Two additional standalone procedures and a package are created specifically to provide access to the procedures defined in the main package.
CREATE PACKAGE BODY employee_changes AS PROCEDURE change_salary(...) IS BEGIN ... END; PROCEDURE change_bonus(...) IS BEGIN ... END; PROCEDURE insert_employee(...) IS BEGIN ... END; PROCEDURE delete_employee(...) IS BEGIN ... END; END employee_changes; CREATE PROCEDURE hire BEGIN employee_changes.insert_employee(...) END hire; CREATE PROCEDURE fire BEGIN employee_changes.delete_employee(...) END fire; PACKAGE raise_bonus IS PROCEDURE give_raise(...) AS BEGIN employee_changes.change_salary(...) END give_raise; PROCEDURE give_bonus(...) BEGIN employee_changes.change_bonus(...) END give_bonus;
Using this method, the procedures that actually do the work (the procedures in the employee_changes
package) are defined in a single package and can share declared global variables, cursors, on so on. By declaring top-level procedures, hire
and fire
, and an additional package, raise_bonus
, you can grant selective EXECUTE
privileges on procedures in the main package:
GRANT EXECUTE ON hire, fire TO big_bosses; GRANT EXECUTE ON raise_bonus TO little_bosses;
The following sections describe the use of privileges for types, methods, and objects:
Table 4-4 lists system privileges for named types (object types, VARRAY
s, and nested tables).
Table 4-4 System Privileges for Named Types
Privilege | Enables you to ... |
---|---|
|
Create named types in your own schemas |
|
Create a named type in any schema |
|
Alter a named type in any schema |
|
Drop a named type in any schema |
|
Use and reference a named type in any schema |
The RESOURCE
role includes the CREATE
TYPE
system privilege. The DBA
role includes all of these privileges.
The only object privilege that applies to named types is EXECUTE
. If the EXECUTE
privilege exists on a named type, then a user can use the named type to:
Define a table
Define a column in a relational table
Declare a variable or parameter of the named type
The EXECUTE
privilege permits a user to invoke the methods in the type, including the type constructor. This is similar to the EXECUTE
privilege on a stored PL/SQL procedure.
Method execution is the same as any other stored PL/SQL procedure.
See Also:
"Managing Procedure Privileges"To create a type, you must meet the following requirements:
You must have the CREATE
TYPE
system privilege to create a type in your schema or the CREATE
ANY
TYPE
system privilege to create a type in the schema of another user. These privileges can be acquired explicitly or through a role.
The owner of the type must be explicitly granted the EXECUTE
object privileges to access all other types referenced within the definition of the type, or have been granted the EXECUTE
ANY
TYPE
system privilege. The owner cannot obtain the required privileges through roles.
If the type owner intends to grant access to the type to other users, then the owner must receive the EXECUTE
privileges to the referenced types with the GRANT
OPTION
or the EXECUTE
ANY
TYPE
system privilege with the ADMIN
OPTION
. If not, then the type owner has insufficient privileges to grant access on the type to other users.
To create a table using types, you must meet the requirements for creating a table and the following additional requirements:
The owner of the table must have been explicitly granted the EXECUTE
object privileges to access all types referenced by the table, or were granted the EXECUTE
ANY
TYPE
system privilege. The owner cannot obtain the required privileges through roles.
If the table owner intends to grant access to the table to other users, then the owner must have the EXECUTE
privileges to the referenced types with the GRANT
OPTION
or the EXECUTE
ANY
TYPE
system privilege with the ADMIN
OPTION
. If not, then the table owner has insufficient privileges to grant access on the type to other users.
See Also:
"Managing Table Privileges" for the requirements for creating a tableAssume that three users exist with the CONNECT
and RESOURCE
roles:
user1
user2
user3
The following DDL is run in the schema of user1
:
CREATE TYPE type1 AS OBJECT ( attr1 NUMBER); CREATE TYPE type2 AS OBJECT ( attr2 NUMBER); GRANT EXECUTE ON type1 TO user2; GRANT EXECUTE ON type2 TO user2 WITH GRANT OPTION;
The following DDL is performed in the schema of user2
:
CREATE TABLE tab1 OF user1.type1; CREATE TYPE type3 AS OBJECT ( attr3 user1.type2); CREATE TABLE tab2 ( col1 user1.type2);
The following statements succeed because user2
has EXECUTE
privilege on user1.type2
with the GRANT
OPTION:
GRANT EXECUTE ON type3 TO user3; GRANT SELECT on tab2 TO user3;
However, the following grant fails because user2
does not have EXECUTE
privilege on user1.type1
with the GRANT
OPTION:
GRANT SELECT ON tab1 TO user3;
The following statements can be successfully run by user3
:
CREATE TYPE type4 AS OBJECT ( attr4 user2.type3); CREATE TABLE tab3 OF type4;
Note:
Customers should discontinue using theCONNECT
and RESOURCE
roles, as they will be deprecated in future Oracle Database releases. The CONNECT
role presently retains only the CREATE SESSION
privilege.Existing column-level and table-level privileges for DML statements apply to both column objects and row objects.
Table 4-5 lists the privileges for object tables.
Table 4-5 Privileges for Object Tables
Privilege | Enables you to... |
---|---|
|
Access an object and its attributes from the table |
|
Modify the attributes of the objects that make up the rows in the table |
|
Create new objects in the table |
|
Delete rows |
Similar table privileges and column privileges apply to column objects. Retrieving instances does not in itself reveal type information. However, clients must access named type information to interpret the type instance images. When a client requests type information, Oracle Database checks for the EXECUTE
privilege on the type.
Consider the following schema:
CREATE TYPE emp_type ( eno NUMBER, ename CHAR(31), eaddr addr_t); CREATE TABLE emp OF emp_t;
In addition, consider the following two queries:
SELECT VALUE(emp) FROM emp; SELECT eno, ename FROM emp;
For either query, Oracle Database checks the SELECT
privilege of the user for the emp
table. For the first query, the user needs to obtain the emp_type
type information to interpret the data. When the query accesses the emp_type
type, Oracle Database checks the EXECUTE
privilege of the user.
Running the second query, however, does not involve named types, so Oracle Database does not check type privileges.
In addition, by using the schema from the previous section, user3
can perform the following queries:
SELECT tab1.col1.attr2 FROM user2.tab1 tab1; SELECT attr4.attr3.attr2 FROM tab3;
Note that in both SELECT
statements, user3
does not have explicit privileges on the underlying types, but the statement succeeds because the type and table owners have the necessary privileges with the GRANT
OPTION.
Oracle Database checks privileges on the following events, and returns an error if the client does not have the privilege for the action:
Pinning an object in the object cache using its REF
value causes Oracle Database to check for the SELECT
privilege on the containing object table.
Modifying an existing object or flushing an object from the object cache causes Oracle Database to check for the UPDATE
privilege on the destination object table.
Flushing a new object causes Oracle Database to check for the INSERT
privilege on the destination object table.
Deleting an object causes Oracle Database to check for the DELETE
privilege on the destination table.
Pinning an object of a named type causes Oracle Database to check EXECUTE
privilege on the object.
Modifying the attributes of an object in a client third-generation language application causes Oracle Database to update the entire object. Therefore, the user needs the UPDATE
privilege on the object table. Having the UPDATE
privilege on only certain columns of the object table is not sufficient, even if the application only modifies attributes corresponding to those columns. Therefore, Oracle Database does not support column-level privileges for object tables.
As with stored objects, such as procedures and tables, types being referenced by other objects are called dependencies. There are some special issues for types on which tables depend. Because a table contains data that relies on the type definition for access, any change to the type causes all stored data to become inaccessible. Changes that can cause this are when necessary privileges required by the type are revoked, or the type or dependent types are dropped. If these actions occur, then the table becomes invalid and cannot be accessed.
A table that is invalid because of missing privileges can automatically become valid and accessible if the required privileges are granted again. A table that is invalid because a dependent type was dropped can never be accessed again, and the only permissible action is to drop the table.
Because of the severe effects that revoking a privilege on a type or dropping a type can cause, the SQL statements REVOKE
and DROP
TYPE
, by default, implement restricted semantics. This means that if the named type in either statement has table or type dependents, then an error is received and the statement cancels. However, if the FORCE
clause for either statement is used, then the statement always succeeds. If there are depended-upon tables, then they are invalidated.
See Also:
Oracle Database Reference for details about using theREVOKE
, DROP
TYPE
, and FORCE
clausesThis section describes the granting of privileges and roles, and contains the following topics:
It is also possible to grant roles to a user connected through a middle tier or proxy. This is discussed in "Using a Middle Tier Server for Proxy Authentication".
You can use the GRANT
SQL statement to grant system privileges and roles to users and roles. The following privileges are required:
To grant a system privilege, a user must be granted the system privilege with the ADMIN OPTION
or was granted the GRANT ANY PRIVILEGE
system privilege.
To grant a role, a user must be granted the role with the ADMIN OPTION
or was granted the GRANT ANY ROLE
system privilege.
Example 4-9 grants the system privilege CREATE SESSION
and the accts_pay
role to the user jward
.
Example 4-9 Granting a System Privilege and a Role to a User
GRANT CREATE SESSION, accts_pay TO jward;
Note:
Object privileges cannot be granted along with system privileges and roles in the sameGRANT
statement.A user or role that is granted a privilege or role, which specifies the WITH ADMIN OPTION
clause, has the following expanded capabilities:
The grantee can grant or revoke the system privilege or role to or from any user or other role in the database. Users cannot revoke a role from themselves.
The grantee can grant the system privilege or role with ADMIN OPTION
.
The grantee of a role can alter or drop the role.
Example 4-10 grants the new_dba
role with the WITH ADMIN OPTION
clause to user michael
.
User michael
is able to not only use all of the privileges implicit in the new_dba
role, but he can also grant, revoke, and drop the new_dba
role as deemed necessary. Because of these powerful capabilities, use caution when granting system privileges or roles with the ADMIN OPTION
. These privileges are usually reserved for a security administrator, and are rarely granted to other administrators or users of the system.
Note:
When a user creates a role, the role is automatically granted to the creator with theADMIN OPTION
.Oracle Database enables you to create a new user with the GRANT
statement. If you specify a password using the IDENTIFIED BY
clause, and the user name and password do not exist in the database, then a new user with that user name and password is created.
Example 4-11 creates psmith
as a new user while granting psmith
the CONNECT
system privilege.
Example 4-11 Creating a New User with the GRANT Statement
GRANT CONNECT TO psmith IDENTIFIED BY two_4_one;
See Also:
"Creating User Accounts"You can use the GRANT
statement to grant object privileges to roles and users. To grant an object privilege, you must fulfill one of the following conditions:
You own the object specified.
You have been granted the GRANT ANY OBJECT PRIVILEGE
system privilege. This privilege enables you to grant and revoke privileges on behalf of the object owner.
The WITH GRANT OPTION
clause was specified when you were granted the object privilege by its owner.
Note:
System privileges and roles cannot be granted along with object privileges in the sameGRANT
statement.Example 4-12 grants the SELECT
, INSERT
, and DELETE
object privileges for all columns of the emp
table to the users jfee
and tsmith
.
Example 4-12 Granting Object Privileges to Users
GRANT SELECT, INSERT, DELETE ON emp TO jfee, tsmith;
To grant all object privileges on the salary
view to user jfee
, use the ALL
keyword as shown in the following example:
GRANT ALL ON salary TO jfee;
Note:
A grantee cannot regrant access to objects unless the original grant included theGRANT OPTION
. Thus in the example just given, jfee
cannot use the GRANT
statement to grant object privileges to anyone else.Specify the WITH GRANT OPTION
clause with the GRANT
statement to enable the grantee to grant the object privileges to other users and roles. The user whose schema contains an object is automatically granted all associated object privileges with the GRANT OPTION
. This special privilege allows the grantee several expanded privileges:
The grantee can grant the object privilege to any user in the database, with or without the GRANT OPTION
, and to any role in the database.
If both of the following conditions are true, then the grantee can create views on the table, and grant the corresponding privileges on the views to any user or role in the database:
The grantee receives object privileges for the table with the GRANT OPTION
.
The grantee has the CREATE VIEW
or CREATE ANY VIEW
system privilege.
The GRANT ANY OBJECT PRIVILEGE
system privilege enables users to grant and revoke any object privilege on behalf of the object owner. This privilege provides a convenient means for database and application administrators to grant access to objects in any schema without requiring that they connect to the schema. Login credentials do not need to be maintained for schema owners who have this privilege, which reduces the number of connections required during configuration.
This system privilege is part of the Oracle Database supplied DBA
role and is thus granted (with the ADMIN OPTION
) to any user connecting AS SYSDBA
(user SYS
). As with other system privileges, the GRANT ANY OBJECT PRIVILEGE
system privilege can only be granted by a user who possesses the ADMIN OPTION
.
The recorded grantor of access rights to an object is either the object owner or the person exercising the GRANT ANY OBJECT PRIVILEGE
system privilege. If the grantor with GRANT ANY OBJECT PRIVILEGE
does not have the object privilege with the GRANT OPTION
, then the object owner is shown as the grantor. Otherwise, when that grantor has the object privilege with the GRANT OPTION
, then that grantor is recorded as the grantor of the grant.
Note:
The audit record generated by theGRANT
statement always shows the actual user who performed the grant.For example, consider the following scenario. User adams
possesses the GRANT ANY OBJECT PRIVILEGE
system privilege. He does not possess any other grant privileges. He issues the following statement:
GRANT SELECT ON hr.employees TO blake WITH GRANT OPTION;
If you examine the DBA_TAB_PRIVS
view, then you will see that hr
is shown as the grantor of the privilege:
SELECT GRANTEE, OWNER, GRANTOR, PRIVILEGE, GRANTABLE FROM DBA_TAB_PRIVS WHERE TABLE_NAME = 'EMPLOYEES' and OWNER = 'HR'; GRANTEE OWNER GRANTOR PRIVILEGE GRANTABLE -------- ----- ------- ----------- ---------- BLAKE HR HR SELECT YES
Now assume that user blake
also has the GRANT ANY OBJECT PRIVILEGE
system. He issues the following statement:
GRANT SELECT ON hr.employees TO clark;
In this case, when you query the DBA_TAB_PRIVS
view again, you see that blake
is shown as being the grantor of the privilege:
GRANTEE OWNER GRANTOR PRIVILEGE GRANTABLE -------- ----- -------- -------- ---------- BLAKE HR HR SELECT YES CLARK HR BLAKE SELECT NO
This occurs because blake
already possesses the SELECT
privilege on hr.employees
with the GRANT OPTION
.
You can grant INSERT
, UPDATE
, or REFERENCES
privileges on individual columns in a table.
Caution:
Before granting a column-specificINSERT
privilege, determine if the table contains any columns on which NOT NULL
constraints are defined. Granting selective insert capability without including the NOT NULL
columns prevents the user from inserting any rows into the table. To avoid this situation, ensure that each NOT NULL
column can either be inserted into or has a non-NULL
default value. Otherwise, the grantee will not be able to insert rows into the table and will receive an error.The following statement grants the INSERT
privilege on the acct_no
column of the accounts
table to user scott
:
GRANT INSERT (acct_no) ON accounts TO scott;
In the following example, object privilege for the ename
and job
columns of the emp
table are granted to the users jfee
and tsmith
:
GRANT INSERT(ename, job) ON emp TO jfee, tsmith;
This section describes the following aspects of revoking user privileges and roles:
You can revoke system privileges and roles using the SQL statement REVOKE
. Any user with the ADMIN OPTION
for a system privilege or role can revoke the privilege or role from any other database user or role. The revoker does not have to be the user that originally granted the privilege or role. Users with GRANT ANY ROLE
can revoke any role.
The following statement revokes the CREATE TABLE
system privilege and the accts_rec
role from user tsmith
:
REVOKE CREATE TABLE, accts_rec FROM tsmith;
To revoke an object privilege, you must fulfill one of the following conditions:
You previously granted the object privilege to the user or role.
You possess the GRANT ANY OBJECT PRIVILEGE
system privilege that enables you to grant and revoke privileges on behalf of the object owner.
You can only revoke the privileges that you, the grantor, directly authorized, not the grants made by other users to whom you granted the GRANT OPTION
. However, there is a cascading effect. The object privilege grants propagated using the GRANT OPTION
are revoked if a grantor object privilege is revoked.
Assuming you are the original grantor, the following statement revokes the SELECT
and INSERT
privileges on the emp
table from users jfee
and tsmith
:
REVOKE SELECT, INSERT ON emp FROM jfee, tsmith;
The following statement revokes all object privileges for the dept
table that you originally granted to the human_resource
role:
REVOKE ALL ON dept FROM human_resources;
Note:
TheGRANT OPTION
for an object privilege cannot be selectively revoked. Instead, revoke the object privilege and then granted it again but without the GRANT OPTION
. Users cannot revoke object privileges from themselves.The GRANT ANY OBJECT PRIVILEGE
system privilege enables you to revoke any specified object privilege where the object owner is the grantor. This occurs when the object privilege is granted by the object owner, or on behalf of the owner by any user holding the GRANT ANY OBJECT PRIVILEGE
system privilege.
In a situation where the object privilege was granted by both the owner of the object and the user executing the REVOKE
statement (who has both the specific object privilege and the GRANT ANY OBJECT PRIVILEGE
system privilege), Oracle Database only revokes the object privilege granted by the user issuing the REVOKE
statement. This can be illustrated by continuing the example started in "Granting Object Privileges on Behalf of the Object Owner".
At this point, user blake
granted the SELECT
privilege on HR.EMPLOYEES
to clark
. Even though blake
possesses the GRANT ANY OBJECT PRIVILEGE
system privilege, he also holds the specific object privilege, thus this grant is attributed to him. Assume that user HR
also grants the SELECT
privilege on HR.EMPLOYEES
to user clark
. A query of the DBA_TAB_PRIVS
view shows that the following grants are in effect for the HR.EMPLOYEES
table:
GRANTEE OWNER GRANTOR PRIVILEGE GRANTABLE -------- ----- ------- ----------- ---------- BLAKE HR HR SELECT YES CLARK HR BLAKE SELECT NO CLARK HR HR SELECT NO
User blake
now issues the following REVOKE
statement:
REVOKE SELECT ON hr.employees FROM clark;
Only the object privilege for user clark
granted by user blake
is removed. The grant by the object owner, hr
, remains.
GRANTEE OWNER GRANTOR PRIVILEGE GRANTABLE -------- ----- ------- ----------- ---------- BLAKE HR HR SELECT YES CLARK HR HR SELECT NO
If blake
issues the REVOKE
statement again, then this time the effect will be to remove the object privilege granted by hr
.
Although users can grant column-selective INSERT
, UPDATE
, and REFERENCES
privileges for tables and views, they cannot selectively revoke column-specific privileges with a similar REVOKE
statement. Instead, the grantor must first revoke the object privilege for all columns of a table or view, and then selectively grant again the column-specific privileges that should remain.
For example, assume that role human_resources
was granted the UPDATE
privilege on the deptno
and dname
columns of the table dept
. To revoke the UPDATE
privilege on just the deptno
column, issue the following two statements:
REVOKE UPDATE ON dept FROM human_resources; GRANT UPDATE (dname) ON dept TO human_resources;
The REVOKE
statement revokes the UPDATE
privilege on all columns of the dept
table from the role human_resources
. The GRANT
statement then grants again the UPDATE
privilege on the dname
column to the role human_resources
.
If the grantee of the REFERENCES
object privilege has used the privilege to create a foreign key constraint (that currently exists), then the grantor can revoke the privilege only by specifying the CASCADE CONSTRAINTS
option in the REVOKE
statement:
REVOKE REFERENCES ON dept FROM jward CASCADE CONSTRAINTS;
Any foreign key constraints currently defined that use the revoked REFERENCES
privilege are dropped when the CASCADE CONSTRAINTS
clause is specified.
Depending on the type of privilege, there may be cascading effects when a privilege is revoked. This is discussed in the following sections:
There are no cascading effects when revoking a system privilege related to DDL operations, regardless of whether the privilege was granted with or without the ADMIN OPTION
. For example, assume the following:
The security administrator grants the CREATE TABLE
system privilege to user jfee
with the ADMIN OPTION
.
User jfee
creates a table.
User jfee
grants the CREATE TABLE
system privilege to user tsmith
.
User tsmith
creates a table.
The security administrator revokes the CREATE TABLE
system privilege from user jfee
.
The table created by user jfee
continues to exist. User tsmith
still has the table and the CREATE TABLE
system privilege.
You can observe cascading effects when you revoke a system privilege related to a DML operation. If the SELECT ANY TABLE
privilege is revoked from a user, then all procedures contained in the users schema relying on this privilege fails until the privilege is reauthorized.
Revoking an object privilege can have cascading effects. Remember the following:
Object definitions that depend on a DML object privilege can be affected if the DML object privilege is revoked. For example, assume that the body of the test
procedure includes a SQL statement that queries data from the emp
table. If the SELECT
privilege on the emp
table is revoked from the owner of the test
procedure, then the procedure can no longer be executed successfully.
When a REFERENCES privilege for a table is revoked from a user, any foreign key integrity constraints that are defined by the user and require the dropped REFERENCES privilege are automatically dropped. For example, assume that user jward
is granted the REFERENCES
privilege for the deptno
column of the dept
table. This user now creates a foreign key on the deptno
column in the emp
table that references the deptno
column of the dept
table. If the REFERENCES
privilege on the deptno
column of the dept
table is revoked, then the foreign key constraint on the deptno
column of the emp
table is dropped in the same operation.
The object privilege grants propagated using the GRANT OPTION are revoked if the object privilege of a grantor is revoked. For example, assume that user1
is granted the SELECT
object privilege with the GRANT OPTION
, and grants the SELECT
privilege on emp
to user2
. Subsequently, the SELECT
privilege is revoked from user1
. This REVOKE
statement is also cascaded to user2
. Any objects that depend on the revoked SELECT
privilege of user1
and user2
can also be affected, as described earlier.
Object definitions that require the ALTER
and INDEX DDL
object privileges are not affected if the ALTER
or INDEX
object privilege is revoked. For example, if the INDEX
privilege is revoked from a user that created an index on a table that belongs to another user, then the index continues to exist after the privilege is revoked.
You can grant and revoke privileges and roles from the user group PUBLIC
. Because PUBLIC
is accessible to every database user, all privileges and roles granted to PUBLIC
are accessible to every database user.
Security administrators and database users should grant a privilege or role to PUBLIC
only if every database user requires the privilege or role. This recommendation reinforces the general rule that, at any given time, each database user should have only the privileges required to accomplish the current group tasks successfully.
Revoking a privilege from PUBLIC
can cause significant cascading effects. If any privilege related to a DML operation is revoked from PUBLIC
(for example, SELECT ANY TABLE
or UPDATE ON
emp
), then all procedures in the database, including functions and packages, must be reauthorized before they can be used again. Therefore, be careful when you grant and revoke DML-related privileges to or from PUBLIC
.
See Also:
Managing Object Dependencies in Oracle Database Administrator's Guide for more information about object dependencies
This section describes the following aspects of granting roles through your operating system or network:
Instead of a security administrator explicitly granting and revoking database roles to and from users using GRANT
and REVOKE
statements, the operating system that operates Oracle Database can grant roles to users at connect time. Roles can be administered using the operating system and passed to Oracle Database when a user creates a session. As part of this mechanism, the default roles of a user and the roles granted to a user with the ADMIN OPTION
can be identified. If the operating system is used to authorize users for roles, then all roles must be created in the database and privileges assigned to the role with GRANT
statements.
Roles can also be granted through a network service.
The advantage of using the operating system to identify the database roles of a user is that privilege management for an Oracle database can be externalized. The security facilities offered by the operating system control user privileges. This option may offer advantages of centralizing security for a number of system activities, such as the following situation:
MVS Oracle administrators want RACF groups to identify database user roles.
UNIX Oracle administrators want UNIX groups to identify database user roles.
VMS Oracle administrators want to use rights identifiers to identify database user roles.
The main disadvantage of using the operating system to identify the database roles of a user is that privilege management can only be performed at the role level. Individual privileges cannot be granted using the operating system, but they can still be granted inside the database using GRANT
statements.
A second disadvantage of using this feature is that, by default, users cannot connect to the database through the shared server or any other network connection if the operating system is managing roles. However, you can change this default as described in "Using Network Connections with Operating System Role Management".
Note:
The features described in this section are available only on some operating systems. See your operating system-specific Oracle Database documentation to determine if you can use these features.To cause a database to use the operating system to identify the database roles of each user when a session is created, set the initialization parameter OS_ROLES
to TRUE
(and restart the instance, if it is currently running). When a user tries to create a session with the database, Oracle Database initializes the user security domain using the database roles identified by the operating system.
To identify database roles for a user, the operating system account for each Oracle Database user must have operating system identifiers (these may be called groups, rights identifiers, or other similar names) that indicate which database roles are to be available for the user. Role specification can also indicate which roles are the default roles of a user and which roles are available with the ADMIN OPTION
. No matter which operating system is used, the role specification at the operating system level follows the format:
ora_ID_ROLE[_[d][a]]
In this specification:
ID
has a definition that varies on different operating systems. For example, on VMS, ID
is the instance identifier of the database; on VMS, it is the computer type; and on UNIX, it is the system ID
.
Note:
ID
is case-sensitive to match your ORACLE_SID
. ROLE
is not case-sensitive.ROLE
is the name of the database role.
d
is an optional character that indicates this role is to be a default role of the database user.
a
is an optional character that indicates this role is to be granted to the user with the ADMIN OPTION
. This allows the user to grant the role to other roles only. Roles cannot be granted to users if the operating system is used to manage roles.
Note:
If either thed
or a
character is specified, then precede that character by an underscore (_).For example, an operating system account might have the following roles identified in its profile:
ora_PAYROLL_ROLE1 ora_PAYROLL_ROLE2_a ora_PAYROLL_ROLE3_d ora_PAYROLL_ROLE4_da
When the corresponding user connects to the payroll
instance of Oracle Database, role3
and role4
are defaults, while role2
and role4
are available with the ADMIN OPTION
.
When you use operating system-managed roles, remember that database roles are being granted to an operating system user. Any database user to which the operating system user is able to connect will have the authorized database roles enabled. For this reason, you should consider defining all Oracle Database users as IDENTIFIED EXTERNALLY
if you are using OS_ROLES = TRUE
, so that the database accounts are tied to the operating system account that was granted privileges.
If the OS_ROLES
parameter is set to TRUE
, then the operating system completely manages the granting and revoking of roles to users. Any previous granting of roles to users using GRANT
statements do not apply. However, they are still listed in the data dictionary. Only the role grants to users made at the operating system level apply. Users can still grant privileges to roles and users.
Note:
If the operating system grants a role to a user with theADMIN OPTION
, then the user can grant the role only to other roles.If the OS_ROLES
initialization parameter is set to TRUE
, then any role granted by the operating system can be dynamically enabled using the SET ROLE
statement. This still applies, even if the role was defined to require a password or operating system authorization. However, any role not identified in the operating system account of a user cannot be specified in a SET ROLE
statement, even if a role was granted using a GRANT
statement when OS_ROLES = FALSE
. (If you specify such a role, then Oracle Database ignores it.)
When OS_ROLES = TRUE
, a user can enable as many roles as specified by the initialization parameter MAX_ENABLED_ROLES
.
If you have the operating system manage roles, then, by default, users cannot connect to the database through the shared server. This restriction is the default because a remote user could impersonate another operating system user over an unsecure connection.
If you are not concerned with this security risk and want to use operating system role management with the shared server, or any other network connection, then set the initialization parameter REMOTE_OS_ROLES
to TRUE
. The change takes effect the next time you start the instance and mount the database. The default setting of this parameter is FALSE
.
Depending on what is granted or revoked, a grant or revoke takes effect at different times:
All grants and revokes of system and object privileges to anything (users, roles, and PUBLIC
) take immediate effect.
All grants and revokes of roles to anything (users, other roles, PUBLIC
) take effect only when a current user session issues a SET ROLE
statement to reenable the role after the grant and revoke, or when a new user session is created after the grant or revoke.
You can see which roles are currently enabled by examining the SESSION_ROLES
data dictionary view.
During the user session, the user or an application can use the SET ROLE
statement any number of times to change the roles currently enabled for the session. The user must already be granted the roles that are named in the SET ROLE
statement.
To specify the maximum number of roles number of roles that can be concurrently enabled, set the initialization parameter MAX_ENABLED_ROLES
.
Example 4-13 enables the role clerk
, which you have already been granted, and specifies the password.
Example 4-13 Using SET ROLE to Grant a Role and Specify a Password
SET ROLE clerk IDENTIFIED BY morework2do;
Example 4-14 shows how to use SET ROLE
to disable all roles.
When a user logs on, Oracle Database enables all privileges granted explicitly to the user and all privileges in the default roles of the user.
You can set and alter a list of default roles for a user by using the ALTER USER
SQL statement. The ALTER USER
statement specifies roles that are to be enabled when a user connects to the database, without requiring the user to specify the role passwords. The user must have been directly granted the roles with a GRANT
statement. You cannot specify as a default role any role managed by an external service including a directory service (external roles or global roles).
Example 4-15 sets the default roles payclerk
and pettycash
for user jane
:
Example 4-15 Using ALTER USER to Set Default Roles
ALTER USER jane DEFAULT ROLE payclerk, pettycash;
You cannot set default roles for a user in the CREATE USER
statement. When you first create a user, the default user role setting is ALL
, which causes all roles subsequently granted to the user to be default roles. Use the ALTER USER
statement to limit the default user roles.
Caution:
When you create a role (other than a user role), it is granted implicitly and added as a default role. When theMAX_ENABLED_ROLES
initialization parameter is set, users receive an error at login if they have more roles than MAX_ENABLED_ROLES
specifies. You can avoid this error by changing the default user roles to be less than MAX_ENABLED_ROLES
. Therefore, you should change the DEFAULT ROLE
settings of SYS
and SYSTEM
before creating user roles. See Oracle Database Reference for more information about MAX_ENABLED_ROLES
.A user can enable as many roles as specified by the initialization parameter MAX_ENABLED_ROLES
. All indirectly granted roles enabled as a result of enabling a primary role are included in this count. The database administrator can alter this limitation by modifying the value for this parameter. Higher values permit each user session to have more concurrently enabled roles, but these values also cause more memory to be used for each user session. This occurs because the PGA size requires four bytes for each role in each session. Determine the highest number of roles that will be concurrently enabled by any one user, and use this value for the MAX_ENABLED_ROLES
parameter.
For detailed information about the MAX_ENABLED_ROLES
initialization parameter, see Oracle Database Reference.
You can configure fine-grained access control for users and roles that need to access external network services from the database. This way, specific groups of users can connect to one or more host computers, based on privileges that you grant them. Typically, you use this feature to control access to applications that run on specific host addresses.
This section includes the following topics:
Upgrading Applications That Depend on the PL/SQL Network Utility Packages
Creating an Access Control List for Database Network Services
Precedence Order for a Host Computer in Multiple Access Control List Assignments
Precedence Order for a Host in Access Control List Assignments with Port Ranges
Checking Privilege Assignments That Affect User Access to a Network Host
Setting the Precedence of Multiple Users and Roles in One Access Control List
Using Data Dictionary Views to Find Information About Access Control Lists
To configure fine-grained access to database network services, you create an access control list (ACL), which is stored in Oracle XML DB. You can create the access control list by using Oracle XML DB itself, or by using the DBMS_NETWORK_ACL_ADMIN
and DBMS_NETWORK_ACL_UTILITY
PL/SQL packages. This guide explains how to use these packages to create and manage the access control list. To create an access control list by using Oracle XML DB and for general conceptual information about access control lists, see Oracle XML DB Developer's Guide.
This feature enhances security for network connections because it restricts the external network hosts that a database user can connect to using the PL/SQL network utility packages such as UTL_TCP
, UTL_SMTP
, UTL_MAIL
, UTL_HTTP
, and UTL_INADDR
. Otherwise, an intruder who gained access to the database could maliciously attack the network, because, by default, the PL/SQL utility packages are created with the EXECUTE
privilege granted to PUBLIC
users.
If you have upgraded from a previous release of Oracle Database, and your applications depend on PL/SQL network utility packages such as UTL_TCP
, UTL_SMTP
, UTL_MAIL
, UTL_HTTP
, and UTL_INADDR
, the following error may occur when you try to run the application:
ORA-24247: network access denied by access control list (ACL)
Use the procedures in this section to reconfigure the network access for the application. See also Oracle Database Upgrade Guide for compatibility issues for applications that depend on the PL/SQL network utility packages. For detailed information on the network utility packages, see Oracle Database PL/SQL Packages and Types Reference.
When you create access control lists for network connections, you should create one access control list dedicated to a group of common users, for example, users who need access to a particular application that resides on a specific host computer. For ease of administration and for good system performance, do not create too many access control lists. Network hosts accessible to the same group of users should share the same access control list.
To create the access control list by using the DBMS_NETWORK_ACL_ADMIN
package, follow these steps:
Step 1: Create the Access Control List and Its Privilege Definitions
Step 2: Assign the Access Control List to One or More Network Hosts
Use the DBMS_NETWORK_ACL_ADMIN.CREATE_ACL
procedure to create the content of the access control list. It contains a name of the access control list, a brief description, and privilege settings for one user or role that you want to associate with the access control list. In an access control list, privileges for each user or role are grouped together as an access control entry (ACE). An access control list must have the privilege settings for at least one user or role.
Note:
You cannot import or export the access control list settings by using the Oracle Database import or export utilities such as Oracle Data Pump.The syntax for creating an access control list is as follows:
BEGIN DBMS_NETWORK_ACL_ADMIN.CREATE_ACL ( acl => 'file_name.xml', description => 'file description', principal => 'user_or_role', is_grant => TRUE|FALSE, privilege => 'connect|resolve', start_date => null|timestamp_with_time_zone, end_date => null|timestamp_with_time_zone); END;
In this specification:
acl
: Enter a name for the access control list XML file. Oracle Database creates this file relative to the /sys/acls
directory in the XML DB Repository in the database. Include the .xml
extension. For example:
acl => 'us-mycompany-com-permissions.xml',
description
: Enter a brief description of the file's purpose. For example:
description => 'Network connection permission for ACCT_MGR role',
principal
: Enter the user account or role being granted or denied permissions. For example:
principal => 'ACCT_MGR',
Enter the name of the user account or role in case sensitive characters. For example, if the database stores the user name preston
in all capital letters, entering it in mixed or lower case will not work. You can find the user accounts and roles in the current database instance by querying the DBA_USERS
and DBA_ROLES
views, for example:
SELECT USERNAME FROM DBA_USERS; SELECT ROLE FROM DBA_ROLES;
is_grant
: Enter either TRUE
or FALSE
, to indicate whether the privilege is to be granted or denied. For example:
is_grant => TRUE,
privilege
: Enter either connect
or resolve
. This setting is case sensitive, so always enter it in lowercase. For example:
privilege => 'connect',
A database user needs the connect
privilege to an external network host computer if he or she is connecting using the UTL_TCP
, UTL_HTTP
, UTL_SMTP
, and UTL_MAIL
utility packages. To resolve the host name that was given a host IP address, or the IP address that was given a host name, with the UTL_INADDR
package, grant the database user the resolve
privilege instead.
You can use the data dictionary views described in "Using Data Dictionary Views to Find Information About Access Control Lists" to find more information about existing privileges and network connections.
start_date
: (Optional) Enter the start date for the access control entry (ACE), in TIMESTAMP WITH TIME ZONE
format (YYYY-MM-DD HH:MI:SS.FF TZR). When specified, the access control entry will be valid only on or after the specified date. The default is null
. For example, to set a start date of February 28, 2007, at 6:30 a.m. in San Francisco, California, U.S., which is in the Pacific time zone:
start_date => '2006-02-28 06:30:00.00 US/Pacific',
The NLS_TIMESTAMP_FORMAT
initialization parameter sets the default timestamp format. See Oracle Database Reference for more information.
end_date
: (Optional) Enter the end date for the access control entry (ACE), in TIMESTAMP WITH TIME ZONE
format (YYYY-MM-DD HH:MI:SS.FF TZR). When specified, the access control entry will expire after the specified date. The end_date
setting must be greater than or equal to the start_date
setting. The default is null
.
For example, to set an end date of December 10, 2007, at 11:59 p.m. in San Francisco, California, U.S., which is in the Pacific time zone:
end_date => '2007-12-10 23:59:00.00 US/Pacific');
To add more users or roles to the access control list, use the DBMS_NETWORK_ACL.ADD_PRIVILEGE
procedure. The syntax is as follows:
BEGIN DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE ( acl => 'file_name.xml', principal => 'user_or_role', is_grant => TRUE|FALSE, privilege => 'connect|resolve', position => null|value, start_date => null|timestamp_with_time_zone, end_date => null|timestamp_with_time_zone); END;
As you can see, the parameters to add the privilege are the similar to those in the CREATE_ACL
procedure, except that description
is not included and the position
parameter, which sets the order of precedence for multiple users or roles, was added. Because you now are adding more than one user or role, you may want to consider setting their precedence. "Setting the Precedence of Multiple Users and Roles in One Access Control List" provides more information.
Other DBMS_NETWORK_ACL_ADMIN
procedures that are available for this step are DELETE_PRIVILEGE
and DROP_ACL
.
At this stage, you have created an access control list that defines the privileges needed to connect to a network host. However, the access control list has no effect until you complete Step 2: Assign the Access Control List to One or More Network Hosts.
After you create the access control list, then you are ready to assign it to one or more network host computers. You can use the DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL
procedure to do so.
For example:
BEGIN DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL ( acl => 'file_name.xml', host => 'network_host', lower_port => null|port_number, upper_port => null|port_number); END;
In this specification:
acl
: Enter the name of the access control list XML file to assign to the network host. Oracle Database creates this file relative to the /sys/acls
directory in the XML DB Repository in the database. Include the .xml
extension. For example:
acl => 'us-mycompany-com-permissions.xml',
host
: Enter the network host to which this access control list will be assigned. This setting can be a name or IP address of the network host. Host names are case-insensitive. For example:
host => 'us.mycompany.com',
See the following sections for more information about how network host computers in access control list assignments work:
lower_port
: (Optional) For TCP connections, enter the lower boundary of the port range. Use this setting for the connect
privilege only; omit it for the resolve
privilege. The default is null
. For example:
lower_port => 80,
upper_port
: (Optional) For TCP connections, enter the upper boundary of the port range. Use this setting for connect
privileges only; omit it for resolve
privileges. The default is null
. For example:
upper_port => 3999);
If you enter a value for the lower_port
and leave the upper_port
at null
(or just omit it), Oracle Database assumes the upper_port
setting is the same as the lower_port
. For example, if you set lower_port
to 80
and omit upper_port
, the upper_port
setting is assumed to be 80
.
The resolve
privilege in the access control list takes no effect when a port range is specified in the access control list assignment.
Only one access control list can be assigned to any host computer, domain, or IP subnet, and if specified, the TCP port range. When you assign a new access control list to a network target, Oracle Database unassigns the previous access control list that was assigned to the same target. However, Oracle Database does not drop the access control list. You can drop the access control list by using the DROP_ACL
procedure. To remove an access control list assignment, use the UNASSIGN_ACL
procedure.
Depending on how you create and maintain the access control list, the two steps may overlap. For example, you can create an access control list that has privileges for five users in it, and then apply it to two host computers. Later on, you can modify this access control list to have different or additional users and privileges, and assign it to different or additional host computers.
All access control list changes, including the assignment to network hosts, are transactional. They do not take effect until the transaction is committed.
You can find information about existing privileges and network connections by using the data dictionary views described in Table 4-6, "Data Dictionary Views That Display Information about Access Control Lists".
For information about using the DBMS_NETWORK_ACL_ADMIN
package, see Oracle Database PL/SQL Packages and Types Reference.
The following examples demonstrate how to create access control lists.
Example 4-16 shows how you would create an access control list called us-mycompany-com-permissions.xml
to grant users who have the ACCT_MGR
role access to network services that run on the host us.mycompany.com
.
Example 4-16 Creating an Access Control List for a Single Role and Network Connection
-- First, create the access control list, which includes one role: BEGIN DBMS_NETWORK_ACL_ADMIN.CREATE_ACL ( acl => 'us-mycompany-com-permissions.xml', description => 'Network connection permission for ACCT_MGR', principal => 'ACCT_MGR', is_grant => TRUE, privilege => 'connect'); END; -- Second, assign the access control list a network host: BEGIN DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL ( acl => 'us-mycompany-com-permissions.xml', host => 'www.us.mycompany.com', lower_port => 80, upper_port => 80); END;
This example creates the us-mycompany-com-permissions.xml
file in the /sys/acls
directory, which is the default location. The XML file appears as follows:
<acl description="Network connection permission for ACCT_MGR" xmlns="http://xmlns.oracle.com/xdb/acl.xsd" xmlns:plsql="http://xmlns.oracle.com/plsql" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/xdb/acl.xsd http://xmlns.oracle.com/xdb/acl.xsd"> <security-class>plsql:network</security-class> <ace> <grant>true</grant> <principal>ACCT_MGR</principal> <privilege><plsql:connect/></privilege> </ace> </acl>
The xmlns
and xsi
elements are fixed and should not be modified, for example, in a text editor.
You can check the contents of the access control list in SQL*Plus. See Oracle XML DB Developer's Guide for examples.
Example 4-17 shows how to create a slightly more complex version of the us-mycompany-com-permissions.xml
access control list. In this example, you specify multiple role privileges and their precedence position, and assigned to multiple host computers.
See"Using Wildcard Characters in Network Host Computers" and "Precedence Order for a Host Computer in Multiple Access Control List Assignments" for more information about host names. See also "Setting the Precedence of Multiple Users and Roles in One Access Control List" to determine the order of multiple ACE
elements in the access control list XML file.
Example 4-17 Creating an Access Control List for Multiple Roles and Network Connections
-- Create the access control list: BEGIN DBMS_NETWORK_ACL_ADMIN.CREATE_ACL ( acl => 'us-mycompany-com-permissions.xml', description => 'Network connection permission for ACCT_MGR and ACCT_CLERK', principal => 'ACCT_MGR', is_grant => TRUE, privilege => 'resolve'); DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE ( -- Creates the second role privilege acl => 'us-mycompany-com-permissions.xml', principal => 'ACCT_CLERK', is_grant => TRUE, privilege => 'connect', position => null); END; -- Assign the access control list to hosts: BEGIN DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL ( -- Creates the first target host acl => 'us-mycompany-com-permissions.xml', host => '*.us.mycompany.com'); DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL ( -- Creates the second target host acl => 'us-mycompany-com-permissions.xml', host => '*.uk.mycompany.com', lower_port => 80, upper_port => 99); END;
The us-mycompany-com-permissions.xml
appears as follows:
<acl description="Network connection permission for ACCT_MGR and ACCT_CLERK" xmlns="http://xmlns.oracle.com/xdb/acl.xsd" xmlns:plsql="http://xmlns.oracle.com/plsql" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.oracle.com/xdb/acl.xsd http://xmlns.oracle.com/xdb/acl.xsd"> <security-class>plsql:network</security-class> <ace> <grant>true</grant> <principal>ACCT_MGR</principal> <privilege><plsql:resolve/></privilege> </ace> <ace> <grant>true</grant> <principal>ACCT_CLERK</principal> <privilege><plsql:connect/></privilege> </ace> </acl>
Example 4-18 shows how the DBA_NETWORK_ACL_PRIVILEGES
data dictionary view displays the privilege granted in the previous access control list.
Example 4-18 Using the DBA_NETWORK_ACL_PRIVILEGES View to Show Granted Privileges
ACL ACLID PRINCIPAL PRIVILEGE IS_GRANT INVERT START_DATE END_DATE ------------------------------------------ -------------------------------- ---------- ------- -------- ------- ---------- ---------- /sys/acls/us-mycompany-com-permissions.xml 2EF86135D0E29B2AE040578CE4043250 ACCT_ MGR resolve true false /sys/acls/us-mycompany-com-permissions.xml 2EF86135D0E29B2AE040578CE4043250 ACCT_ CLERK connect true false
Example 4-19 shows how the DBA_NETWORK_ACLS
data dictionary view displays the host assignment of the access control list.
Example 4-19 Using the DBA_NETWORK_ACLS View to Show Host Assignments
HOST LOWER_PORT UPPER_PORT ACL ACLID -------------------- ---------- ---------- ------------------------------------------ -------------------------------- *.us.mycompany.com /sys/acls/us-mycompany-com-permissions.xml 2EF86135D0E29B2AE040578CE4043250 *.uk.mycompany.com 80 99 /sys/acls/us-mycompany-com-permissions.xml 2EF86135D0E29B2AE040578CE4043250
In these examples, the ACCT_MGR
role has the resolve
privilege to the first host, and the ACCT_CLERK
role has the connect privilege to the first and second target hosts. The ACCT_MGR
role does not have the resolve
privilege to the second host because a port range is specified in the assignment to the second host.
To check the contents of the access control list in SQL*Plus, see Oracle XML DB Developer's Guide for examples.
If you want to assign an access control list to a group of network host computers, you can use the asterisk (*) wildcard character. For example, enter *.mycompany.com
for host computers that belong to a domain or 192.168.0.*
for IP addresses that belong to an IP subnet. The asterisk wildcard must be at the beginning, before a period (.) in a domain, or at the end, after a period (.), in an IP subnet. For example, *.mycompany.com
is valid, but *mycompany.com
and *.mycompany.*
are not.
Be aware that the use of wildcard characters affects the order of precedence for multiple access control lists that are assigned to the same host computer.
For multiple access control lists that are assigned to the host computer and its domains, the access control list that is assigned to the host computer takes precedence over those assigned to the domains. The access control list assigned to a domain has a lower precedence than those assigned to the subdomains.
For example, Oracle Database first selects the access control list assigned to the host server.us.mycompany.com
, ahead of other access control lists assigned to its domains. If additional access control lists were assigned to the sub domains, their order of precedence is as follows:
server.us.mycompany.com
*.us.mycompany.com
*.mycompany.com
*.com
*
Similarly, here is how the order of precedence works for the IP address 111.222.0.4
:
111.222.0.4
111.222.0.*
111.222.*
111.*
*
When an access control list is assigned to a host computer, a domain, or an IP subnet with a port range, it take precedence over the access control list assigned to the same host, domain, or IP subnet without a port range.
For example, for TCP connections to any port between port 80 and 99 at server.us.mycompany.com
, Oracle Database first selects the access control list assigned to port 80 through 99 at server.us.mycompany.com
, ahead of the other access control list assigned to server.us.mycompany.com
that is without a port range.
Database administrators can use the DBA_NETWORK_ACL_PRIVILEGES
data dictionary view to query network privileges that have been granted to or denied from database users and roles in the access control lists, and whether those privileges take effect during certain times only. Using the information provided by the view, you may need to combine the data to determine if a user is granted the privilege at the current time, the roles the user has, the order of the access control entries, and so on. To simplify this privilege evaluation, you can use the following DBMS_NETWORK_ACL_ADMIN
functions to check the privilege granted to a user in an access control list:
CHECK_PRIVILEGE
: Checks if the specified privilege is granted to or denied from the specified user in an access control list. This procedure identifies the access control list by its path in the XML DB Repository. Use CHECK_PRIVILEGE
if you want to evaluate a single access control list with a known path.
CHECK_PRIVILEGE_ACLID
: Similar to the CHECK_PRIVILEGE
procedure, except that it enables you to specify the object ID of the access control list. Use CHECK_PRIVILEGE_ACLID
if you need to evaluate multiple access control lists, when you query the DBA_NETWORK_ACLS
data dictionary view. For better performance, call CHECK_PRIVILEGE_ACLID
on multiple access control lists rather than using CHECK_PRIVILEGE
on each one individually.
Users without database administrator privileges do not have the privilege to access the access control lists or to invoke those DBMS_NETWORK_ACL_ADMIN
functions. However, they can query the USER_NETWORK_ACL_PRIVILEGES
data dictionary view to check their privileges instead.
Both database administrators and users can use the following DBMS_NETWORK_ACL_UTILITY
functions to generate the list of domains or IP subnet a host belongs to and to sort the access control lists by their order of precedence according to their host assignments:
DOMAINS
: Returns a list of the domains or IP subnets whose access control lists may affect permissions to a specified network host, subdomain, or IP subnet
DOMAIN_LEVEL
: Returns the domain level of a given host
The following sections explain how database administrators and users can check permissions for the user to connect to a network host or to perform domain name resolutions:
How a DBA Can Check User Network Connection and Domain Privileges
How Users Can Check Their Network Connection and Domain Privileges
A database administrator can query the DBA_NETWORK_ACLS
view to determine which access control lists are present for a specified host computer. This view shows the access control lists that determine the access to the network connection or domain, and then determines if each access control list grants (GRANTED
), denies (DENIED
), or does not apply (NULL
) to the access privilege of the user. Only the database administrator can query this view.
This section provides examples that demonstrate how the database administrator can check user privileges for network connections and domain name resolution.
Database Administrator Checking User Connection Privileges
Example 4-20 shows how a database administrator can check the privileges for user preston
to connect to www.us.mycompany.com
. Remember that the user name you enter for the user
parameter in the CHECK_PRIVILEGE_ACLID
procedure is case sensitive. In this example, entering the user name preston
is correct, but entering Preston
or preston
is incorrect.
You can find the users in the current database instance by querying the DBA_USERS
data dictionary view, for example:
SELECT USERNAME FROM DBA_USERS;
Example 4-20 Administrator Checking User Permissions for Network Host Connections
SELECT HOST, LOWER_PORT, UPPER_PORT, ACL, DECODE( DBMS_NETWORK_ACL_ADMIN.CHECK_PRIVILEGE_ACLID(aclid, 'PRESTON', 'connect'), 1, 'GRANTED', 0, 'DENIED', null) PRIVILEGE FROM DBA_NETWORK_ACLS WHERE host IN (SELECT * FROM TABLE(DBMS_NETWORK_ACL_UTILITY.DOMAINS('www.us.mycompany.com'))) ORDER BY DBMS_NETWORK_ACL_UTILITY.DOMAIN_LEVEL(host) DESC, LOWER_PORT, UPPER_PORT; HOST LOWER_PORT UPPER_PORT ACL PRIVILEGE -------------------- ---------- ---------- -------------------- --------- www.us.mycompany.com 80 80 /sys/acls/www.xml GRANTED www.us.mycompany.com 3000 3999 /sys/acls/www.xml GRANTED www.us.mycompany.com /sys/acls/www.xml GRANTED *.mycompany.com /sys/acls/all.xml * /sys/acls/all.xml
In this example, user preston
was granted privileges for all the network host connections found for www.us.mycompany.com
. However, suppose preston
had been granted access to a host connection on port 80, but then denied access to the host connections on ports 3000–3999. In this case, you need to create one access control list for the host connection on port 80, and a separate access control list for the host connection on ports 3000–3999.
Database Administrator Checking User Privileges for Domain Name Resolution
Example 4-21 shows how a database administrator can check the privileges of user preston
to perform domain name resolution for the host www.us.mycompany.com
. In this example, only the access control lists assigned to hosts without a port range because the resolve
privilege has no effect to those with a port range. (Remember that the user name you enter for the user
parameter in CHECK_PRIVILEGE_ACLID
is case sensitive.)
Example 4-21 Administrator Checking Permissions for Domain Name Resolution
SELECT HOST, ACL, DECODE( DBMS_NETWORK_ACL_ADMIN.CHECK_PRIVILEGE_ACLID(aclid, 'PRESTON', 'resolve'), 1, 'GRANTED', 0, 'DENIED', null) privilege FROM DBA_NETWORK_ACLS WHERE host IN (SELECT * FROM TABLE(DBMS_NETWORK_ACL_UTILITY.DOMAINS('www.us.mycompany.com'))) AND LOWER_PORT IS NULL AND UPPER_PORT IS NULL ORDER BY DBMS_NETWORK_ACL_UTILITY.DOMAIN_LEVEL(host) DESC; HOST ACL PRIVILEGE -------------------- -------------------- --------- www.us.mycompany.com /sys/acls/www.xml GRANTED *.mycompany.com /sys/acls/all.xml * /sys/acls/all.xml
Users can query the USER_NETWORK_ACL_PRIVILEGES
view to check their network and domain permissions. The USER_NETWORK_ACL_PRIVILEGES
view is PUBLIC
, so all users can select from it.
This view hides the access control lists from the user. It evaluates the permission status for the user (GRANTED
or DENIED
) and filters out the NULL
case because the user does not need to know when the access control lists do not apply to him or her. In other words, Oracle Database only shows the user on the network hosts that explicitly grant or deny access to him or her. Therefore, the output does not display the *.mycompany.com
and *
that appear in the output from the database administrator-specific DBA_NETWORK_ACLS
view.
These sections provide examples that demonstrate how a database administrator can check user permissions for network connections and domain name resolution.
User Checking His or Her Network Connection Privileges
Example 4-20 shows how user preston
can check her privileges to connect to www.us.mycompany.com
.
Example 4-22 User Checking Permissions for Network Host Connections
SELECT HOST, LOWER_PORT, UPPER_PORT, STATUS PRIVILEGE FROM USER_NETWORK_ACL_PRIVILEGES WHERE host IN (SELECT * FROM TABLE(DBMS_NETWORK_ACL_UTILITY.DOMAINS('www.us.mycompany.com'))) AND PRIVILEGE = 'connect' ORDER BY DBMS_NETWORK_ACL_UTILITY.DOMAIN_LEVEL(host) DESC, LOWER_PORT; HOST LOWER_PORT UPPER_PORT ACL PRIVILEGE -------------------- ---------- ---------- -------------------- --------- www.us.mycompany.com 80 80 /sys/acls/www.xml GRANTED www.us.mycompany.com 3000 3999 /sys/acls/www.xml GRANTED www.us.mycompany.com /sys/acls/www.xml GRANTED
User Checking Own Privileges for Domain Name Resolution
Example 4-21 shows how the user preston
can check her privileges to perform domain name resolution for www.us.mycompany.com
:
Example 4-23 User Checking Privileges for Domain Name Resolution
SELECT host, status privilege FROM user_network_acl_privileges WHERE host IN (SELECT * FROM TABLE(DBMS_NETWORK_ACL_UTILITY.DOMAINS('www.us.mycompany.com'))) AND privilege = 'resolve' ORDER BY DBMS_NETWORK_ACL_UTILITY.DOMAIN_LEVEL(host) DESC; HOST PRIVILEGE -------------------- --------- www.us.mycompany.com GRANTED
By default, Oracle Database grants or denies privileges to users and roles based on their physical position in the access control list. The first user or role listed is granted or denied privileges first, followed the second user or role, and so on. For instance, suppose the code in Example 4-17 defined one role, ACCT_MGR
, and two users, sebastian
and preston
, and the access control list XML file ordered these three as follows:
<acl ...> ... <ace> <principal>ACCT_MGR</principal> <grant>true</grant> <privilege><plsql:connect/></privilege> </ace> <ace> <principal>SEBASTIAN</principal> <grant>false</grant> <privilege><plsql:connect/></privilege> </ace> <ace> <principal>PRESTON</principal> <grant>false</grant> <privilege><plsql:connect/></privilege> </ace> </acl>
ACCT_MGR
is granted permissions first, followed by permission denials for sebastian
and then preston
. However, if sebastian
and preston
have been granted the ACCT_MGR
role, they still could log in, because the ACCT_MGR
role appears first in the list.
Even though these two users were granted the acct_mgr
role, their specific jobs do not require them to have access to the www.mycompany.com
host. If the positions were reversed—the acct_mgr
role listed after sebastian
and preston
—they would be denied the privilege of connecting to the network. To set the order of precedence of the ACE
elements irrespective of their physical location in the CREATE_ACL
and ADD_PRIVILEGE
statements, you can use the position
attribute.
For example, the following statements set the ACE
elements in the resultant XML file in this order:
The ACE
element for sebastian
appears first.
The ACE
element for preston
appears second.
The acct_mgr
role appears last.
In this case, neither of these users will be able to connect, because their grant privileges, which are set to FALSE
, are evaluated before the acct_mgr
role.
BEGIN DBMS_NETWORK_ACL_ADMIN.CREATE_ACL ( acl => 'us-mycompany-com-permissions.xml', description => 'Network connection permission for ACCT_MGR and users'); principal => 'ACCT_MGR', is_grant => TRUE, privilege => 'connect'); DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE ( acl => 'us-mycompany-com-permissions.xml' principal => 'SEBASTIAN', is_grant => FALSE, privilege => 'connect', position => 1); DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE ( acl => 'us-mycompany-com-permissions.xml' principal => 'PRESTON', is_grant => FALSE, privilege => 'connect', position => 2); END;
Table 4-6 lists data dictionary views that you can use to find information about existing access control lists. See Oracle Database Reference for more information about these views.
Table 4-6 Data Dictionary Views That Display Information about Access Control Lists
View | Description |
---|---|
Shows the access control list assignments to the network hosts. The |
|
Shows the network privileges defined in all access control lists that are currently assigned to network hosts. The |
|
Shows the status of the network privileges for the current user to access network hosts. The |
Table 4-7 lists data dictionary views that you can query to access information about grants of privileges and roles. See Oracle Database Reference for detailed information about these views.
Table 4-7 Views That Display Grant Information about Privileges and Roles
View | Description |
---|---|
|
Describes all column object grants for which the current user or |
|
Lists column object grants for which the current user is object owner or grantor. |
|
Describes column object grants for which the current user or |
|
Lists the grants on objects where the user or |
|
Lists the all object grants made by the current user or made on the objects owned by the current user. |
|
Lists object grants for which the user or |
|
Describes all column object grants in the database |
|
Lists all grants on all objects in the database |
|
This view lists all roles that exist in the database |
|
Lists roles granted to users and roles |
|
Lists system privileges granted to users and roles |
|
This view describes roles granted to other roles. Information is provided only about roles to which the user has access. |
|
This view contains information about system privileges granted to roles. Information is provided only about roles to which the user has access. |
|
This view contains information about object privileges granted to roles. Information is provided only about roles to which the user has access. |
|
Describes column object grants for which the current user is the object owner, grantor, or grantee |
|
Describes column object grants for which the current user is the grantor |
|
Describes column object grants for which the current user is the grantee |
|
Lists roles granted to the current user |
|
Lists grants on all objects where the current user is the grantee |
|
Lists system privileges granted to the current user |
|
Lists grants on all objects owned by the current user |
|
Lists object grants for which the current user is the grantee |
|
Lists the privileges that are currently enabled for the user |
|
Lists the roles that are currently enabled to the user |
This section provides some examples of using these views. For these examples, assume the following statements were issued:
CREATE ROLE security_admin IDENTIFIED BY honcho2all; GRANT CREATE PROFILE, ALTER PROFILE, DROP PROFILE, CREATE ROLE, DROP ANY ROLE, GRANT ANY ROLE, AUDIT ANY, AUDIT SYSTEM, CREATE USER, BECOME USER, ALTER USER, DROP USER TO security_admin WITH ADMIN OPTION; GRANT SELECT, DELETE ON SYS.AUD$ TO security_admin; GRANT security_admin, CREATE SESSION TO swilliams; GRANT security_admin TO system_administrator; GRANT CREATE SESSION TO jward; GRANT SELECT, DELETE ON emp TO jward; GRANT INSERT (ename, job) ON emp TO swilliams, jward;
See Also:
Oracle Database Reference for a detailed description of these data dictionary viewsThe following query returns all system privilege grants made to roles and users:
SELECT * FROM DBA_SYS_PRIVS; GRANTEE PRIVILEGE ADM -------------- --------------------------------- --- SECURITY_ADMIN ALTER PROFILE YES SECURITY_ADMIN ALTER USER YES SECURITY_ADMIN AUDIT ANY YES SECURITY_ADMIN AUDIT SYSTEM YES SECURITY_ADMIN BECOME USER YES SECURITY_ADMIN CREATE PROFILE YES SECURITY_ADMIN CREATE ROLE YES SECURITY_ADMIN CREATE USER YES SECURITY_ADMIN DROP ANY ROLE YES SECURITY_ADMIN DROP PROFILE YES SECURITY_ADMIN DROP USER YES SECURITY_ADMIN GRANT ANY ROLE YES SWILLIAMS CREATE SESSION NO JWARD CREATE SESSION NO
See Oracle Database Reference for detailed information about the DBA_SYS_PRIVS
view.
The following query returns all the roles granted to users and other roles:
SELECT * FROM DBA_ROLE_PRIVS; GRANTEE GRANTED_ROLE ADM ------------------ ------------------------------------ --- SWILLIAMS SECURITY_ADMIN NO
See Oracle Database Reference for detailed information about the DBA_ROLE_PRIVS
view.
The following query returns all object privileges (not including column-specific privileges) granted to the specified user:
SELECT TABLE_NAME, PRIVILEGE, GRANTABLE FROM DBA_TAB_PRIVS WHERE GRANTEE = 'jward'; TABLE_NAME PRIVILEGE GRANTABLE ----------- ------------ ---------- EMP SELECT NO EMP DELETE NO
To list all the column-specific privileges that have been granted, use the following query:
SELECT GRANTEE, TABLE_NAME, COLUMN_NAME, PRIVILEGE FROM DBA_COL_PRIVS; GRANTEE TABLE_NAME COLUMN_NAME PRIVILEGE ----------- ------------ ------------- -------------- SWILLIAMS EMP ENAME INSERT SWILLIAMS EMP JOB INSERT JWARD EMP NAME INSERT JWARD EMP JOB INSERT
See Oracle Database Reference for detailed information about the DBA_TAB_PRIVS
view.
The following query lists all roles currently enabled for the issuer:
SELECT * FROM SESSION_ROLES;
If user swilliams
has the security_admin
role enabled and issues the previous query, then Oracle Database returns the following information:
ROLE ------------------------------ SECURITY_ADMIN
The following query lists all system privileges currently available in the security domain of the issuer, both from explicit privilege grants and from enabled roles:
SELECT * FROM SESSION_PRIVS;
If user swilliams
has the security_admin
role enabled and issues the previous query, then Oracle Database returns the following results:
PRIVILEGE ---------------------------------------- AUDIT SYSTEM CREATE SESSION CREATE USER BECOME USER ALTER USER DROP USER CREATE ROLE DROP ANY ROLE GRANT ANY ROLE AUDIT ANY CREATE PROFILE ALTER PROFILE DROP PROFILE
If the security_admin
role is disabled for user swilliams
, then the first query would return no rows, while the second query would only return a row for the CREATE SESSION
privilege grant.
See Oracle Database Reference for detailed information about the SESSION_ROLES
view.
You can use the DBA_ROLES
data dictionary view to list all roles of a database and the authentication used for each role. For example, the following query lists all the roles in the database:
SELECT * FROM DBA_ROLES; ROLE PASSWORD ---------------- -------- CONNECT NO RESOURCE NO DBA NO SECURITY_ADMIN YES
See Oracle Database Reference for detailed information about the DBA_ROLES
view.
The ROLE_ROLE_PRIVS
, ROLE_SYS_PRIVS
, and ROLE_TAB_PRIVS
data dictionary views contain information about the privilege domains of roles. For example, the following query lists all the roles granted to the system_admin
role:
SELECT GRANTED_ROLE, ADMIN_OPTION FROM ROLE_ROLE_PRIVS WHERE ROLE = 'SYSTEM_ADMIN'; GRANTED_ROLE ADM ---------------- ---- SECURITY_ADMIN NO
The following query lists all the system privileges granted to the security_admin
role:
SELECT * FROM ROLE_SYS_PRIVS WHERE ROLE = 'SECURITY_ADMIN'; ROLE PRIVILEGE ADM ----------------------- ----------------------------- --- SECURITY_ADMIN ALTER PROFILE YES SECURITY_ADMIN ALTER USER YES SECURITY_ADMIN AUDIT ANY YES SECURITY_ADMIN AUDIT SYSTEM YES SECURITY_ADMIN BECOME USER YES SECURITY_ADMIN CREATE PROFILE YES SECURITY_ADMIN CREATE ROLE YES SECURITY_ADMIN CREATE USER YES SECURITY_ADMIN DROP ANY ROLE YES SECURITY_ADMIN DROP PROFILE YES SECURITY_ADMIN DROP USER YES SECURITY_ADMIN GRANT ANY ROLE YES
The following query lists all the object privileges granted to the security_admin
role:
SELECT TABLE_NAME, PRIVILEGE FROM ROLE_TAB_PRIVS WHERE ROLE = 'SECURITY_ADMIN'; TABLE_NAME PRIVILEGE --------------------------- ---------------- AUD$ DELETE AUD$ SELECT
See Oracle Database Reference for detailed information about the ROLE_ROLE_PRIVS
, ROLE_SYS_PRIVS
, and ROLE_TAB_PRIVS
views.