Security
This chapter covers the following DB212 security topics:
10.1 Installation or migration without requiring SYSADM
Up to DB2 11, only users with installation SYSADM authority can install new a DB2 subsystem or data sharing group or migrate DB2 to the new release. However, a system operator (with installation SYSOPR authority) usually is the person performing the installation or migration steps, which means he or she is granted SYSADM authority. SYSADM authority also includes access to all data. Certain government regulations and policies require that sensitive user data not be exposed to anyone, except the system administrator or data owner. Therefore, to help protect user data and comply with security regulations, DB2 12 provides a way to install or migrate a DB2 subsystem without having SYSADM authority.
With DB2 12 compatibility mode, a user with installation SYSOPR authority has the capability to install and migrate a subsystem with no access to user data. Enhancements are made so that SYSOPR authority can perform work necessary in the process such as these examples:
Execute the CATMAINT utility to install or migrate to a new release.
Issue the ACTIVATE FUNCTION LEVEL command.
Access to all catalog tables and all tables in the system databases.
Set current SQLID to SYSINSTL, regardless of SEPARATE SECURITY DSNZPARM setting.
Use BINDAGENT privilege to specify any owner. The BINDAGENT privilege also gives the ability to free any package, and bind or free a plan.
When executing the migration or installation jobs, system objects in the DB2 catalog might need to be created by the user with installation SYSOPR authority, but these objects will be owned by SYSINSTL. For this to work, the current SQLID must be set to 'SYSINSTL'. The runner with installation SYSOPR now has the authority to use CREATE, ALTER, and DROP on the following objects:
Database
Table space
Table, auxiliary table, created global temporary table
Index
Stogroup
Trigger
Procedure, function including those in schema SYSTOOLS and SYSFUN
 
Note: If procedure and function have an associated package, then the OWNER keyword must be specified. If the stored procedures are created with the SECURITY DEFINER clause, SYSINSTL must be defined in Resource Access Control Facility (IBM RACF®).
Additionally, SYSINSTL with installation SYSOPR authority now have the ability to CREATE, ALTER, and DROP several objects without any additional privileges such as alias, distinct type, sequence, global variable. SYSINSTL can also grant privileges on the following system objects and resources:
All database, table space, and table privileges on objects in the DSNDB04 database, and DSNRGFDB, DSNRLST, DSNOPTDB, DSNMDCDB, DSNADMDB, DSNATPDB, DSN5JSDB, DSNMQDB, SYSIBMTA, SYSIBMTS, and DSNXSR system databases
The USE privilege on buffer pool and storage group
All privileges on plans that begin with 'DSN'
All privileges on packages where the collection-ID and package-name begin with 'DSN'
The execute privilege on system-defined routines
On the installation panel DSNTIPG shown in Figure 10-1, the ROUTINES CREATOR, SEC DEF CREATOR, and INSTALL SQL ID fields must be set to SYSINSTL. The INSTALL PKG OWNER field on this panel also must be set to an authorization ID (PKOWNER in this example) that has been granted system DBADM and DATAACCESS authorities. This is necessary because the BIND and REBIND commands issued during the installation and migration processes require an owner that has authorization to bind and execute all the SQL statements in the package.
Figure 10-1 DSNTIPG panel with Install SQL ID set to SYSINSTL
10.2 UNLOAD privilege
Up to DB2 11, the SELECT privilege is the lowest required privilege to execute the UNLOAD utility. Even with the SELECT privilege, if the table has column masks or row permission defined, a user might not be able to retrieve certain rows and columns by using an application that issues the SELECT SQL statement. However, such a user with the SELECT privilege has the ability to read all data in the table using the UNLOAD utility. Furthermore, the SQL SELECT statement, static or dynamic, can be governed by the DB2 resource limit facility (RLF) to control how many rows an application with those SQL statements can retrieve. RLF limits, row permissions, and column masks do not apply to utilities. Executing an UNLOAD utility with only the SELECT privilege can be considered a security vulnerability because a user can unload and have access to large amounts of data beyond the user’s intended authorization. Also, when running the UNLOAD utility, a user with the SELECT privilege can leave a restricted state on the object in case the utility experiences an abend condition and is not terminated.
DB2 12 closes this security exposure by introducing the UNLOAD privilege, which is required when executing the UNLOAD utility. This DB12 UNLOAD privilege provides separation between the SQL SELECT and utility execution, thus the security administrator will have better control to grant the appropriate authorization to intended usage.
10.2.1 Enforcing new privilege
The UNLOAD privilege can be established for users starting in DB2 12 compatibility mode (or function level V12R1M100). However, this privilege is mandated for the UNLOAD utility only after new function mode is activated (function level V12R1M500 or greater).
The SELECT privilege can still be used for the UNLOAD utility access in DB2 12 after new function is activated, if AUTH_COMPATIBILITY DSNZPARM is set to the SELECT_FOR_UNLOAD option. The default value for this DSNZPARM is NULL. Prior to activating function level V12R1M500 or greater, the new serviceability trace record IFCID 404 may be enabled to collect the authorization IDs that use the SELECT privilege to execute an UNLOAD utility. This trace record is also retrofitted to DB2 11 so the auditing work can be done before migration to DB2 12 also. The preference is to activate IFCID 404 prior to migrating to DB2 12 with the PTF for APAR PI55706. Actions must be taken for those authorization IDs so the UNLOAD utility will work as intended in the DB2 12 new function mode.
10.2.2 Using DB2 security facility
The following SQL statement syntax diagrams show how to grant (Figure 10-2) the UNLOAD privilege to a user ID and revoke (Figure 10-3 on page 171) the privilege.
Figure 10-2 The GRANT statement syntax with UNLOAD privilege
Figure 10-3 The REVOKE statement syntax with UNLOAD option
A new column UNLOADAUTH is added to the SYSIBM.SYSTABAUTH catalog table to record the successful result of the GRANT statement and the authorization ID having the UNLOAD privilege in the GRANTEE column (Example 10-1; the result is shown in Table 10-1).
Example 10-1 Granting the UNLOAD privilege to USRT001 and the SELECT privilege to USRT002
GRANT UNLOAD ON TABLE T1 TO USRT001;
GRANT SELECT ON TABLE T1 TO USRT002;
SELECT GRANTEE, TTNAME, SELECTAUTH, UNLOADAUTH FROM SYSIBM.SYSTABAUTH WHERE (GRANTEE = 'USRT001' OR GRANTEE = 'USRT002') AND TTNAME = 'T1';
Table 10-1 Result of query
GRANTEE
TTNAME
SELECTAUTH
UNLOADAUTH
USRT001
T1
Y
 
USRT002
T1
 
Y
10.2.3 Using Resource Access Control Facility (RACF)
If RACF is used for security management, then a new profile must be added for the UNLOAD privilege in the RACF class. Example 10-2 shows a couple of RACF profiles defined for the UNLOAD privilege (given to user USER001) and SELECT privilege (given to both users USERT001 and USER002).
Example 10-2 Permitting UNLOAD and SELECT privileges to USER001 and only the SELECT privilege to USER002
RDEFINE MDSNTB DB2A.EMPLOYEE.TABLE01.UNLOAD UACC(NONE) -OWNER(DB2OWNER)
PERMIT DB2A.EMPLOYEE.TABLE01.UNLOAD ID(USER001) ACCESS(READ) - CLASS(MDSNTB)
RDEFINE MDSNTB DB2A.EMPLOYEE.TABLE01.SELECT UACC(NONE) -OWNER(DB2OWNER)
PERMIT DB2A.EMPLOYEE.TABLE01.SELECT ID(USER001 USER002) -ACCESS(READ) CLASS(MDSNTB)
SETR RACLIST(MDSNTB) REFRESH
If a RACF access control module is written, the module should be updated to handle the new ULOADAUTT constant value (297 or x'129') in the XAPLPRIV field of the RACF parameter list. The RACF access control exit should have logic to handle whether the user or the role associated with the user owns the table:
If yes, then XAPLUPRM must match the owner name passed from DB2 by the XAPLOWNR parameter when XAPLONRT indicates an authorization ID, or XAPLUCHK must match XAPLOWNR and XAPLUCKT must match XAPLONRT.
If no, then the user must have sufficient authority to one of the resources listed in the corresponding class shown in Table 10-2.
Table 10-2 Resources and classes
One of these resources:
In this class:
DB2-subsystem.table-qualifier.table-name.UNLOAD
MDSNTB or GDSNTB
DB2-subsystem.database-name.DBADM
DSNADM
DB2-subsystem.SQLADM
This check is bypassed for user tables
MDSNSM or GDSNSM
DB2-subsystem.SYSDBADM
This check is bypassed for user tables
DSNADM
DB2-subsystem.DATAACCESS
DSNADM
DB2-subsystem.ACCESSCTRL
This check is bypassed for user tables
DSNADM
DB2-subsystem.SYSCTRL
This check is bypassed for user tables
DSNADM
DB2-subsystem.SYSADM
DSNADM
DB2-subsystem.SECADM
This check is bypassed for user tables
DSNADM
10.3 Object ownership transfer
Another popular security item addressed in DB2 12 is the ability to change an object’s ownership online. Ownership of a database object can be determined by several rules such as whether the DDL statement that defines the object is a static or dynamic SQL, executed under a trusted context with ROLE AS OBJECT OWNER or not, the privilege set for the DDL statement, and so on. The ownership belongs to either an authorization ID or a role. To comply with government and company regulations, the ownership of sensitive data must be transferable from one authorization ID or role to another authorization ID or role. In DB2 11, such a task can be accomplished only with DROP and CREATE DDL statements followed by reloading data in the object as needed. These activities are disruptive in a production system where access to the object is constantly acquired.
To provide the support for changing ownership while keeping the object available, DB2 12 introduces the TRANSFER OWNERSHIP SQL statement with the appropriate authorization. This SQL statement can be either static or dynamic. The TRANSFER OWNERSHIP statement is allowed when the application compatibility is V12R1M500 or greater. The package containing the TRANSFER OWNERSHIP statement can be bound to that application compatibility level after activating new function.
Figure 10-4 shows the syntax diagram for the TRANSFER OWNERSHIP statement.
Figure 10-4 The TRANSFER OWNERSHIP statement syntax diagram
 
Note: Although the syntax diagram does not specify ALIAS, an alias for TABLE and VIEW can be specified on the TRANSFER OWNERSHIP statement and its based table or the view ownership will be transferred.
The CREATOR and CREATORTYPE columns in the following tables are updated with the new owner when the transfer is successful for the objects:
SYSIBM.SYSDATABASE If ownership of a database is transferred (ownership of the DSNDB01, DSNDB04, and DSNDB06 databases are not allowed to be transferred)
SYSIBM.SYSSTOGROUP If ownership of a storage group is transferred
SYSIBM.SYSTABLESPACE If ownership of a table space is transferred
The OWNER and OWNERTYPE columns in the following tables are updated with the new owner when the transfer is successful for the objects:
SYSIBM.SYSTABLES If ownership of a table is transferred
SYSIBM.SYSINDEXES If ownership of an index is transferred
SYSIBM.SYSVIEWS If ownership of a view is transferred
The example in Figure 10-5 on page 174 shows a table that is created and owned by an authorization ID and later, its ownership is transferred to another authorization ID by the SECADM authority.
Figure 10-5 SECADM transfers table's SZI10T's ownership from ADMF002 to ADMF003
 
Note: The SYSTABLES.CREATEDBY column remains as is with the old owner while the OWNER column is updated with the new owner. The catalog table SYSTABAUTH is also updated with the appropriate table authorization’s grantor and grantee.
10.3.1 Supported objects
The privilege set of the application executing the TRANSFER OWNERSHIP statement must be the owner of the object or SECADM authority. Even with the SEPARATE_SECURITY DSNZPARM set to NO, installed SYSADM and SYSADM authority is not sufficient to perform the ownership transfer. By using this SQL statement, ownership of the following objects can be transferred:
Database
Tablespace
Table
Index
View
Stogroup
Those objects must not be the system objects (owned by schemas that begin with SYS) and must exist at the current server where the statement is executing. Therefore, three-part name table or view, or alias created with the three-part name should have the location name resolved to the local server. When ownership of a database is transferred, the ownerships of other objects created in the same database such as tablespaces, tables, and views are not transferred. When ownership of a table is transferred, the ownership of the following dependent objects is also transferred:
Index (if same owner)
Implicitly created table space for this base table
Implicitly and explicitly (same owner) created LOB objects (aux table, aux index, LOB table space)
XML objects (table, index, table space)
10.3.2 New owner
The new owner can be an authorization ID, a role or the SESSION user (the primary authorization ID executing the application). The new owner's name and type are recorded in either the CREATOR/CREATORTYPE or OWNER/OWNERTYPE columns in the appropriate DB2 catalog table where the object's definition is kept. The new owner is automatically granted the same privileges that the old owner obtained when the object was created. The new owner must have the set of privileges on the base objects, as indicated by the objects dependencies, that are required to maintain the objects existence, unchanged.
For example, TAMMIED is the owner of table T1 and TAMMIED ID also has DBADM authority. After executing the TRANSFER OWNERSHIP OF T1 TO ACACIO statement, ACACIO ID will also have DBADM authority.
The example in Figure 10-6 shows that TAMMIED creates a view with the CREATE VIEW V1 AS SELECT MYUDF(C1) FROM T1 statement. This view is updatable so TAMMIED ID, as the owner, has SELECT, INSERT, UPDATE, DELETE privileges on the T1 based table. TAMMIED should also have EXECUTE privilege on the MYUDF user-defined function. When owner TAMMIED or SECADM executes the TRANSFER OWNERSHIP OF T1 TO MBERNAL statement, DB2 requires that MBERNAL also has SELECT, INSERT, UPDATE, and DELETE privileges on the T1 based table, and EXECUTE privilege on the MYUDF user-defined function.
Figure 10-6 View’s ownership transfer failure
10.3.3 Revoking privileges of current owner
In DB2 12, the REVOKE PRIVILEGES option on the TRANSFER OWNERSHIP statement must be specified to indicate that the current owner will not have any implicit privilege on the object after the transfer is completed (Example 10-3). The following objects are invalidated:
Dynamic cached statements that are dependent on the current owner’s privilege on the object
Stabilized dynamic statements that are dependent on the current owner’s privilege on the object
Example 10-3 Transfer ownership of table EMPLOYEE.BENEFIT to role BENEFIT_ADMINROLE and revoke current owner's privileges on this table
TRANSFER OWNERSHIP OF TABLE EMPLOYEE.BENEFIT TO ROLE BENEFIT_ADMINROLE REVOKE PRIVILEGES;
If any package exists that is dependent on the current owner's privilege on the object, the TRANSFER statement fails. This failure can be avoided by explicitly granting those privileges from another source (such as SECADM) or if the current owner has an administrative authority that allows access (such as DBADM on the database).
The query shown in Figure 10-7 can be used to identify those packages and the privileges associated with a table and schema.
Figure 10-7 Query to find packages dependent on current owner's privilege on the table
For tables created prior to DB2 9, the query shown in Figure 10-8 can be used.
Figure 10-8 Query to find packages dependent on current owner's privilege on table (before DB2 9)
The grant actions performed by the current owner are not changed when the transfer completes. Those privileges can be revoked separately after by using REVOKE statement with the BY clause.
 
Note: The clone table and the base table are considered unrelated objects with regard to access control. Therefore, transferring ownership of the clone table does not affect ownership of the base table and vice versa. Ownership of each table should be transferred separately as needed.
Also, that functionality does not apply to plan, packages, and security objects created in DB2. Ownership of an application plan and package can be transferred by using the REBIND subcommand with the existing OWNER option. The security objects, such as trusted contexts, roles, row permissions, column masks and their ownerships can be transferred with the DROP and CREATE DDL statements.
 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset