Chapter 2
Chapter 2
SYSTEM PRIVILEGES
CHAPTER CONTRIBUTOR: Dr. K. Ruth Ramya
CREATE TYPE enables you to create object types in your own schema
CREATE ANY TYPE enables you to create object types in any schema
ALTER ANY TYPE enables you to alter object types in any schema
DROP ANY TYPE enables you to drop named types in any schema
EXECUTE ANY TYPE enables you to use and reference named types in any schema
UNDER ANY TYPE enables you to create subtypes under any non-final object types
UNDER ANY VIEW enables you to create subviews under any object view
EXECUTE lets you invoke the methods of a type, including the constructor.
Method execution and the associated permissions are the same as for stored PL/SQL
procedures.
UNDER enables you to create a subtype or subview under the type or view on which
the privilege is granted.
Only a grantor with the UNDER privilege WITH GRANT OPTION on the direct supertype
or superview can grant the UNDER privilege on a subtype or subview.
The phrase WITH HIERARCHY OPTION grants a specified object privilege on all subtypes of the
object. This option is meaningful only with the SELECT object privilege granted on an object
view in an object view hierarchy. In this case, the privilege applies to all subviews of the
view on which the privilege is granted.
The SECURITY ADMINISTRATOR role in Oracle is a powerful role that grants the user a wide
range of privileges, including the ability to:
In addition to these general privileges, the SECURITY ADMINISTRATOR role also grants the user
several specific privileges, such as:
It is important to note that the SECURITY ADMINISTRATOR role is a very powerful role, and
should only be granted to users who need it to perform their job duties.
1. Most of these system privileges that we grant to secadm_role allow us to do some of what we
have already done as SYS.
2. We will allow our security administrator to create and edit users, create roles and assign them
to users.
3.secadm will grant privileges to roles to work with Oracle objects (structures) in other diagrams.
It will grant certain system privileges to the roles.
4. It will also create procedures and triggers, which are like procedures, but which run when
certain events occur. And the security administrator will create profiles,
5. For now, we are relying on the default profile.
6. We will also set up audits as security administrators.
7.We will be auditing a variety of system events, and we will be auditing access to tables and
other structures in the HR schema - hence the AUDIT ANY privilege.
8. Anytime you see EVERYTHING in an object privilege grant, you can read it as “in any
schema”.
9. Usually, a user already has these privileges in their own schema.
10. These are not all the system and schema object privileges that our security administrator will
need to do his job, but they will get us started.
11. We will come back as SYS and give the security administrator a bit more privileges later.
The audit role in Oracle is a set of privileges that allow users to perform auditing tasks. This
includes creating and managing audit policies, viewing audit data, and managing the audit trail
administration.
AUDIT_ADMIN: This role enables users to create unified and fine-grained audit policies,
use the AUDIT and NOAUDIT SQL statements, view audit data, and manage the audit trail
administration. Grant this role only to trusted users.
AUDIT_VIEWER: This role enables users to view and analyze audit data. It provides the
EXECUTE privilege on the DBMS_AUDIT_UTIL PL/SQL package. The kind of user who
needs this role is typically an external auditor.
Auditing is an important security measure that can help you to monitor database activity, detect
unauthorized access, and troubleshoot problems. By auditing database operations, you can gain
valuable insights into how your database is being used and identify any potential security threats.
•Finally, as SYS, we are going to set up some initial auditing on the auditing trail itself.
•This will deter a rogue database administrator from doing something wrong and then erasing
their tracks by deleting their audit records:
AUDIT SELECT, UPDATE, DELETE ON sys.aud$ BY ACCESS;
•When we designate BY ACCESS for auditing, we are saying that we want detailed information.
•The other (possibly default) option is BY SESSION. This gives less detail, but still audits each
occurrence, rather than only providing a single audit record per session, as in earlier releases of
Oracle.
To acquire the SECADM_ROLE from a SQL*Plus local connection, you can use the following
steps:
Connect to the database as a user with the SYSDBA privilege. For example:
SQL> CONNECT SYS AS SYSDBA;
ROLE
SECADM
Once you have acquired the SECADM_ROLE, you can perform any administrative tasks that are
allowed by the role. For example, you can create and manage users, roles, and database objects.
Note: The SECADM_ROLE is a very powerful role, so it is important to only acquire it when you
need to perform administrative tasks. Once you have finished performing the administrative tasks,
you should revoke the role.
Here is an example of how to acquire the SECADM_ROLE from a SQL*Plus local connection:
ROLE
SECADM
Once you have acquired the SECADM_ROLE, you can perform any administrative tasks that are
allowed by the role. For example, you can create a new user:
Once you have finished performing the administrative tasks, you should revoke the
SECADM_ROLE:
SQL> ALTER SESSION SET ROLE = NONE;
Session role changed.
You should also drop the new user if you no longer need it:
SQL> DROP USER new_user;
User dropped.
• There are always gotcha's, and here's one that will probably get you a few times if you use
SQL*Plus as your primary client: you can connect locally to the default instance while you are
sitting at a command prompt on the Oracle database.
• Do that by executing SQL*Plus without any arguments, like this:
Sqlplus
• You can connect then as secadm user by entering the username and the password.
• If you then attempt to execute the procedure, sys.p_check_secadm_access that sets secadm_role, it
will not succeed.
• Why does it not succeed? Our address should be that of localhost, which should be okay.
• Well, when connecting locally, SQL*Plus doesn’t use the network at all—it just talks directly to
the database.
• You can see the lack of IP address information by executing this command:
SELECT SYS_CONTEXT( 'USERENV', 'IP_ADDRESS' ) FROM DUAL;
• This has some implications for security.
• The commands you enter do not cross the network adapter when linked locally like this and have
no chance of leaking out to snooping devices on the network.
• So how, you might ask, are we supposed to connect as secadm and run sys.p_check_secadm_access
from SQL*Plus on the Oracle Database? There is a way, and it only requires that you act like you’re
not connecting locally by adding the arguments for user and instance name (orcl in this example) on
the command line. Actually orcl in this context is a TNS alias with the same name as the instance.
sqlplus secadm@orcl
• At that point, you have an IP address in the session context, and you can successfully set role
through the procedure:
SELECT SYS_CONTEXT( 'USERENV', 'IP_ADDRESS' ) FROM DUAL;
EXEC sys.p_check_secadm_access
Replace <username> with the name of the application user you want to create, and replace
<password> with the password you want to assign to the user.
You can also grant the application user other privileges, such as the privilege to create tables, views,
and procedures.
•We are going to begin securing access to the data in the Human Resources (HR) Sample Schema.
•We will create a role named hrview_role. Through that role we will grant access to the data needed
by a variety of applications that we plan to build.
•At the outset, we only want folks who are on our internal network to access this data, and only
during our normal office hours of 7 AM to 7 PM.
•We are going to begin securing access to the data in the Human Resources (HR) Sample Schema.
•We will create a role named hrview_role. Through that role we will grant access to the data needed
by a variety of applications that we plan to build.
•At the outset, we only want folks who are on our internal network to access this data, and only
during our normal office hours of 7 AM to 7 PM.
•To accomplish these constraints, we will create the role and require that it be verified by a
procedure. •Oracle calls this a secure application role because that is its function – it is a role that
gives access to application data, but it is secured by some encoded constraints.
• Just as we did previously for the secadm_role, we will create a procedure to protect access
to the hrview_role.
• At the end of the procedure, if the CURRENT_USER meets the requirements encoded in
this procedure, we will SET ROLE to the hrview_role.
• Here, we are creating a procedure in another schema. Notice the schema name, appsec.
pretended on the procedure name.
•To do this requires secadm to have the CREATE ANY PROCEDURE system privilege.
2. A Web site that allows users to enter text, such as a comment or a name, and then stores it
and later display it to other users, is potentially vulnerable to a kind of attack called a
___________________ attack.
a) Two-factor authentication
b) Cross-site request forgery
c) Cross-site scripting
d) Cross-site scoring scripting
3. _________ is an attack which forces an end user to execute unwanted actions on a web
application in which he/she is currently authenticated.
a) Two-factor authentication
b) Cross-site request forgery
c) Cross-site scripting
d) Cross-site scoring scripting
4. Many applications use _________________ where two independent factors are used to
identify a user.
a) Two-factor authentication
b) Cross-site request forgery
c) Cross-site scripting
d) Cross-site scoring scripting
6. A single ______________ further allows the user to be authenticated once, and multiple
applications can then verify the user’s identity through an authentication service without
requiring reauthentication.
a) OpenID
b) Sign-on system
c) Security Assertion Markup Language (SAML)
d) Virtual Private Database (VPD)
8. The __________ standard is an alternative for single sign-on across organizations, and has
seen increasing acceptance in recent years.
a) OpenID
b) Single-site system
c) Security Assertion Markup Language (SAML)
d) Virtual Private Database (VPD)
10. VPD provides authorization at the level of specific tuples, or rows, of a relation, and is
therefore said to be a _____________ mechanism.
a) Row-level authorization
b) Column-level authentication
c) Row-type authentication
d) Authorization security
TERMINAL QUESTIONS
1. What are the system privileges? Explain how these are granted to Administrator role?
2. What are some common system privileges? How can I grant or revoke system privileges?
3. What are some security best practices for system privileges?
4. What permissions does the application security role have to the application directory?
5. How do I remove the application security user from the dev role?
6. What are the required fields for creating an HR view role?
7. What are the best practices for creating HR view roles?
8. How do I restrict access to specific HR data within an HR view role?
9. How do I audit who has accessed which HR views?