Showing posts with label IT Security. Show all posts
Showing posts with label IT Security. Show all posts

Friday, August 22, 2008

DB2 Audit Facility for Dummy

IT security auditors came and approached me, asking about DB2 user query activities, security events and blah blah. Let me see, o yeah, we got application specific audit trails. HR system got their own, ERP too and not forgetting that small little ETL program that IS people wrote. Of course, having domain specific audit facility is not a sin and they are one of the standard practice. However, DB2 provides an audit facility which is generic enough to capture almost any events happened in your databases.

Check out this DB2 program, located at <DB2_INSTALL_PATH>\bin

db2audit


Before you start to use db2audit, you should configure the AUDIT_BUF_SZ parameter in DBM configuration file. By the way, db2audit is controlled at Instance level. Setting AUDIT_BUF_SZ to non-Zero value indicates a multiple of 4KB. This is the buffer size before the audit records written to disk.

Then, you can check the current settings of db2audit, by using this command

db2audit describe


You will see something like below:



DB2 AUDIT SETTINGS:

Audit active: "FALSE "
Log errors: "TRUE "
Log success: "TRUE "
Log audit events: "TRUE "
Log checking events: "TRUE "
Log object maintenance events: "TRUE "
Log security maintenance events: "TRUE "
Log system administrator events: "TRUE "
Log validate events: "TRUE "
Log context events: "TRUE "
Return SQLCA on audit error: "TRUE "

AUD0000I Operation succeeded.




For example, if I just want to log audit events for authentication and authorization, both when success and failed, and rollback application if the system unable to generate the audit logs, perhaps due to system failure. Then I use this command:



db2audit configure scope checking,validate status both errortype audit


I will get the results below, when I submit "db2audit describe" again


DB2 AUDIT SETTINGS:

Audit active: "FALSE "
Log errors: "TRUE "
Log success: "TRUE "
Log audit events: "FALSE "
Log checking events: "TRUE "
Log object maintenance events: "FALSE "
Log security maintenance events: "FALSE "
Log system administrator events: "FALSE "
Log validate events: "TRUE "
Log context events: "FALSE "
Return SQLCA on audit error: "TRUE "

AUD0000I Operation succeeded.


You can enumerate the list of possible values for SCOPE, STATUS and ERRORTYPE by just typing "db2audit" and submit.

After configuring the audit facility, to start the facility


db2audit start


To stop the facility


db2audit stop



And, whenever you set AUDIT_BUF_SZ to non-ZERO, you should also use


db2audit flush


for writing the buffer to disk.

2 output file formats are supported by the native extraction: Flat and Delimited.

Use "db2audit extract" command to extract the logs. For example, if I need the audit records for authentication and authorization events, in comma delimiter format for database PROD, then I use the command below:


db2audit extract delasc DELIMITER , category checking, validation database


This will generates a list of files with .DEL extention in <INSTANCE_DIRECTORY>\security folder. You can load the files into database by using LOAD or IMPORT utility.

Audit file will grows over time and you need to perform house keeping on it occasionally. To remove all audit records, use


db2audit prune all


Or more likely you will want to remove records prior to certain date.


db2audit prune date YYYYMMDDHH


E.g. db2audit prune date 2007050100 will delete all records where date prior to 1-May-2007.


Lastly, additional information you might need to aware of


  • Only SYSADM group members can perform auditing actions

  • Audit Configuration File located at <INSTANCE_DIR>\security\db2audit.cfg, and it is in binary format

  • Audit Log File located at <INSTANCE_DIR>\security\db2audit.log, and it is in binary format

  • By setting DB2INSTANCE environment variable, you can configure audit for different DB2 instances

  • IBM Data Warehouse Edition DWH Password Maze

    Stringent user account security policy in the network domain can cause damaging maintenance headache in deployed IBM DWH multiservers environment. User account information are all around the places, in your DB2 services, WAS server, Alphablox and so on. The day when the user passwords expired or required account disabled, it will be the day DWE solutions face total outrage. Well, may be I'm just exaggerating.

    Where do you update the user credentials in DWE environment when such a need arise?

    Briefly speaking, at least the following locations:

    1. DB2 Windows services, assuming Windows environment

    Log On As for each DB services need to be updated.


    2. Websphere Global Security Setting, assuming using LocalOS repository

    This can be tricky. The easiest is to update the password before you shut down the WAS server. If the server already shut down and you didn't manage to update the password, then you wouldn't be able to start the server again because of authentication error. If this is the case, you got to manually disable the WAS global security by changing the "enabled" attribute of security:Security xml element to false in security.xml file located in /config/cells/Cell. Then start the server, update the password in LocalOS setting and turn on Global Security again by checking on the option in WAS Admin Console.

    3. Data Sources defined in DWE Admin Console

    Data Sources used by DWH application processes, which are not attached to WAS data source, must be updated.

    Before you can perform this, you need to update the J2C user password in WAS for Admin Console to be able to connect to its repository. (Item 6)

    4. Data Sources defined in Alphablox Admin Console

    Usually this will be data sources for Alphablox cubes to retrieve IBM Cube Views meta data.

    5. WAS account used by Alphablox for management

    Alphablox uses a WAS user credential for connecting to WAS and managing Alphablx applications in WAS. This piece of information is located in Alphablox repository, /servers/AlphabloxAnalytics/server.properties.

    Replace the line ws.admin.password.protected with ws.admin.password=<your_password_in_plaintext>

    The issue here is that the new password will be in clear text. I read across some materials that say the password is encoded again the next time the server restarted. However, I don't see that happens in my environment.

    6. WAS J2C Authentication entries

    7. WAS JNDI Data Sources, assuming not using J2C authentication

    8. Optionally, WAS Windows Services


    Hope this is helpful to you.