/home security problem

Andy Koppe andy.koppe@gmail.com
Fri Sep 3 18:45:00 GMT 2010


On 3 September 2010 03:04, Dave Korn wrote:
> On 02/09/2010 22:22, Andy Koppe wrote:
>
>> The /home directory has rwxrwxrwt rights. This allows anyone to create
>> directories and files in /home, but due to the 'sticky' bit
>> represented by the 't' at the end, only directory/file owners can
>> delete them. So this allows /etc/profile to create a user's home
>> directory, without allowing users to remove other users' home
>> directories.
>>
>> Trouble is, users can create directories with any name in /home,
>> including directories with the name of another user who hasn't yet
>> logged in. When that user eventually does log in, (s)he'll end up with
>> a home directory owned by someone else. This even works for
>> administrators, i.e. I ended up being able as an ordinary user to
>> delete files in an administrator's home directory.
>>
>> I've got no idea how to fix that short of changing the /home
>> permissions to 775 and hence requiring an administrator to create any
>> home directories (which of course is what happens on Linux).
>
>  We could restructure the logic in /etc/profile to do something like
>
>  if [ $HOME already exists ]
>    if [ $HOME owner uid != $user uid ]
>      issue warning and rename bogus home dir aside
>    fi
>  fi
>
> just before the current
>
>  if [ $HOME doesn't exist ]
>    copy it from /etc/skel, issuing the standard first-run message.
>  fi
>
> bit.  (Sorry pseudocode only.)

Good idea. I see bash has a built-in test for whether a file belongs
to the current user (-O file), so this could probably be done without
incurring another fork.

Andy



More information about the Cygwin-developers mailing list