Linux - SecurityThis forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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.
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.
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.)
Last edited by Gullible Jones; 05-08-2013 at 08:16 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.
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'.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.