SetuidThe Unix and Linux access rights flags setuid and setgid (short for set user identity and set group identity)[1] 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 to perform a specific task. While the assumed user id or group id privileges provided are not always elevated, at a minimum they are specific. The flags File modesThe Typically, EffectsThe When set on an executable fileWhen the Security impactFor security purposes, the invoking user is usually prohibited by the system from altering the new process in any way, such as by using While the The presence of When set on a directorySetting the Thus is granted a capacity to work with files amongst a group of users without explicitly setting permissions, but limited by the security model expectation that existing files permissions do not implicitly change. The ExamplesChecking permissionsPermissions of a file can be checked in octal form and/or alphabetic form with the command line tool [ torvalds ~ ] $ stat -c "%a %A" ~/test/
1770 drwxrwx--T
SUID4701 on an executable file owned by 'root' and the group 'root' A user named 'thompson' attempts to execute the file. The executable permission for all users is set (the '1') so 'thompson' can execute the file. The file owner is 'root' and the SUID permission is set (the '4') - so the file is executed as 'root'. The reason an executable would be run as 'root' is so that it can modify specific files that the user would not normally be allowed to, without giving the user full root access.
A default use of this can be seen with the [ thompson ~ ] $ stat -c "%a %U:%G %n" /usr/bin/passwd
4701 root:root /usr/bin/passwd
[ thompson ~ ] $ passwd
passwd: Changing password for thompson
The owner of the process is not the user running the executable file but the owner of the executable file SGID2770 on a directory named 'music' owned by the user 'root' and the group 'engineers' A user named 'torvalds' who belongs primarily to the group 'torvalds' but secondarily to the group 'engineers' makes a directory named 'electronic' under the directory named 'music'. The group ownership of the new directory named 'electronic' inherits 'engineers.' This is the same when making a new file named 'imagine.txt' Without SGID the group ownership of the new directory/file would have been 'torvalds' as that is the primary group of user 'torvalds'. [ torvalds ~ ] $ groups torvalds
torvalds : torvalds engineers
[ torvalds ~ ] $ stat -c "%a %U:%G %n" ./music/
2770 root:engineers ./music/
[ torvalds ~ ] $ mkdir ./music/electronic
[ torvalds ~ ] $ stat -c "%U:%G %n" ./music/electronic/
torvalds:engineers ./music/electronic/
[ torvalds ~ ] $ echo 'NEW FILE' > ./music/imagine.txt
[ torvalds ~ ] $ stat -c "%U:%G %n" ./music/imagine.txt
torvalds:engineers ./music/imagine.txt
[ torvalds ~ ] $ touch ~/test
[ torvalds ~ ] $ stat -c "%U:%G %n" ~/test
torvalds:torvalds ~/test
Sticky bit1770 on a directory named 'videogames' owned by the user 'torvalds' and the group 'engineers'. A user named 'torvalds' creates a file named 'tekken' under the directory named 'videogames'. A user named 'wozniak', who is also part of the group 'engineers', attempts to delete the file named 'tekken' but he cannot, since he is not the owner. Without sticky bit, 'wozniak' could have deleted the file, because the directory named 'videogames' allows read and write by 'engineers'. A default use of this can be seen at the [ torvalds /home/shared/ ] $ groups torvalds
torvalds : torvalds engineers
[ torvalds /home/shared/ ] $ stat -c "%a %U:%G %n" ./videogames/
1770 torvalds:engineers ./videogames/
[ torvalds /home/shared/ ] $ echo 'NEW FILE' > videogames/tekken
[ torvalds /home/shared/ ] $ su - wozniak
Password:
[ wozniak ~/ ] $ groups wozniak
wozniak : wozniak engineers
[ wozniak ~/ ] $ cd /home/shared/videogames
[ wozniak /home/shared/videogames/ ] $ rm tekken
rm: cannot remove ‘tekken’: Operation not permitted
Sticky bit with SGID3171 on a directory named 'blog' owned by the group 'engineers' and the user 'root' A user named 'torvalds' who belongs primarily to the group 'torvalds' but secondarily to the group 'engineers' creates a file or directory named 'thoughts' inside the directory 'blog'. A user named 'wozniak' who also belongs to the group 'engineers' cannot delete, rename, or move the file or directory named 'thoughts', because he is not the owner and the sticky bit is set. However, if 'thoughts' is a file, then 'wozniak' can edit it. Sticky bit has the final decision. If sticky bit and SGID had not been set, the user 'wozniak' could rename, move, or delete the file named 'thoughts' because the directory named 'blog' allows read and write by group, and wozniak belongs to the group, and the default 0002 umask allows new files to be edited by group. Sticky bit and SGID could be combined with something such as a read-only umask or an append only attribute. [ torvalds /home/shared/ ] $ groups torvalds
torvalds : torvalds engineers
[ torvalds /home/shared/ ] $ stat -c "%a %U:%G %n" ./blog/
3171 root:engineers ./blog/
[ torvalds /home/shared/ ] $ echo 'NEW FILE' > ./blog/thoughts
[ torvalds /home/shared/ ] $ su - wozniak
Password:
[ wozniak ~/ ] $ cd /home/shared/blog
[ wozniak /home/shared/blog/ ] $ groups wozniak
wozniak : wozniak engineers
[ wozniak /home/shared/blog/ ] $ stat -c "%a %U:%G %n" ./thoughts
664 torvalds:engineers ./thoughts
[ wozniak /home/shared/blog/ ] $ rm thoughts
rm: cannot remove ‘thoughts’: Operation not permitted
[ wozniak /home/shared/blog/ ] $ mv thoughts /home/wozniak/
mv: cannot move ‘thoughts’ to ‘/home/wozniak/thoughts’: Operation not permitted
[ wozniak /home/shared/blog/ ] $ mv thoughts pondering
mv: cannot move ‘thoughts’ to ‘pondering’: Operation not permitted
[ wozniak /home/shared/blog/ ] $ echo 'REWRITE!' > thoughts
[ wozniak /home/shared/blog/ ] $ cat thoughts
REWRITE!
SecurityDevelopers design and implement programs that use this bit on executables carefully in order to avoid security vulnerabilities including buffer overruns and path injection. Successful buffer-overrun attacks on vulnerable applications allow the attacker to execute arbitrary code under the rights of the process exploited. In the event that a vulnerable process uses the Of particular importance in the case of a HistoryThe See alsoReferences
External links
|
Portal di Ensiklopedia Dunia