Security1O1 avatar

[EN] Linux file permissions - SUID

security101

Published: 05 May 2018 › Updated: 05 May 2018[EN] Linux file permissions - SUID

[EN] Linux file permissions - SUID

sec-image(1).png

File permissions are a basic concept in Linux systems to manage permissions to write, read and execute files.
In this article I would like to limit myself to a less common file right - the SUID-bit.

By setting the SetUserID bit a file is always executed with the rights of the file owner.


What is the file permission used for?

An example of a meaningful use of this file right is the program passwd, which changes passwords of users and groups. In order for a user to change his own password, the SUID right must be set. Thus, the program is executed as root.


Schema

The SUID bit is displayed as follows:
The SUID bit is indicated by a s or S at the position of the file permission to execute a file (x).

passwd.PNG

A small s means that an execution is also possible in addition to the SUID bit. However, this is not possible with a large S.


Why is the SUID bit "dangerous"?

The SUID bit should be used very carefully and only when really necessary. Because the privileged execution of a file creates a potential security risk. If a file is manipulated accordingly, rights can be extended ( privilege escalation).


Example

The program find with the original rights:
find.png

find offers the possibility to execute commands using -exec :
findwhoami.png

Now the SUID bit is set: chmod +s /usr/bin/find
chmodfind.png

Then we execute the same command as before:
findwhoamiroot.png

So it is now possible to execute arbitrary code as root. If unauthorized access to a system has taken place, a "backdoor" can be set up with which it is possible to obtain administrative rights from any user.


Which files have set the SUID bit?

Files with SUID rights can be found, for example, using:

find / -user root -perm -4000 -print 2>/dev/null

Thank you for reading !

Leave [EN] Linux file permissions - SUID to:

Written by

IT Security / Kryptowährungen

Read more #it-security posts


Best Posts From Security1O1

We have not curated any of security101's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From Security1O1