Internal Production: Last Updated 2007-11-19

Overview of permchk and process-setuid


Purpose (top, intro, usage, examples)

Describe monitoring and management of suid and sguid binaries. General security guidelines require identifying all suid and sgid binaries on a system and ensuring the integrity of those files is correct. Typically platform IAOs will review any vendor supplied sguid binary for need and reduce permissions if appropriate. These programs are intended to run on "system" filesystems which may be mounted to allow suid|sgid execution, user filesystems (home, wrkdir, archive) are typically mounted 'nosuid' and due to their potential size should be monitored via other tools walking inodes for mulitple functions (such as world writable). Note, files with ACLs are also reported since ACLs can conceal access not shown via mode.

Document Index / Related Documentation


Introduction (top, intro, usage, examples)

The following scripts and files under /usr/local/adm [pkg/permchk] are used:

File                    Function
----                    --------
bin/permchk             platform independent driver/reporting script
bin/permchk_os          platform configuration script
bin/process-setuid      platform independent validation script
bin/process-setuid_os   platform configuration script
etc/sguid.list          registered suid|sgid binaries

The process-setuid script runs on a node and can:

While process-setuid is intended to detect new sguid binaries and validate registered ones, the sguid.list file can also contain other files where mode, ownership, and checksum must be monitored.

The permchk script is a driver script launching 'process-setuid compare new' on a collection of managed systems using push, dsh, or pdsh and emailing a report of anomalies. Typically permchk entries are added to crontab/sysmon on either admin1 or the platform management server (csmberg, csmflyer, mn1sm, ...).


Usage Summary (top, intro, usage, examples)

The sguid.list file has the following format:

  #OS  ARCH OldMode OldOwn OldGrp NewMode NewOwn NewGrp  Size Sum-r FILENAME [#Comment]
  #--  ---- ------- ------ ------ ------- ------ ------  ---- ----- --------
  sys  web7 .       .      .      4755    root   sys    13728 20626 /usr/bin/atq
  5.8  Sun  .       .      .      4755    root   sys    13728 32898 /usr/bin/atq
  5.10 Sun  .       .      .      4755    root   sys    19108 31463 /usr/bin/atq
  msk  h.*  .       .      .      4755    root   root   14123 17208 /bin/atq
Where columns are:
  1. OS: either operating system version or "sys" for a host specific entry
  2. ARCH: either platform architecture or a hostname if OS is "sys"
  3. OldMode: octal mode of file as shipped or "." if unchanged by ARSC
  4. OldOwn: username of file as shipped or "." if unchanged by ARSC
  5. OldGrp: group of file as shipped or "." if unchanged by ARSC
  6. NewMode: ARSC registered octal mode of file
  7. NewOwn: ARSC registered username of file
  8. NewGrp: ARSC registered group of files
  9. Size: size in bytes of file, or:
  10. Sum-r: the "sum -r" (uals -yr) of the file or "+", "-", or "."
  11. FILENAME: full path of the binary or file
  12. #Comment: optional comment
Note:

The process-setuid script maintains information about suid and sgid files:

admin1: process-setuid --help

Usage: process-setuid_os [-options] command setting

command:
  compare    # compares current with old or new settings
  update     # records  current as old or new settings (to stdout)
  convert    # converts file from size only to size and checksum
  swap       # swaps current settings with old or new (requires sudo)

setting:
  new        # site-defined settings
  old        # original (vendor-defined) settings

Options:
  -l list    # specify sguid.list,    current: /usr/local/adm/etc/sguid.list
  -v         # verbose ('set -x')
  -h         # this information
Note:

The permchk reports sguid anomalies on a collection of systems:

admin1: permchk --help

Usage: permchk_os [-options] platform

Options:
  -a address # email address,      current: 
  -p select  # push|dsh selection, current: 
  -d date    # results re-report,  current: 
  -b bindir  # binary directory,   current: /usr/local/adm/bin
  -l list    # sguid.list file,    current: /usr/local/adm/etc/sguid.list
  -r         # sort by node not errror
  -s         # squash whitespace in report
  -v         # verbose ('set -x')
  -h         # this information

The platform may be:
  sun, ibm, iceberg, iceflyer, midnight, nelchina,
  lnxwkst, lnxmisc, or linux
Note:


Examples (top, intro, usage, examples)

admin1: process-setuid compare new
# Find:  / /usr /var /export/home /export/software /tmp
current  mode:     0755       is not new     4511   for: /usr/bin/lpstat
info: Skipping variable size missing file: /etc/init.d/web
info: Using 'admin1' not '5.10 Sun' for: /opt/SUNWsamfs/bin/archive
info: Using 'admin1' not '5.10 Sun' for: /usr/bin/showrev
info: Skipping variable size missing file: /export/software/adm/pkg/ftptools/CheckFTP
Warn: Missing file: /var/local/CF/linux/usr/sbin/sendmail.sendmail/sendmail.sendmail.template
New file:   4511  root   root    27728  31031 /var/local/CF/linux/usr/bin/passwd/passwd.balboa
New file:   4511  root   root    27728  12646 /var/local/CF/linux/usr/bin/passwd/passwd.cortez
New file:   4511  root   lp      27504  57968 /usr/bin/lpstat.bak
Message types:
admin1: grep STDERR process-setuid | sed -e 's/^[ {  ]*printf(STDERR[  ]*//'
"Warn: Skipping duplicate entry found for: $FILENAME\n");
"Warn: Skipping '%s' after os entry '%s': $FILENAME\n",
"info: Using '%s' not '%s %s' for: $FILENAME\n",
"Warn: Missing file: $FILENAME\n");
"info: Skipping variable size missing file: $FILENAME\n");
"current sum-r: %8s %5s is not $SETTING %8s %5s: $FILENAME\n",
"current  size: %8s %5s is not $SETTING %8s %5s: $FILENAME\n",
"current  mode: %8s       is not $SETTING %8s   for: $FILENAME\n",   $CURRENT_MODE, $OLD_MODE);
"current owner: %-8s       is not $SETTING %-8s   for: $FILENAME\n", $CURRENTOWNER, $OLDOWNER);
"current group: %-8s       is not $SETTING %-8s   for: $FILENAME\n", $CURRENTGROUP, $OLDGROUP);
"current  mode: %8s       is not $SETTING %8s   for: $FILENAME\n",   $CURRENT_MODE, $NEW_MODE);
"current owner: %-8s       is not $SETTING %-8s   for: $FILENAME\n", $CURRENTOWNER, $NEWOWNER);
"current group: %-8s       is not $SETTING %-8s   for: $FILENAME\n", $CURRENTGROUP, $NEWGROUP);
"Warn: Missing file: $SGUIDFILENAME\n");
"New file:     %-5s %-8s %-8s %8d %6d %s\n",
"info: non-executable: %-5s %-8s %-8s %8d %6d %s\n",