Technical article 104706

How to locate SUID (setuid) and SGID (setgid) files on your system.

OpenServer 5.0.0OpenServer 5.0.2OpenServer 5.0.4OpenServer 5.0.5OpenServer 5.0.6UnixWare 7.0.0UnixWare 7.0.1UnixWare 7.1.0UnixWare 7.1.1Open UNIX 8

Written · Last revised

Problem

How to locate SUID and SGID files.

Solution

Files with setuid and/or setguid permission settings mean that the file (actually a binary) will be executed with the ID of the owner or group, depending on which bit is set. For security reasons many system administrators need to monitor these files to make sure their system has not been compromised.

The following example uses find(C) to locate setuid files, owner ID set, and setgid files, group ID set on execution. The find is piped to xargs which outputs a full listing of the files to /tmp/suid.sgid (any output file can be named):

                find . \( -perm -4000 -o -perm -2000 \) -print | xargs l >
/tmp/suid.sgid
Ideally this is performed on a freshly installed system.  That
file can then be compared to output files created thereafter.

In order to find the same files in /etc/perms, use:

grep 4[0-9][0-9][0-9] /etc/perms/* > /tmp/perms.suid
grep 2[0-9][0-9][0-9] /etc/perms/* > /tmp/perms.sgid

NOTE: The setuid, setgid and sticky bit settings have no effect on shell scripts.

See also

chmod(C) and find(C)

From the Xinuos technical article database, record 104706. Reproduced with permission. The original is at www.sco.com/ta/104706, which is reachable but blocked from search engines. Xinuos marks this article against a retired product line. That refers to the product’s lifecycle, not to whether the advice still works — plenty of it still applies to running systems.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.