Setuid
lastmod 2020-11-20created 2020-11-209 edits
The Unix access rights flags setuid and setgid (short for "set user ID" and "set group ID") allow users to run an executable with the file system permissions of the executable's owner or group respectively, and to change behaviour in directories. They are often used to allow users on a computer system to run programs with temporarily elevated privileges in order to perform a specific task.
SUID
The absolute notation value is 4000. It lets a regular user run a file with the owner's permissions. It must be used with care because it poses security problems.
SGID
The absolute notation value is 2000. It lets a regular user execute with the owning group's permissions. When applied to a file, it is as if another group runs the file with the owning group's permissions.
Sticky bit
When applied to a directory that all users can write to, files in the directory cannot be deleted arbitrarily; only the owner has permission to delete or modify them. In Linux, the /tmp directory is the typical example set with the stick bit.
If you type the following command,
the output is as follows.
Note the last character, t, in drwxrwxrwt.
How to set
## suid를 적용한다는 뜻이다. (u -> user)
chmod u+s 파일이름
## suid를 적용해제 시키겠다는 뜻이다. (u -> user)
chmod u-s 파일이름
## sgid를 적용하겠다는 뜻이다. (g -> group)
chmod g+s 파일이름
## sgid를 적용해제 시키겠다는 뜻이다. (g -> group)
chmod g-s 파일이름
## stick bit를 적용시키겠다는 뜻이다. (o -> other)
chmod o+t 파일이름
## stick bit를 적용해제시키겠다는 뜻이다. (o -> other)
chmod o-t 파일이름
Finding files
To find files with sgid, suid, and stickybit set, respectively, do the following.
See also
- Linux
- InformationSecurity:CheckList:Unix - Checklist of security items for Unix-like systems.