Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 65589 - Files owned by root can be removed by nonroot user when created with SUID binary
Summary: Files owned by root can be removed by nonroot user when created with SUID binary
Status: RESOLVED CANTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: x86 Linux
: High critical (vote)
Assignee: Gentoo's Team for Core System packages
URL: http://forums.gentoo.org/viewtopic.ph...
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-09-27 14:57 UTC by Nick Marsh
Modified: 2004-09-27 19:55 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Marsh 2004-09-27 14:57:11 UTC
Here is the deal, I have a user called backup. Backup is a normal user, except he has a SUID tar file used to backup the system. I discovered that anyone can remove the file owned by root if it was created with SUID tar. 

Example at: http://forums.gentoo.org/viewtopic.php?t=229445

Granted SUID is not the most secure way of doing things, but files files created with the SUID binary should not be able to be removed by non root users since they are owned by root and have 0644 mode.

Reproducible: Always
Steps to Reproduce:
1. Create an archive using SUID tar.
2. As a normal users
3. Remove the file owned by root as the normal user.

Actual Results:  
The file can be removed.

Expected Results:  
Files created with the SUID binary should not be able to be removed by non root
users since they are owned by root and have 0644 mode.

$ qpkg -I -v coreutils
sys-apps/coreutils-5.2.1 *

$ qpkg -I -v tar
app-arch/tar-1.14 *
Comment 1 Sven Wegener gentoo-dev 2004-09-27 15:09:30 UTC
We can't do anything about this. If a directory is writeable by a user, he is
able to delete files in that directory regardless of if he has has write access
to the file. A solution is to set the sticky bit on that directory, like it's
done with /tmp. This allows users only to delete files they own themself. root
is able to delete any file.
Comment 2 SpanKY gentoo-dev 2004-09-27 19:39:50 UTC
that's just how unix permissions work
Comment 3 solar (RETIRED) gentoo-dev 2004-09-27 19:55:51 UTC
A suid tar is not really a good idea either, in fact it's a pretty bad idea.

What if a local attacker on your box were to just tar zxvf etc_shadow.tgz -C / and adds (him|her)self to root via unpacking.