View previous topic :: View next topic |
Author |
Message |
Buge n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
![](images/avatars/gallery/Simpsons/simpsons_groundskeeper_will.gif)
Joined: 29 Feb 2004 Posts: 60 Location: Bern, Switzerland
|
Posted: Fri Apr 16, 2004 8:28 am Post subject: PS in Jail |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
mikulus Tux's lil' helper
![Tux's lil' helper Tux's lil' helper](/images/ranks/rank_rect_1.gif)
![](images/avatars/101339801741f43131e426b.png)
Joined: 03 Jun 2002 Posts: 77
|
Posted: Fri Apr 16, 2004 5:49 pm Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
mikulus Tux's lil' helper
![Tux's lil' helper Tux's lil' helper](/images/ranks/rank_rect_1.gif)
![](images/avatars/101339801741f43131e426b.png)
Joined: 03 Jun 2002 Posts: 77
|
Posted: Fri Apr 16, 2004 5:53 pm Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
Buge n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
![](images/avatars/gallery/Simpsons/simpsons_groundskeeper_will.gif)
Joined: 29 Feb 2004 Posts: 60 Location: Bern, Switzerland
|
Posted: Fri Apr 16, 2004 7:33 pm Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
mikulus Tux's lil' helper
![Tux's lil' helper Tux's lil' helper](/images/ranks/rank_rect_1.gif)
![](images/avatars/101339801741f43131e426b.png)
Joined: 03 Jun 2002 Posts: 77
|
Posted: Sat Apr 17, 2004 5:04 am Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
neuron Advocate
![Advocate Advocate](/images/ranks/rank-G-1-advocate.gif)
![](images/avatars/d946e5263cf3dddd25d4e.gif)
Joined: 28 May 2002 Posts: 2371
|
Posted: Sat Apr 17, 2004 9:53 am Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
creese n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 13 Aug 2003 Posts: 58 Location: Folsom, CA
|
Posted: Sat Apr 17, 2004 8:52 pm Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
Chris W l33t
![l33t l33t](/images/ranks/rank_rect_4.gif)
![](images/avatars/gallery/Simpsons/Simpsons_-_Ralph.jpg)
Joined: 25 Jun 2002 Posts: 972 Location: Brisbane, Australia
|
Posted: Sun Apr 18, 2004 12:11 am Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
Buge n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
![](images/avatars/gallery/Simpsons/simpsons_groundskeeper_will.gif)
Joined: 29 Feb 2004 Posts: 60 Location: Bern, Switzerland
|
Posted: Sun Apr 18, 2004 12:59 pm Post subject: |
|
|
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.
Thanks again! |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
garn Tux's lil' helper
![Tux's lil' helper Tux's lil' helper](/images/ranks/rank_rect_1.gif)
Joined: 10 Sep 2003 Posts: 131
|
Posted: Sun Apr 18, 2004 2:48 pm Post subject: |
|
|
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 |
|
![](templates/gentoo/images/spacer.gif) |
|