Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Data architect: Securing DB2 data

Grant privileges to a what, not a who

Robert Catterall (rfcatter@us.ibm.com), IBM DB2 Specialist, IBM
Robert Catterall is a client technical advisor for the DB2 for z/OS platform at IBM.

Summary:  Role-based security gives you a way to protect your organization's information assets and has been available since the release of DB2 V9.5 for Linux®, UNIX®, and Windows®(LUW), and DB2 9 for z/OS®. However, many users are still confused about when to use this feature. In his column, Robert Catterall clarifies the purpose and advantages of roles and trusted contexts. This content is part of the IBM Data Management Magazine.

View more content in this series

Date:  03 May 2011
Level:  Intermediate
Also available in:   Chinese

Activity:  2361 views
Comments:  

- Read this article in our interactive digital edition format!
- Subscribe to IBM Data Management magazine

These days, executives are more concerned than ever about unauthorized access to data entrusted to their organizations. Their fears are justified: a recent survey showed that about a third of those polled would quit doing business with a company they perceived to be guilty of a data security breach. This is why there is such high demand for DB2 experts who can tighten up data access controls.

Role-based security is a great way to protect your organization's information assets, and it's probably easier to implement than you think. DB2 roles—and their close relatives, trusted contexts—have been available since the release of DB2 9.5 for Linux, UNIX, and Windows (LUW) and DB2 9 for z/OS. But although these DB2 releases became generally available more than three years ago, many users still seem confused regarding the purpose and advantages of roles and trusted contexts. I’ll try to clear things up in this article.

A better way to manage DB2 privileges

First, the introduction of roles and trusted contexts did not introduce any new DB2 privileges. Rather, this security capability provided a new way to assign and manage privileges. They can now be granted to roles instead of being assigned directly to users’ authorization IDs. You can also limit the scope of granted privileges by restricting their use to trusted connections that conform to defined trusted contexts.

Managing DB2 security this way can be particularly useful when dealing with a common client/server computing scenario: An application running on a Java or a .NET (or some other) application server issues SQL statements that are executed on a DB2 database server (in a DB2 for z/OS environment, the SQL statements would likely flow through the Distributed Data Facility, or DDF). Individual users authenticate themselves at the application server, but the application itself presents to DB2 a generic authorization ID and password that are hard-coded in a program.

If the SQL statements are dynamically prepared at the DB2 server—as is often the case for programs that use database interfaces such as JDBC or ODBC or ADO.NET—the application's generic authorization ID must be granted table privileges (SELECT, INSERT, UPDATE, DELETE) on target objects to enable successful statement execution.

But lots of programmers could know the application's DB2 authorization ID and password—because, as mentioned, these are embedded in program code. Someone could then use that ID and its privileges to access data in the database from outside the application, seriously weakening security.


A useful analogy

To use an analogy from the real world, my eldest daughter is less than a year away from getting her driver's license. If only I could manage her driving with something like DB2 roles and trusted contexts, perhaps I could better control her access to our cars. I could set something up so that she could exercise the privilege of driving only between home and school, and only in the minivan (not the sport sedan). An impossible dream for me, of course, and probably a nightmare from my daughter's perspective.


Using roles and trusted contexts

But you can do something very similar in DB2 if you use DB2 9 for z/OS in new function mode, or DB2 10 for z/OS. Administrators of DB2 9.5 for LUW, 9.7, and later versions have the same capability: instead of granting to a generic authorization ID a set of privileges required to execute an application's dynamic SQL statements, you could grant the privileges to a role.

Now, merely granting privileges to a role accomplishes next to nothing. Why? Because DB2 has no way of knowing either who can use the role's privileges, or the circumstances under which the role can be used at all.

That's where defining a trusted context comes in. The trusted context limits the exercise of a role's privileges to users connecting to DB2 from a particular application server—identified by an IP address—through an application that provides to DB2 a particular authorization ID, referred to as a “system” authorization ID.

Because the privileges needed to execute the dynamic SQL statements issued by the application are assigned to a role and not to an ID, the application's generic authorization ID is useless (in terms of providing someone with a means of accessing DB2 data) unless it has the privileges of the aforementioned role. And it can have those privileges only when it is used to connect to DB2 from the application server whose IP address is an attribute of the trusted context that specifies the conditions under which the role can be used. This way, security is much tighter than it would be if the application's generic ID had privileges that could be exercised regardless of the “come from” connection type.


But wait, there's more!

You have a few choices here:

  • If you use the IBM WebSphere Application Server, you can propagate an end user's identity to DB2 by setting the database property propagateClientIdentityUsingTrustedContext to 'true'.
  • There are application programming interfaces (APIs) for JDBC (such as getDB2Connection), CLI (the SQL_ATTR_TRUSTED_CONTEXT_USERID attribute and the SQLSetConnectAddr functions), and .NET (where the connection string keyword UserID corresponds to the end user) that can be used by an application to establish a trusted connection to DB2, reuse a trusted connection with a different end-user ID, and propagate that end-user ID to the DB2 server.
  • If the requester is a DB2 for z/OS system, you can provide the “system” authorization ID for a trusted connection in the requester’s communications database (specifically, in the SYSIBM.USERNAMES table). End users’ IDs will be propagated to the DB2 server as the trusted connection is reused.

Not only does this functionality let you restrict a role's privileges to designated users of a particular trusted connection, it also lets you get DB2 (and Resource Access Control Facility, or RACF) audit information that contains end users’ individual IDs. This works even when those users are connecting to DB2 through an application that itself provides a single generic authorization ID when establishing connections to DB2.

If you do send end-user IDs to DB2 from an application server, you can get even more granular with respect to the roles associated with a given trusted context. For example, a trusted context could have a default role, ROLE_A. Assuming that the application for which the trusted context is defined propagates end-user identities to DB2, you could indicate that another role, ROLE_B, is usable by end user SMITH for a trusted connection by specifying WITH USE FOR SMITH ROLE ROLE_B on the CREATE TRUSTED CONTEXT statement. If you require authentication information—a password, for example—for SMITH to use ROLE_B, you'd add WITH AUTHENTICATION to the preceding WITH USE FOR clause.

Note that when you omit the WITH USE FOR clause of CREATE TRUSTED CONTEXT, it is as though you specified WITH USE FOR PUBLIC WITHOUT AUTHENTICATION. This means that the privileges of the default role associated with the trusted context are available to any individual who uses a trusted connection as defined by the trusted context.

You can even specify in a trusted context definition that a requester must communicate with DB2 using the Secure Sockets Layer (SSL) cryptographic protocol. Just make ENCRYPTION 'HIGH' one of the attributes of the trusted context. (ENCRYPTION 'LOW' corresponds to 64-bit DRDA encryption.)

Now, here are a couple of important things to remember about trusted contexts:

  • For a mainframe DB2 server, a trusted context can also be defined for a local connection to DB2 through a batch job or a started task.
  • A trusted context can be set up to make the context’s default role the owner of any object created using the role’s privileges.

The catch

When a user establishes a trusted connection with a DB2 subsystem—in accordance with a defined trusted context—he or she has the privileges of the associated role plus any privileges granted directly to his or her ID. The point here: roles and trusted contexts limit the exercise of DB2 privileges only if those privileges are not widely granted to users’ DB2 authorization IDs. The assumption is that you'll begin to REVOKE privileges previously granted to individual user IDs (and/or to RACF—or equivalent—group IDs) as you phase in the use of roles and trusted contexts.

Setting up role-based security is easier than most people think. And as long as organizations seek better control over their information, there will be a demand for the increasingly fine control over data assets that DB2 provides. It's the wave of the future, folks. Catch it now, and you'll be ahead of the game.

Partner Resources
Applied Analytix, Inc DBIFourth Millennium Technologies
IBMIBM Client Reference ProgramIBM Information On Demand
International DB2 Users Group (IDUG)Informix ConferenceMelissa Data
NetezzaNiteo PartnersQuest Software
Relational Architects InternationalSafari Books Online

Resources

About the author

Robert Catterall is a client technical advisor for the DB2 for z/OS platform at IBM.

Report abuse help

Report abuse

Thank you. This entry has been flagged for moderator attention.


Report abuse help

Report abuse

Report abuse submission failed. Please try again later.


developerWorks: Sign in


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

Choose your display name

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


Rate this article

Comments

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Information Management
ArticleID=648335
ArticleTitle=Data architect: Securing DB2 data
publish-date=05032011
author1-email=rfcatter@us.ibm.com
author1-email-cc=

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

For articles in technology zones (such as Java technology, Linux, Open source, XML), Popular tags shows the top tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), Popular tags shows the top tags for just that product zone.

For articles in technology zones (such as Java technology, Linux, Open source, XML), My tags shows your tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), My tags shows your tags for just that product zone.

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Try IBM PureSystems. No charge.

Special offers