Object Security by Adoption

IBM i (OS/400, i5/OS)
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

No discussion of OS/400 security could be complete without mentioning adopted authority. This article does much more than mention it; this article describes adopted authority and lists some of its advantages and some dangers inherent to its use.

Of all the tricks available in OS/400 security, adopted authority is high among the trickiest. It is not surprising, then, that some security administrators have trouble dealing with it. In this article, you’ll learn the basics of adopted authority and become aware of not only its advantages, but also its pitfalls.

Every OS/400 object has an owner. Initially, the owner of an object is the user who creates it; later, ownership of an object can be transferred to another user by using the Change Object Owner (CHGOBJOWN) command. Initially, the owner of an object has *ALL authority to the object; this means that the owner can use the object, change it in any way he wants, and even delete the object from the system.

When the object is a program (*PGM), service program (*SRVPGM), or SQL package (*SQLPKG), object ownership takes an additional meaning—whether to adopt authorities or not. I’ll explain what this means by way of an example.

The General Idea

Imagine an interactive RPG program named PGM1 that uses two files: FILEA and FILEB. Any user can call PGM1 because its public authority is set to *USE, and no user can access either file because their information is confidential; the security administrator has given *EXCLUDE authority to the public. This means that if a user who has not been explicitly given access to the files calls program PGM1, the program will begin to initiate but then bomb as soon as it attempts to open the files. Why? Because the user has *EXCLUDE authority, courtesy of the public authority.

There may be valid reasons for keeping public authority set to *EXCLUDE. For example, one of the files could be the employee master file, the other a history of year-to- date deductions taken from employee paychecks. How do you solve the problem?

Here are two options:
• Give users (who have been authorized by management) whatever authority they need to run PGM1 successfully. Perhaps user A needs *CHANGE authority if she maintains the employee master file, while user B needs only *USE if all he ever does is look at the file without altering anything.

• Transfer ownership of PGM1 to a user who has enough authority to both database files and then set PGM1 so it adopts the authority of its owner.

The first option is the most secure, but (not surprisingly) it is also the most complicated. If you keep using this method, user profiles will soon have hundreds of objects to which they are explicitly authorized in one way or another. You can reduce the clutter somewhat by careful use of authorization lists or group profiles (or both), but doing that just adds one more layer of complexity that obscures the overall structure of your AS/400 security.

The second option is less secure, but it is the simplest to implement. If user C has *CHANGE authority to both FILEA and FILEB, C can become the owner of PGM1. Then, when you change PGM1 to adopt authority from its owner, any user running PGM1 will automatically be given temporary authorization to both files. As soon as PGM1 ends, the user immediately loses his authorization to the files. If you’re wondering why adopted authority is less secure, keep reading. I’ll get to that later.


Simply put, QUSEADPAUT tells the system who can create programs that adopt authority. This system value is available only on OS/400 V3R6 or higher.

QUSEADPAUT stores an authorization list name (object type *AUTL), but the AS/400 is shipped to you with this system value set to *NONE. With *NONE, any user who can create programs can create them so they adopt authority from their owners. If you supply an authorization list name in this system value, however, the only users who can create programs that adopt authority are the users who have authority to the authorization list.

It sounds complicated (and the repeated use of the words authority and authorization does nothing to make it more clear), but actually it’s rather simple. Suppose you create an authorization list named ADPAUT, give the public *EXCLUDE authority, and give users PGMR1 and PGMR2 *USE authority. Then, you change system value QUSEADP-AUT to ADPAUT. From that point on, only PGMR1 and PGMR2 can create programs that adopt authority. Of course, users who enjoy *ALLOBJ special authority can override the *EXCLUDE authority given the public; therefore, *ALLOBJ users can also create programs that adopt authorities.

Creating the Programs

For a program to adopt authorities from its owner, two things must happen first: The program must be owned by a user who has the authority you want to adopt, and the program must have been created with USRPRF(*OWNER).

All CRTxxxPGM commands—even Create Program (CRTPGM) and Create Service Program (CRTSRVPGM)—have a USRPRF parameter. By default, its value is *USER; this value means that the program uses the authorities granted to the user who is running it. The value *OWNER, on the other hand, tells the system to adopt the authorities of the owner of the program.

You may forget to set USRPRF to *OWNER. If you do, run Change Program (CHGPGM) or Change Service Program (CHGSRVPGM); both commands also have a USRPRF parameter.

Adopted authorities are automatically propagated to programs you call from a program compiled with USRPRF(*OWNER). So, if PGM1 adopts authorities and calls PGM2, PGM2 also adopts authorities, even if it was compiled with USRPRF(*USER). If this state of affairs is undesirable, you can change PGM2 (with the CHGPGM command) to USEADPAUT(*NO). This way, PGM2 will not adopt authorities.

Advantages of Adopting Authority

Besides the obvious advantages, such as greatly simplifying security administration, the technique of adopting authorities offers an excellent advantage in systems that use Client Access/400. If OS/400 didn’t offer adopted authorities, you would have to give a user the highest authority he is ever going to need to do his job well. That might mean giving him *CHANGE access to the employee master file, just because he occasionally runs a program to change emergency contact information on employee records.

Suppose this user accesses the AS/400 via Client Access. He can, then, start only the router and then start a remote command that runs a program he wrote to increase his wages a bit. With *CHANGE authority to the file, he can do it.

Adopting authorities changes all that. You can give this user *USE authority and then change the program he runs to maintain contact information, making it adopt *CHANGE authority from the owner. This technique accomplishes two things: First, it prevents unwanted access from Client Access sessions; second, it prevents unwanted access from other programs the user may write. Only when the program that adopts authority is running is the user able to change information in the employee file—and in the specific (and restricted) way in which the programmer has coded it.

Here’s another, similar advantage: If you have users who routinely use SQL, you can keep them from using anything but the SELECT statement. To do so, give these users *USE authority to the files you want to protect, and then change all programs that require higher authority so they adopt authorities from their owners.

Pitfalls, Too!

You must not think, however, that adopting authorities is a universal remedy to all your security-related troubles. In fact, if not used properly, adopting authorities may make matters worse. Here are a couple of troublesome scenarios. I hope they give you a chill.

First, imagine that program PGM1 adopts authorities and calls PGM2. Because of the way OS/400 works, PGM2 will also adopt authorities, even if compiled with USRPRF(*USER), because it has been called by a program that adopts. PGM1 adopts authorities from a user who has *ALLOBJ special authority, and the call to PGM2 is not qualified with a library name; the system uses the library list to find PGM2.

A resourceful user may create a clone of QSYS/QCMD, or build a “shell” around it, name it PGM2, and place it in a library higher than that which contains the real PGM2. When the user calls PGM1 and PGM1 eventually calls PGM2, he’ll get a Command Entry panel, if that’s what he created his “shell” to do. From this, he’ll be able to run any command and do everything the user profile with the higher authority could, thanks to the *ALLOBJ authority he’s adopting from the owner of PGM1. There you have a textbook example of a Trojan horse (for another example of a Trojan horse scenario, see “Are Your AS/400 Passwords Really Secure?” also in this issue of MC).

Or how about this? A user runs CL program CLP1, which adopts authority. CLP1 then adds library LIBA to the library list. LIBA contains file DB1, and the user is not specifically authorized to either the library or the file. No matter: Because CLP1 adopts authority, he’ll have access to DB1. Later, CLP1 ends without removing LIBA from the library list. Even though CLP1 has ended and the user is not running under adopted

authorities, the user still has authorization to file DB1. This one is really weird! It’s documented in the AS/400 Advanced Series: Security Reference manual, too.

There’s another gotcha, too. If you create PGM1 and then re-create it (say, after debugging it), the new version of the program will have the same USRPRF setting the old version had—the value of the USRPRF parameter in the compilation command is ignored. You must delete the original program object before re-creating it or use the CHGPGM command to alter the new version after compilation is complete.

Control Tools

To be sure, OS/400 gives you many tools to help you control adopted authorities. First is the Display Programs that Adopt (DSPPGM-ADP) command, which does exactly what its name implies: It creates a list of programs that adopt authorities. Or, instead of the command, you can use the QSYLOBJP API .

Second, you can use Display Program (DSPPGM) or Display Service Program (DSPSRVPGM) to check whether a specific program adopts authorities from its owner.

Third, system value QALWOBJRST controls which security-sensitive objects may be restored into your system. If the system value contains either *ALL or *ALWPGMADP, a user with enough authority may restore a program that adopts authorities. Since QALWOBJRST must be set to *ALL prior to some system-level activities (such as installing OS/400 or applying PTFs), you must remember to set QALWOBJRST back to its former value.

Finally, OS/400 has an incredibly rich auditing feature. If you set system value QAUDLVL to *PGMADP or if you set a user profile’s AUDLVL setting to *PGMADP, OS/400 will write a journal entry every time adopted authority is used to gain access to an object. You can then check the journal to determine whether your system’s security is full of holes. Look for journal entries of type AP. A subtype of S indicates that a program that adopts authority has started. A subtype of E indicates that it ended, and an A indicates that adopted authority was used during the activation of the program. The model outfile is QASYAPJE in all cases.

Use It Wisely

Properly used, adopted authority can be a tremendous addition to your security administration policies. I hope that you have learned useful concepts and that you will take care when employing the techniques presented here.


AS/400 Advanced Series: Security Reference (SC41-4302-01, CD-ROM QBJALC01)