LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Security (https://www.linuxquestions.org/questions/linux-security-4/)
-   -   Does not this conflict with the concept of DAC? (https://www.linuxquestions.org/questions/linux-security-4/does-not-this-conflict-with-the-concept-of-dac-4175461140/)

ulkoma 05-08-2013 06:20 AM

Does not this conflict with the concept of DAC?
 
The fact that chown command requires root privileges? this means the original owner of a file can not transfer the ownership to somebody else? this sounds like MAC?

Sorry for being total noob

acid_kewpie 05-08-2013 09:04 AM

it doesn't strictly need root, but it doesn't make sense to allow a user to make a file be opened by someone else of the same security level or higher.

rknichols 05-08-2013 07:27 PM

The issues with allowing users to give away files are that it provides a way to evade quotas, or to DoS another user by consuming his quota with a large file somewhere that he cannot delete it or even access it.

Gullible Jones 05-08-2013 08:10 PM

1. Copy a shell binary somewhere you have write access to
2. Make it setuid
3. Make it owned by root

Now you can run it and get a shell as root without ever knowing the root password!

This is why limited users cannot run chown. AFAIK this applies to all UNIX and Linux OSes.

Edit: of course you could probably restrict chown to prevent non-root users from setting root ownership, and restrict chmod to prevent non-root users from creating setuid/setgid files. Not sure why this isn't done, maybe it introduces too much complexity and failure-proneness?

(Restricting chmod in particular seems like a good idea to me, limited users should never need to create setuid, setgid, or sticky files/directories. But anyway you can get that effect by mounting all user-writable areas nosuid.)

unSpawn 05-09-2013 12:27 AM

Quote:

Originally Posted by Gullible Jones (Post 4947516)
1. Copy a shell binary somewhere you have write access to
2. Make it setuid
3. Make it owned by root

Now you can run it and get a shell as root without ever knowing the root password!

This is why limited users cannot run chown.

That's a nice description of why allowing it would be a Bad Thing but it's not the reason why. The actual explanation can be read from 'man capabilities' (CAP_CHOWN) and the description of 'man 2 chown'.

rknichols 05-12-2013 09:19 PM

Quote:

Originally Posted by Gullible Jones (Post 4947516)
1. Copy a shell binary somewhere you have write access to
2. Make it setuid
3. Make it owned by root

Now you can run it and get a shell as root without ever knowing the root password!

Even in the early days of Unix when users were allowed to chown files, when a non-root user did so the setuid bit was cleared from the permissions. There is a similar protection in place for chgrp and the setgid bit.


All times are GMT -5. The time now is 01:09 PM.