System Administration Guide: Security Services

ProcedureHow to Audit All Commands by Users

As part of site security policy, some sites require audit records of all commands that are run by the root user or by administrative roles. Some sites also require audit records of all commands that are run by users.

  1. Audit the lo and ex classes.

    The ex class audits all calls to the exec() and execve() functions. The lo class audits logins, logouts, and screen locks. The following ouput lists all the events in the ex and lo classes.


    7:AUE_EXEC:exec(2):ps,ex
    23:AUE_EXECVE:execve(2):ps,ex
    ...
    6152:AUE_login:login - local:lo
    6153:AUE_logout:logout:lo
    6154:AUE_telnet:login - telnet:lo
    6155:AUE_rlogin:login - rlogin:lo
    6158:AUE_rshd:rsh access:lo
    6159:AUE_su:su:lo
    6162:AUE_rexecd:rexecd:lo
    6163:AUE_passwd:passwd:lo
    6164:AUE_rexd:rexd:lo
    6165:AUE_ftpd:ftp access:lo
    6171:AUE_ftpd_logout:ftp logout:lo
    6172:AUE_ssh:login - ssh:lo
    6173:AUE_role_login:role login:lo
    6212:AUE_newgrp_login:newgrp login:lo
    6213:AUE_admin_authenticate:admin login:lo
    6221:AUE_screenlock:screenlock - lock:lo
    6222:AUE_screenunlock:screenlock - unlock:lo
    6227:AUE_zlogin:login - zlogin:lo
    • To audit these classes for administrators, modify the audit_user file.

      In the following example, the site has created three roles, sysadm, auditadm, and netadm. These roles and the root account are audited for the exec and lo classes:


      ## audit_user file
      root:lo,ex:no
      sysadm:lo,ex:no
      auditadm:lo,ex:no
      netadm:lo,ex:no
    • To audit the lo class for non-attributable events, modify the audit_control file.


      ## audit_control file
      ...
      naflags:lo
      ...
    • To audit these classes for all users, modify the audit_control file.


      ## audit_control file
      flags:lo,ex
      naflags:lo
      ...

      The output appears similar to the following:


      header,375,2,execve(2),,mach1,2009-08-06 11:19:57.388 -07:00
      path,/usr/bin/ls
      subject,jdoe,root,root,root,root,1401,737,0 0 mach1
      return,success,0
  2. To record the arguments to commands, set the argv policy.


    # auditconfig -setpolicy +argv
    

    The exec_args token records the command arguments:


    header,375,2,execve(2),,mach1,2009-08-06 11:19:57.388 -07:00
    path,/usr/bin/ls
    exec_args,1,ls
    subject,jdoe,root,root,root,root,1401,737,0 0 mach1
    return,success,0
  3. To record the environment in which the command is run, set the arge policy.


    # auditconfig -setpolicy +arge
    

    The exec_env token records the command environment:


    header,375,2,execve(2),,mach1,2009-08-06 11:19:57.388 -07:00
    path,/usr/bin/ls
    exec_env,9,HOME=/,HZ=,LANG=C,LOGNAME=root,MAIL=/var/mail/root,
      PATH=/usr/sbin:/usr/bin,SHELL=/sbin/sh,TERM=xterm,TZ=US/Pacific
    subject,jdoe,root,root,root,root,1401,737,0 0 mach1
    return,success,0
  4. To record the arguments and the command environment, set both policies.


    # auditconfig -setpolicy +argv
    

    The output appears similar to the following:


    header,375,2,execve(2),,mach1,2009-08-06 11:19:57.388 -07:00
    path,/usr/bin/ls
    exec_args,1,ls
    exec_env,9,HOME=/,HZ=,LANG=C,LOGNAME=root,MAIL=/var/mail/root,
      PATH=/usr/sbin:/usr/bin,SHELL=/sbin/sh,TERM=xterm,TZ=US/Pacific
    subject,jdoe,root,root,root,root,1401,737,0 0 mach1
    return,success,0