[Yum-devel] selinux and other pain
Ryan Tomayko
rtomayko at naeblis.cx
Sat Feb 28 20:24:53 UTC 2004
On Thu, 2004-02-26 at 10:59, Michael Stenner wrote:
> Well, if the data exists in memory BEFORE the fork, then it will
> simply exist in memory for both processes after the fork. I'd be
> shocked if this was non-safe.
>
> A fork is not like a system call. At the time of the fork, the
> process is cloned. The two processes are completely identical except
> for process ID and the return value of the fork() command.
>
> > xmlrpc MIGHT be safer - but I'm not sure if the two processes would be
> > allowed to communicate like that in the selinux security model.
>
> Agreed. I would hope that socket communication would be safe, but who
> knows. Those guys are psycho.
>
My understanding is that this is almost always accomplished with fork,
setuid, and plain old pipes (os.pipe). For example, most daemon type
stuff needs to start as root, forks, calls setuid to assume lesser
privileges, closes std{in,out,err} and then uses pipes to communicate
back with the other side of the fork if necessary. A lot of times the
side of the fork that is running as root exits.
Here's a really really good example of how some of this this is done in
python:
http://www.myelin.co.nz/post/2003/3/13/
The basic idea is to create a pipe _before the fork_. Then, fork. Now,
both sides of the fork can read and write to the pipe (i.e. it is a
shared object and is not duplicated for the forked process). It is then
trivial to wrap a fileobject around the pipe, so you can even use
pickles to communicate across the pipe.
forks are a weird concept in general and only lead to weirder stuff.
Still, I would assume that this is exactly what the SELinux policy stuff
is trying to enforce. Especially the setuid piece. I think the rule (not
the SELinux-rule but just security-in-general rule) is that any time
your opening a channel/socket with another machine, it should not be
done as root (or any other user/group that can do a ton of damage). Note
that this goes for clients and servers even though exploits are much
more common in servers. Imagine there was some way to exploit URLGrabber
(or more likely urllib2) when it established a connection to an HTTP
server. So, urllib2 connects and if the server sends back exactly 5573
bytes that are all 9's we buffer-overflow or something. Depending on how
much control I can get from this exploit, it could be very damaging if
it's running as root. If you instead drop down to nobody or a user that
can write only to a specific directory before you establish the
connection, then you've made _all_ exploits much less dangerous. Not by
removing the exploit but by reducing the amount of nasty stuff that can
happen when an exploit is found.
- Ryan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.baseurl.org/pipermail/yum-devel/attachments/20040228/30e493f0/attachment.pgp
More information about the Yum-devel
mailing list