public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* suid bit on directories
@ 2002-05-18  8:34 Michael Hoennig
  2002-05-18  8:52 ` Cedric Ware
  2002-05-20 13:04 ` Jesse Pollard
  0 siblings, 2 replies; 26+ messages in thread
From: Michael Hoennig @ 2002-05-18  8:34 UTC (permalink / raw)
  To: Kernel Mailing List

Hello!

I am new on this list and thoroughly searched the FAQ, the archives and
the web for this question, but couldn't find anything.

We wondererd why setting the guid bit on a directory makes all new files
owned by the group of the directory, but this does not work for the suid
bit, making new files owned by the owner of the directory.

It would be a good solution to make files created by Apaches mod_php in
safe-mode, not owned by web:web (or httpd:httpd or somethign) anymore, but
the Owner of the directory. 

I do not even see a security hole if nobody other than the user itself and
httpd/web can reach this area in the file system, anyway. And it is still
the users decision that files in this (his) directory should belong to
him.

It seems, this has to be patched for each file system separately, right?
For example in linux/fs/ext2/ialloc.c.

Actually, the suid bit on directories works at least under FreeBSD. Is
there any reason, why it does not work under Linux?

Thanks
	Michael

-- 
Hostsharing eG / c/o Michael Hönnig / Boytinstr. 10 / D-22143 Hamburg
phone:+49/40/67581419 / mobile:+49/177/3787491 / fax:++49/40/67581426
http://www.hostsharing.net ---> Webhosting Spielregeln selbst gemacht

^ permalink raw reply	[flat|nested] 26+ messages in thread
* Re: suid bit on directories
@ 2002-05-21 13:34 Jesse Pollard
  0 siblings, 0 replies; 26+ messages in thread
From: Jesse Pollard @ 2002-05-21 13:34 UTC (permalink / raw)
  To: dax, Jesse Pollard; +Cc: linux-kernel, michael@hostsharing.net

Dax Kelson <dax@gurulabs.com>
> On Mon, 20 May 2002, Jesse Pollard wrote:
> 
> > > > No. You loose the fact that the file was NOT created by the user.
> > > 
> > > the user in my example above would be wwwrun or httpd - and that does not
> > > make any sense at all! It would make much more sense if the new files
> > > belonged to the owner of the directory, who is the one who owns the
> > > virtual host.
> > 
> > You can't tell who the user is. ANY user would be able to do that.
> 
> Bzzzt.  Only if the permissions permitted it.
> 
> 
> Example 1:
> 
> /home/bob/public_html
> 
> public_html  is user/group  bob/httpd
> 
> the perms are 2770
> 
> ============================
> 
> Example 2:
> 
> All users on the system have a primary or secondary group "users"
> 
> /home/bob   user/group  bob/users
> 
> perms are 701
> 
> This explictly denies "users", yet allows Apache in (since it is running 
> as httpd).


And if "bob" makes the file world readable it can't be read by someone else?
And if the file is supposed to be updated by the web server it can't be
created (truncated, unless also world writeable)? If not, then his implies that
besides changing the owner of created files, the changed owner is also
used to verify authorization to create.

Granted, this limits the identity of the attacker to anyone in the group
httpd or the user.

And the world x doesn't grant access? (have you seen the attempts to get
a "open file by inode" added? very usefull for file migration - and almost
mandatatory for performance reasons. And also usefull for attacks.
Fortunately, it isn't there yet, and hopefully it will be restricted).

The attacker may not be able to read the directory, but he can certanly
attack it by just creating/opening files in the home directory. That could gain 
access to OTHER files in the home directory.

You also have problems with backup/restore done by users. Tar/cpio will/can
change the group ownership of the directory, and will change group ownership
of any files/subdirectories restored. Even cp would cause problems
by preventing the web server from access (again, it must be created world
readable). Also exposes potential damage in crash situations (though not
as bad as external attack - lost files become world accessable).

ACLs would be much easer to support. Try them out..

-------------------------------------------------------------------------
Jesse I Pollard, II
Email: pollard@navo.hpc.mil

Any opinions expressed are solely my own.

^ permalink raw reply	[flat|nested] 26+ messages in thread
* Re: suid bit on directories
@ 2002-05-21 13:34 Jesse Pollard
  0 siblings, 0 replies; 26+ messages in thread
From: Jesse Pollard @ 2002-05-21 13:34 UTC (permalink / raw)
  To: dax, Jesse Pollard; +Cc: linux-kernel, michael@hostsharing.net


Dax Kelson <dax@gurulabs.com>:
> 
> On Mon, 20 May 2002, Jesse Pollard wrote:
> 
> > That is NOT wrong. The files belong to the server. Not a user. I've been
> > running a server that way for years.
> 
> This is insecure.
> 
> A user has a defined security context.  If the user can create code that 
> is then executed in a different security context (user httpd/nobody), then 
> you've got a potential problem.  If you have multiple users who can 
> create code that executes in the *same* security context, you have a 
> recipe for disaster.

correct.

> user1 can write a web app the delete/modifies the web app, or web app 
> created files of user2.

Exactly what you get when the owner is hidden. Whose app got executed
that created/destroyed someone elses files? What files were created?

It all runs under the web server account... but the results are owned by
the attacked user so it looks like the user did it. Anything a CGI can
create, a CGI can execute or cause to be executed.

If you want a secured web server, DON'T let users create CGI. and don't
give the CGI the capability to execute other programs either. And this
is where compartmentalization comes into play.

All you know is that maybe the attack was via a web server. But you can't tell.

-------------------------------------------------------------------------
Jesse I Pollard, II
Email: pollard@navo.hpc.mil

Any opinions expressed are solely my own.

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2002-05-22  4:44 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-05-18  8:34 suid bit on directories Michael Hoennig
2002-05-18  8:52 ` Cedric Ware
2002-05-18 10:34   ` Michael Hoennig
2002-05-19  1:12     ` jw schultz
2002-05-20 13:04 ` Jesse Pollard
2002-05-20 13:24   ` Michael Hoennig
2002-05-20 14:03     ` Jesse Pollard
2002-05-20 14:53       ` Michael Hoennig
2002-05-20 18:12         ` dean gaudet
2002-05-21 17:48           ` Bill Davidsen
2002-05-20 19:28         ` Jesse Pollard
2002-05-20 20:58           ` Miquel van Smoorenburg
2002-05-20 21:15           ` Michael Hoennig
2002-05-21 18:03             ` Bill Davidsen
2002-05-22  4:44               ` Michael Hoennig
2002-05-21  3:49           ` Dax Kelson
2002-05-20 15:53       ` Bill Davidsen
2002-05-20 19:17       ` Albert D. Cahalan
2002-05-20 20:17         ` Jesse Pollard
2002-05-21  3:28       ` Dax Kelson
2002-05-21  3:58         ` Dax Kelson
2002-05-21 18:04           ` Bill Davidsen
2002-05-21 18:35             ` J Sloan
2002-05-20 15:42   ` Bill Davidsen
  -- strict thread matches above, loose matches on Subject: below --
2002-05-21 13:34 Jesse Pollard
2002-05-21 13:34 Jesse Pollard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox