Chapter3_Elements
Chapter3_Elements
CSEC3360
Chapter 3: Foundational Elements for a
Secure Database
Textbook: David C. Knox, William Maroulis, and Scott Gaetjen:Oracle Database 12c
Security.Thanks to Engineer Saif
Chapter Objectives
16/04/2025
Dr. Ruba Awadallah
3
16/04/2025
4
Dr. Ruba Awadallah
16/04/2025
5
Dr. Ruba Awadallah
➢ System Privileges:
1. ANY System Privileges: not limited to a specific schema, but rather to any object of a
specific type regardlessof schema.
16/04/2025
6
Dr. Ruba Awadallah
➢ A quick description of the categorization of commands within the Oracle Database follows:
❑ Data Manipulation Language (DML): Write actions such as INSERT, UPDATE, or DELETE against
a table or view for example, or EXECUTE actions on PL/SQL code.
16/04/2025
7
Dr. Ruba Awadallah
16/04/2025
8
Dr. Ruba Awadallah
➢ You can determinewhichaccounts or roles have been granted which system privileges by querying the
GRANTEE
view DBA_SYS_PRIVS or CDB_SYS_PRIVSfor all databases.
DATAPUMP_IMP_FULL_DATABASE
➢ Example: DBA
DV_REALM_OWNER
SELECT grantee EXP_FULL_DATABASE
IMP_FULL_DATABASE
FROM dba_sys_privs LBACSYS
MDSYS
WHERE privilege = 'SELECT OLAP_DBA
ANY TABLE' SYS
SYSTEM
ORDER B Y grantee; WMSYS
16/04/2025
9
Dr. Ruba Awadallah
❖ You can determinewhohas SELECT ANY TABLE across all pluggable databasesby issuing the following
query:
SELECT grantee, pdb_name
FROM cdb_sys_privs csp JOIN
cdb_pdbs cp
ON (csp.con_id = cp.con_id)
WHERE privilege = 'SELECT
ANY TABLE'
ORDER B Y grantee;
❖ You can determineall privileges a connected user has by selecting from the view SESSION_PRIVS:
16/04/2025
Dr. Ruba Awadallah
➢ Roles
❑ Roles are collections of privileges and are described later in this chapter.
❑ Granting a database role to a user effectively grants the user all the privileges that were grantedto that
role.
❖ You can determineall roles a connecteduser has by selecting from SESSION_ ROLES:
SELECT * FROM
session_roles
ORDER B Y role ;
❖ What remains to be determined is for which objects the non-administrative privileges pertain.
16/04/2025
Dr. Ruba Awadallah
Object Privileges
➢ Object privileges authorize a user to perform actions (INSERT, SELECT, EXECUTE, and so on)on database
objects (table, view, PL/SQL function, and so on).
➢ Database users are authorized to performactions against objects they own.
✓ Select
✓ Insert Owns
✓ Update
Customers Table
Sales History (SH)
➢ However, if the SH user has a need to query a different schema’sobject,then the SELECT privilege for
that objectmust be granted to SHbefore theaction can be performed.
HR
Grants
X Select ✓ Select
Employees Table
Sales History (SH) HRUser or DBA Sales History (SH)
16/04/2025
Dr. Ruba Awadallah
Object Privileges
➢ As with system privileges, the object privileges can be granted in several
ways—granted directly to a user, granted to a role, and so on.
16/04/2025
Dr. Ruba Awadallah
ObjectPrivileges
16/04/2025
Dr. Ruba Awadallah
ObjectPrivileges
This query is helpful because youcan tailor it to determine which specific privilegeshave been
granted to a specific schema.
16/04/2025
15
Dr. Ruba Awadallah
ObjectPrivileges
16/04/2025
16
Dr. Ruba Awadallah
Object Privileges
16/04/2025
17
Dr. Ruba Awadallah
Column Privileges
➢ Oracle Database 12c enables you to grant privileges (INSERT, UPDATE, and so on) to the
individual columns
within a table.
➢ If a user or group of users (ROLE) need SELECT, INSERT, and UPDATE access to a column or
set of columns, you can grant access directly on the table’s columns.
16/04/2025
18
Dr. Ruba Awadallah
ColumnPrivileges
EmployeesTable
HR Schema HR PDB
IT
SALARY
SALES
MTG
➢ To accomplish the second part of our scenario, we grant UPDATEprivileges on the SALARY column of the
16/04/2025
19
Dr. Ruba Awadallah
16/04/2025
Dr. Ruba Awadallah
Roles
❑ Example:
✓ 100 tables
✓ Each has four privileges(INSERT, UPDATE, DELETE,and, SELECT)
✓ We want to grant these privileges to 100 users
✓ every user gets read access (one object privilege –SELECT) to our 100 tables
✓ we have an additional privilegedgroup of 50 users that get to manipulate the data (three object
privileges–INSERT, UPDATE, and DELETE)in the 100 tables
16/04/2025
Dr. Ruba Awadallah
Roles
❑ Example:
➢ Without using database roles:
o It requires 10,000 grants—(100 users) ×(1object privilege) ×(100 tables)—justfor read access.
o It requires15,000 grants—(50 users)×(3 privileges)×(100 tables)—grantsfor INSERT, UPDATE,
and DELETE privileges.
❖ Thiscan only work for a small number of users and a small number of objects
16/04/2025
Dr. Ruba Awadallah
Roles
16/04/2025
Dr. Ruba Awadallah
Roles
➢ All users thathave been granted the role will receive/revoke the privilegesthe next time they
connect.
16/04/2025
Roles
Dr. Ruba Awadallah
Roles
16/04/2025
Role and Privilege Immediacy
Role andPrivilege Immediacy
Dr. Ruba Awadallah
➢ The role PUBLICis created by Oracle Database 12c by default during the process of creating a
database
➢ Oracle creates or clones several default roles (DBA, RESOURCE, and so on) and grantsthe roles
➢ The PUBLICrole is a general purpose role to which every connected user can grant privileges.
➢ However, the PUBLICrole doesn’t present in the user’s session the same way other database
roles do.
16/04/2025
Dr. Ruba Awadallah
Role Hierarchies
➢ Rolescan be granted object and system privileges and they can be granted other roles.
➢ The ability to nest roles adds flexibility in capturing real-world security policies.
➢ Unfortunately, this flexibility can also lead to complexity and confusion when you’re trying to
unravel which privileges are granted to what or whom.
❖ Recommendation:
➢ Limiting the number of nested roles will help simplify the complexity of your privilegestructures
16/04/2025
Dr. Ruba Awadallah
➢ An advantage to using roles versus direct grantsis that roles can be selectively enabled or
➢ In the following example,privileges to control access to SH’s SREGIONShave been granted to the
HR:
16/04/2025
Dr. Ruba Awadallah
➢ To implement dynamic privilege enablement, we would then create a program similar to the
following:
16/04/2025
Selective Privilege Enablement
Dr. Ruba Awadallah
➢ BAD DESIGN!
16/04/2025
Dr. Ruba Awadallah
✓ Alternative Design: assigning rolesto a user and not enabling them by default
✓ APP_USER Role
Sales PDB
✓ APP_USER Role
Sales PDB
Application
16/04/2025
Dr. Ruba Awadallah
16/04/2025
Selective Privilege Enablement
Dr. Ruba Awadallah
➢ If the user logs in and tries to query the application’s tables, thequery will fail, because the
privilegesto do so are not available until the role is enabled.
16/04/2025
Dr. Ruba Awadallah
16/04/2025
Dr. Ruba Awadallah
➢ Thissolution does not appear to be more secure than the procedural based method.
➢ The only difference is the SET ROLE implementation enables the privileges only for the current
OE database session, whereas the SET_PRIVS procedure enables privileges for all OE
database sessions.
➢ In the preceding examples, knowing or not knowing the existence of a procedure or role that
has to be executedor enabled providesno security.
16/04/2025