With the linux Set UID Attribute you can let the owner of the file be the one the execute it when another user executes the file. This feature has traditionaly be used for system tools in linux which require root access to run but also must be able to be run my users.
It came to mind that a floppy with the ext2 filesystem could contain files of the root user with this Set UID Attribute set. Which theoraticly would allow anyone who is allowed to mount floppy’s or other media with an filesystem that supports this attribute to gain root access for a program.
On my system I got this entry in my
/mnt/fstab, which allows an user to mount the floppy:
/dev/floppy/0 /mnt/floppy auto noauto,user 0 0
I made a simple C program which would show the contents of
/etc/shadow, which contains the password hashes of the users, and chmodded it accordingly. (
chmod = showshadow; chmod go+x showshadow; chmod u+rs showshadow)
I ran my program, and it seemed to work! The contents of the
/etc/shadow file was streaming on my console.
Euforicly I went to another linux computer and tried the same trick.
darkshines@darkshines-one /mnt/floppy $ ./showshadow
bash: ./showshadow: Permission denied
Dissapointed but releived it seemed that linux had already some precaution against a root Set UID-ed executable.
I copied the contents of the folder whilest preserving permissions to another folder outside the
/mnt/floppy and it all seemed to work again, although I couldn’t do it with a normal user account for I can’t preserve the owner when copying a file as a normal user.
I wondered how linux would secure it and tried to run the program while it was unchmodded.
darkshines@darkshines-one /mnt/floppy $ ./showshadow.unchmodded
bash: ./showshadow.unchmodded: Permission denied
The warning is from bash which can’t seem to execute the program. (note that it isn’t the program that can’t acces
shadow) . After recompiling it on the floppy itself it seems that linux prevents any program to be executed in an user mounted folder.
I recon that that security precaution is a bit too strict. Although copying the file from the medium to a normal folder and then executing is still possible, I find it a bit strange that nothing of the user itself can be executed.
This could result in trouble when dealing with netmounts where one user can has a share on a server where he puts his files and can access only that mount for space on a terminal, when dealing with an user mount which would be required for security.