Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
PS in Jail
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
Buge
n00b
n00b


Joined: 29 Feb 2004
Posts: 60
Location: Bern, Switzerland

PostPosted: Fri Apr 16, 2004 8:28 am    Post subject: PS in Jail Reply with quote

I have set up a jail on my external (web-)server so users can deploy their modules in the web container running on the server.

I have received a request for users to be able to use ps, but for that I would have to mount proc in the jail (right?). How can I do this in a safe way, so I do not compromise the advantages I have by using the jail?

Thanks in advance,
Buge
Back to top
View user's profile Send private message
mikulus
Tux's lil' helper
Tux's lil' helper


Joined: 03 Jun 2002
Posts: 77

PostPosted: Fri Apr 16, 2004 5:49 pm    Post subject: Reply with quote

I found this while searching on Google:

http://worldserver3.oleane.com/bouynot/gabuzomeu/alex/doc/apache/index-en.html

Please take a look at the "My File" link within the web page. It shows that he mounted the /proc file system via script as:

Code:
mount -t proc proc /var/chroot/apache/proc

_________________
"Two things are infinite - the universe and human stupidity. And I am not sure about the universe."
Back to top
View user's profile Send private message
mikulus
Tux's lil' helper
Tux's lil' helper


Joined: 03 Jun 2002
Posts: 77

PostPosted: Fri Apr 16, 2004 5:53 pm    Post subject: Reply with quote

Debian security manual also has a similar work-around. This script seems to be better:

http://www.debian.org/doc/manuals/securing-debian-howto/ap-chroot-apache-env.en.html

Here is the code:
Code:
#! /bin/bash
     #
     # apache   Start the apache HTTP server.
     #
     
     CHRDIR=/var/chroot/apache
     
     NAME=apache
     PATH=/bin:/usr/bin:/sbin:/usr/sbin
     DAEMON=/usr/sbin/apache
     SUEXEC=/usr/lib/apache/suexec
     PIDFILE=/var/run/$NAME.pid
     CONF=/etc/apache/httpd.conf
     APACHECTL=/usr/sbin/apachectl
     
     trap "" 1
     export LANG=C
     export PATH
     
     test -f $DAEMON || exit 0
     test -f $APACHECTL || exit 0
     
     # ensure we don't leak environment vars into apachectl
     APACHECTL="env -i LANG=${LANG} PATH=${PATH} chroot $CHRDIR $APACHECTL"
     
     if egrep -q -i "^[[:space:]]*ServerType[[:space:]]+inet" $CONF
     then
         exit 0
     fi
     
     case "$1" in
       start)
         echo -n "Starting web server: $NAME"
         mount -t proc proc /var/chroot/apache/proc
         start-stop-daemon --start --pidfile $PIDFILE --exec $DAEMON \
        --chroot $CHRDIR
         ;;
     
       stop)
         echo -n "Stopping web server: $NAME"
         start-stop-daemon --stop --pidfile "$CHRDIR/$PIDFILE" --oknodo
         umount /var/chroot/apache/proc
         ;;
     
       reload)
         echo -n "Reloading $NAME configuration"
         start-stop-daemon --stop --pidfile "$CHRDIR/$PIDFILE" \
        --signal USR1 --startas $DAEMON --chroot $CHRDIR
         ;;
     
       reload-modules)
         echo -n "Reloading $NAME modules"
         start-stop-daemon --stop --pidfile "$CHRDIR/$PIDFILE" --oknodo \
        --retry 30
         start-stop-daemon --start --pidfile $PIDFILE \
        --exec $DAEMON --chroot $CHRDIR
         ;;
     
       restart)
         $0 reload-modules
         exit $?
         ;;
     
       force-reload)
         $0 reload-modules
         exit $?
         ;;
     
       *)
         echo "Usage: /etc/init.d/$NAME {start|stop|reload|reload-modules|force-reload|restart}"
         exit 1
         ;;
     esac
     
     if [ $? == 0 ]; then
        echo .
        exit 0
     else
        echo failed
        exit 1
     fi

_________________
"Two things are infinite - the universe and human stupidity. And I am not sure about the universe."
Back to top
View user's profile Send private message
Buge
n00b
n00b


Joined: 29 Feb 2004
Posts: 60
Location: Bern, Switzerland

PostPosted: Fri Apr 16, 2004 7:33 pm    Post subject: Reply with quote

Thanks for your reply.

I'm not really looking for a script that simply mounts /proc however. In fact, I am not even using apache. Just JBoss ;-)
What I am looking for, is a way to provide ps with whatever it needs from /proc without needing to mount all of proc (if that is even possible?).
Or should I just mount proc anyway?

Thanks,
Buge
Back to top
View user's profile Send private message
mikulus
Tux's lil' helper
Tux's lil' helper


Joined: 03 Jun 2002
Posts: 77

PostPosted: Sat Apr 17, 2004 5:04 am    Post subject: Reply with quote

I think if you want to provide access to ps, you will have to mount the entire /proc. I don't beleive there is a way to partially mount /proc. If you consider this a security risk, my recommendation is -- don't do it. Your users will have to live without ps.
_________________
"Two things are infinite - the universe and human stupidity. And I am not sure about the universe."
Back to top
View user's profile Send private message
neuron
Advocate
Advocate


Joined: 28 May 2002
Posts: 2371

PostPosted: Sat Apr 17, 2004 9:53 am    Post subject: Reply with quote

theory solution.

chown root:weirdgroup
mount --bind /proc -t proc /opt/glftpd/proc
chown root:weirdgroup /opt/glftpd/proc
chown root:weirdgroup /opt/glftpd/bin/ps
chmod uo-rwx /opt/glftpd/proc
chmod g+s /opt/glftpd/bin/ps

no idea if it'll work though. Dont know how well it works to chown binds, you might be altering the original dir.

Could be you could put the bind in /opt/glftpd/bla/proc
then chown that and ln -s /proc /bla/proc in the chroot
Back to top
View user's profile Send private message
creese
n00b
n00b


Joined: 13 Aug 2003
Posts: 58
Location: Folsom, CA

PostPosted: Sat Apr 17, 2004 8:52 pm    Post subject: Reply with quote

How about setting up xinetd to run the appropriate ps command when a TCP connection to 127.0.0.1:xxx is opened. Then your users can execute the ps command simply by openning a connection and reading.
Back to top
View user's profile Send private message
Chris W
l33t
l33t


Joined: 25 Jun 2002
Posts: 972
Location: Brisbane, Australia

PostPosted: Sun Apr 18, 2004 12:11 am    Post subject: Reply with quote

I'm struggling to think of a single valid reason for a Java-based web application to require the output of the ps command. If you can think a good reason then you might want to look into the vserver extensions to the Linux kernel. Users within a security context can run ps but will only ever see processes belonging to their context. There are issues with the networking of such a solution which may be problematic depending on your environment.

You may be able to selectively mount bits of /proc using the bind option to mount but you need all the process directories in /proc (i.e. pid# directories) which are, of course, a moving target.
_________________
Cheers,
Chris W
"Common sense: The collection of prejudices acquired by age 18." -- Einstein
Back to top
View user's profile Send private message
Buge
n00b
n00b


Joined: 29 Feb 2004
Posts: 60
Location: Bern, Switzerland

PostPosted: Sun Apr 18, 2004 12:59 pm    Post subject: Reply with quote

Thanks for all your replies!

I'm going to take a look at the options whenever I have some free time again, but in the end, it will probably end being no ps for the users. :wink:

Thanks again!
Back to top
View user's profile Send private message
garn
Tux's lil' helper
Tux's lil' helper


Joined: 10 Sep 2003
Posts: 131

PostPosted: Sun Apr 18, 2004 2:48 pm    Post subject: Reply with quote

The grsecurity kernel patch lets you restrict /proc as well, so users can't see netstat and such information, as well as ps listing.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum