Recreating Pre-2007 (Pre-3.1.7) SETUID Permission Bit Behavior


Contents

About This Document
SETUID Behavior

About This Document

This document contains the process for recreating SETUID and SETGID permission bits.

The information in this document applies to AIX Version 3 and 4.

 
************************************************************ 
                    SECURITY RISK 
WARNING:  Current UNIX(r) security manuals 
warn SUID/SGID shell scripts are a major security risk and 
are to be avoided.  This document reintroduces a POTENTIAL 
SECURITY RISK to your system! 
************************************************************ 

SETUID Behavior

A fix for a potential security risk dealing with the use of the SETUID and SETGID permission bits on shell scripts was included in AIX 3.1.7 (which corresponds to update level 2007). Prior to 3.1.7, when a shell script was executed whose permissions included the SETUID bit (set user-id), the shell script ran with the permissions of the shell script's owner. Similarly, if the SETGID bit (set group-id) was set, the shell script ran with the permissions of the shell script's group. Beginning with AIX 3.1.7, the SETUID and SETGID permission bits is no longer supported for shell scripts. This change does NOT affect compiled programs.

Here is an example.

If your application requires the previous SETUID behavior, you can call the shell script from a small compiled program that has the SETUID bit set in its permissions.

To have a non-root user execute a program with root permissions, use the following:

  1. Using your favorite editor, create a file and name it umksysb.c

    Put the following text in the file you just created.

     
        main () 
       { 
          setuid(0); 
          setgid(0); 
          system("/bin/mksysb -i /dev/rmt0"); 
        } 
    
  2. Compile this program by executing the following command:
     
        cc umksysb.c -o umksysb 
    
  3. Change the permissions by executing the following command:
     
        chmod 4755 umksysb 
    

ACL (access control lists) can be used to specify particular users that can access these files. This can be used with other commands as well.

Another example of a non-root user executing a program with root permissions is shown in the following steps.

  1. Using your favorite editor, open the following file:
     
        myshutdown.c 
    

    Put the following text in the file myshutdown.c:

     
        main() 
       { 
          setuid(0); 
          setgid(0); 
          system("/usr/sbin/shutdown -Fr"); 
       } 
    
  2. Compile this program by executing the following command:
     
        cc myshutdown.c -o myshutdown 
    
  3. Change the permissions by executing the following command:
     
        chmod 4755 myshutdown 
    

NOTE: Making a program suid root only assigns uid 0 to the program. Additional code may be required to acquire root's environment using the setpcred and setpenv subroutines.


Recreating Pre-2007 (Pre-3.1.7) SETUID Permission Bit Behavior: suid.script.all.cmd ITEM: FAX
Dated: 99/03/10~00:00 Category: cmd
This HTML file was generated 99/06/24~12:42:02
Comments or suggestions?
Contact us