LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-07-2012, 08:26 AM   #1
qrange
Senior Member
 
Registered: Jul 2006
Location: Belgrade, Yugoslavia
Distribution: Debian stable/testing, amd64
Posts: 1,067

Rep: Reputation: 47
problem. user allowed to modify roots files in /home


If I run 'sudo touch /home/user1/tst', the user1 can remove file tst (even though root is owner, and others should be able to read it only). Please tell me, is that normal behaviour or security issue?
/home is on ext3.

thanks.
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 02-07-2012, 08:34 AM   #2
deep27ak
Senior Member
 
Registered: Aug 2011
Location: Bangalore, India
Distribution: RHEL 7.x, SLES 11 SP2/3/4
Posts: 1,195
Blog Entries: 4

Rep: Reputation: 221Reputation: 221Reputation: 221
give sticky bit permission to the directory so that only owner can delete the files or directory itself.

also give 744 permission to the directory so that others and group will have read only permission over the directory.

Code:
#chmod -R 1744 /home/user1/tst
 
2 members found this post helpful.
Old 02-07-2012, 08:39 AM   #3
cbtshare
Member
 
Registered: Jul 2009
Posts: 645

Rep: Reputation: 42
The user can remove a file root created if the user is in root's private group...

cat /etc/groups

for more info.Or if the user has id of 0

cat /etc/passwd for details...
 
1 members found this post helpful.
Old 02-07-2012, 09:10 AM   #4
qrange
Senior Member
 
Registered: Jul 2006
Location: Belgrade, Yugoslavia
Distribution: Debian stable/testing, amd64
Posts: 1,067

Original Poster
Rep: Reputation: 47
well it says:
cat: /etc/groups: No such file or directory

user1 is in sudoers, does that matter?
id is 1000.
 
Old 02-07-2012, 09:16 AM   #5
deep27ak
Senior Member
 
Registered: Aug 2011
Location: Bangalore, India
Distribution: RHEL 7.x, SLES 11 SP2/3/4
Posts: 1,195
Blog Entries: 4

Rep: Reputation: 221Reputation: 221Reputation: 221
Quote:
Originally Posted by qrange View Post
well it says:
cat: /etc/groups: No such file or directory

user1 is in sudoers, does that matter?
id is 1000.
Code:
#cat /etc/group
 
Old 02-07-2012, 05:08 PM   #6
clocker
Member
 
Registered: Sep 2011
Distribution: fedora, redhat, mint
Posts: 87

Rep: Reputation: Disabled
If user1 is a member of roots home then he can have access to roots files.
1.give root home this

#chmod 744

4-read
2-write
1-execute
 
Old 02-08-2012, 02:11 AM   #7
qrange
Senior Member
 
Registered: Jul 2006
Location: Belgrade, Yugoslavia
Distribution: Debian stable/testing, amd64
Posts: 1,067

Original Poster
Rep: Reputation: 47
hm, user1 is not in root's private group:
user1@debian:~$ cat /etc/group
root:x:0:

I am talking about the files created by root in home/user1 directory.
user1 cannot modify/delete files in /etc/ or similar, but has full access to all files in its home (even those owned by root).
 
Old 02-08-2012, 02:20 AM   #8
deep27ak
Senior Member
 
Registered: Aug 2011
Location: Bangalore, India
Distribution: RHEL 7.x, SLES 11 SP2/3/4
Posts: 1,195
Blog Entries: 4

Rep: Reputation: 221Reputation: 221Reputation: 221
root is default owner for all files and user is owner of its home directory

but you need to check the permission of the file which is created by root inside /home directory of user
for eg:
Code:
-rw-r--r-- 1 root  root     0 Feb  8 18:19 test.txt
The file is inside user's home dir and is owned by root so user will not be able to make any changes because the permission is 644
only owner can make changes and not others
 
Old 02-08-2012, 02:36 AM   #9
qrange
Senior Member
 
Registered: Jul 2006
Location: Belgrade, Yugoslavia
Distribution: Debian stable/testing, amd64
Posts: 1,067

Original Poster
Rep: Reputation: 47
yes, I've got exact same empty file, and if I try rm it as user1:
rm: remove write-protected regular empty file `tst'?

after replying with 'y', it removes it!
 
Old 02-08-2012, 03:06 AM   #10
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 137Reputation: 137
Quote:
Originally Posted by qrange View Post
If I run 'sudo touch /home/user1/tst', the user1 can remove file tst (even though root is owner, and others should be able to read it only). Please tell me, is that normal behaviour or security issue?
/home is on ext3.

thanks.
Yes this behaviour is quite normal.
In order to remove file user don't need any permissions to the file, but write permission to directory that this file in.
 
1 members found this post helpful.
Old 02-08-2012, 03:17 AM   #11
deep27ak
Senior Member
 
Registered: Aug 2011
Location: Bangalore, India
Distribution: RHEL 7.x, SLES 11 SP2/3/4
Posts: 1,195
Blog Entries: 4

Rep: Reputation: 221Reputation: 221Reputation: 221
Quote:
Originally Posted by qrange View Post
yes, I've got exact same empty file, and if I try rm it as user1:
rm: remove write-protected regular empty file `tst'?

after replying with 'y', it removes it!
did you applied sticky bit to that file?
 
Old 02-08-2012, 03:38 AM   #12
Valery Reznic
ELF Statifier author
 
Registered: Oct 2007
Posts: 676

Rep: Reputation: 137Reputation: 137
Quote:
Originally Posted by deep27ak View Post
did you applied sticky bit to that file?
Sticky bit should be applied not to the file, but to it's parent directory, as yourself said in the one of previous ports
 
Old 02-08-2012, 03:42 AM   #13
deep27ak
Senior Member
 
Registered: Aug 2011
Location: Bangalore, India
Distribution: RHEL 7.x, SLES 11 SP2/3/4
Posts: 1,195
Blog Entries: 4

Rep: Reputation: 221Reputation: 221Reputation: 221
agreed but it seems qrange didn't noticed my earlier post

But on the contrary leaving the OP apart sticky bit can be given to files as well
 
Old 02-08-2012, 04:04 AM   #14
rainbowsally
Member
 
Registered: Oct 2011
Posts: 47
Blog Entries: 138

Rep: Reputation: Disabled
Quote:
Originally Posted by qrange View Post
If I run 'sudo touch /home/user1/tst', the user1 can remove file tst (even though root is owner, and others should be able to read it only). Please tell me, is that normal behaviour or security issue?
/home is on ext3.

thanks.
It looks to me like USER created the file so root's 'touch' would only modify the access time.

I.e., it was never root's file. (Others have noted the inheritance of ownership from the parent folder and this may be why it was never root's.)

But to belabor the subject, for example if a user creates a text file
Code:
echo "This is $USER" > test.txt
then as root or sudo or whatever does this...
Code:
echo "And this is ROOT" >> test.txt
User can still add another line:
Code:
echo "And this is $USER again" >> test.txt
and USER can delete the file when no longer needed.

In the original post all root did was "touch" a preexisting file and that does not change ownership.

In short, yes. It's normal security. :-)
 
Old 02-09-2012, 02:06 AM   #15
qrange
Senior Member
 
Registered: Jul 2006
Location: Belgrade, Yugoslavia
Distribution: Debian stable/testing, amd64
Posts: 1,067

Original Poster
Rep: Reputation: 47
@deep27ak
I had checked 'only owner can rename and delete folder content' for /home/user1 in krusader, presuming thats 'sticky bit'.
there is no such option for files.
@rainbowsally
the file was not preexisting. it was created with sudo touch, and had root as owner. exact same thing happens if I use su instead.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Allow ftp user access to modify apache owned files jasonma84@yahoo.com Linux - Newbie 4 10-26-2010 05:25 PM
[SOLVED] [SAMBA] How to track windows user access , create files /modify files on linux SMB efciem Linux - Server 2 05-16-2010 09:45 AM
bash script to read password from roots home lord-fu Linux - Server 2 06-04-2007 01:09 PM
Tracking user logins that was allowed and not allowed eswanepoel Linux - Security 3 08-02-2006 05:37 AM
ssh problem: one user is allowed the other is refused! levent.ozkan Linux - Networking 5 10-05-2005 02:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:58 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration