Precautions for revoking DBA roles
Oracle has very fine-grained permissions. To facilitate the management of numerous permissions, Oracle introduces the role logic concept and also sets many roles in the system. In actual applications, application users may have complicated permissions. Therefore, to facilitate authorization, many application users are granted the DBA role, and the DBA role has more system permissions, this is very unfavorable for database management and violates the security principle of minimizing permissions. For the sake of security, the system may need to revoke the DBA role. In the process of revoking permissions, pay attention to some details to ensure the normal operation of applications, several important points will be discussed below.
Lab environment description (the conclusions in this article apply to 10 Gb ~ 11.2.0.4 ):
- SQL> select * from v $ version;
- BANNER
- --------------------------------------------------------------------------------
- Oracle Database 11g Enterprise Edition Release 11.2.0.3.0-64bit Production
- PL/SQL Release 11.2.0.3.0-Production
- CORE 11.2.0.3.0 Production
- TNS for Linux: Version 11.2.0.3.0-Production
- NLSRTL Version 11.2.0.3.0-Production
1. Validity Period of the grant/revoke role operation
- -- Create a new user and grant the connect role
- Session 1:
- SQL> create user darren identified by darren;
- User created.
- SQL> grant connect to darren;
- Grant succeeded.
- -- Use a new user to log on to the database
- Session 2:
- SQL> conn darren/darren
- Connected.
- SQL> select * from session_privs;
- PRIVILEGE
- ----------------------------------------
- CREATE SESSION
- SQL> select * from session_roles;
- ROLE
- ------------------------------
- CONNECT
Keep session 2 from exiting and assign the resource role to session 1.
- Session 1:
- SQL> grant resource to darren;
- Grant succeeded.
- -- Query the user's system permissions and roles in session 2
- SQL> select * from session_privs;
- PRIVILEGE
- ----------------------------------------
- CREATE SESSION
- Unlimited tablespace -- Added System Permissions
- SQL> select * from session_roles;
- ROLE
- ------------------------------
- CONNECT
Log out of the session and log on to the user again.
- SQL> conn darren/darren
- Connected.
- SQL> select * from session_privs;
- PRIVILEGE
- ----------------------------------------
- CREATE SESSION
- UNLIMITED TABLESPACE
- CREATE TABLE
- CREATE CLUSTER
- CREATE SEQUENCE
- CREATE PROCEDURE
- CREATE TRIGGER
- CREATE TYPE
- CREATE OPERATOR
- CREATE INDEXTYPE
- 10 rows selected.
- SQL> select * from session_roles;
- ROLE
- ------------------------------
- CONNECT
- RESOURCE
Conclusion: 1. the unlimited tablespace system permission will be granted to the user along with the resource role, because it is a separate system permission, it will take effect immediately; 2. The grant/revoke role will not take effect immediately, it takes effect only when you use set role or log on again (directly grant system and object permissions to take effect immediately ).
2. revoke the impact of DBA roles. Continue the experiment above. Grant and revoke the user DBA role in session 1, and session 2 log on to the user again.
- Session 1:
- SQL> grant dba to darren;
- Grant succeeded.
- SQL> revoke dba from darren;
- Revoke succeeded.
- Session 2:
- SQL> conn darren/darren
- Connected.
- SQL> select count (*) from session_privs;
- COUNT (*)
- ----------
- 9
- SQL> select * from session_roles;
- ROLE
- ------------------------------
- CONNECT
- RESOURCE
- SQL> select * from session_privs; -- note that the UNLIMITED TABLESPACE permission is not available here.
- PRIVILEGE
- ----------------------------------------
- CREATE SESSION
- CREATE TABLE
- CREATE CLUSTER
- CREATE SEQUENCE
- CREATE PROCEDURE
- CREATE TRIGGER
- CREATE TYPE
- CREATE OPERATOR
- CREATE INDEXTYPE
Create a table in session 2 and insert data
- SQL> create table test1 (a varchar2 (20), B varchar2 (10); -- the creation is successful because of the latency of 11g, the segment is not actually generated in the tablespace.
- Table created.
- SQL> insert into test1 values ('A', 'B ');
- Insert into test1 values ('A', 'B ')
- *
- ERROR at line 1:
- ORA-01950: no privileges on tablespace 'users'
Conclusion: 1. When the DBA role is reclaimed, the unlimited tablespace permission is revoked. 2. After the unlimited tablespace permission is revoked, the user's tablespace quota is immediately exhausted, meaning that the TABLESPACE storage space cannot be used.
3. Process DBA permission Revocation
1. Since the unlimited tablespace system permission of the user is revoked after the DBA permission is revoked, You can authorize the user in one of the following ways so that the user can use the TABLESPACE normally:
- SQL> grant RESOURCE to DARREN;
- SQL> alter user DARREN quota unlimited on USERS;
- SQL> grant UNLIMITED TABLESPACE to DARREN;
2. If the application user has special permissions, you must revoke the DBA role and grant the user some system and object permissions separately.
This article permanently updates the link address: