Secure Webserver and CGI

Discuss usability issues, general maintenance, and general support issues for a grsecurity-enabled system.

Secure Webserver and CGI

Postby crazyhorse » Wed Jan 07, 2004 5:03 pm

Hello,

I'd like to enhance security of my multi-user webserver.


Every user has an Apache VirtualHost and a directory in /home/$USERNAME and can place HTML, PHP and CGI scripts there.

The problem: CGI scripts run under the user apache. This way a user can create a CGI-script

Code: Select all
#/usr/bin/perl

print "Content-type: text/plain\n\n";
print `cat /home/$OTHERUSER/secret.file;


Apache must have access to "secret.file", perhaps it is a php include containing database password.

I cannot find a solution for this security problem. Can grsecurity help me in this case?
crazyhorse
 
Posts: 2
Joined: Wed Jan 07, 2004 4:47 pm

Re: Secure Webserver and CGI

Postby Serega » Thu Jan 08, 2004 2:56 am

crazyhorse wrote:Hello,

I'd like to enhance security of my multi-user webserver.


Every user has an Apache VirtualHost and a directory in /home/$USERNAME and can place HTML, PHP and CGI scripts there.

The problem: CGI scripts run under the user apache. This way a user can create a CGI-script

Code: Select all
#/usr/bin/perl

print "Content-type: text/plain\n\n";
print `cat /home/$OTHERUSER/secret.file;


Apache must have access to "secret.file", perhaps it is a php include containing database password.

I cannot find a solution for this security problem. Can grsecurity help me in this case?


The easiest way for you is chroot entirelly Apache webserver and use ExecCGI Apache function for running scripts from different users for each virtualhost. If you want also secure run PHP scripts from different users, you should compile PHP as CGI and run PHP scripts via ExecCGI too.
Serega
 
Posts: 1
Joined: Thu Jan 08, 2004 2:38 am

Postby axehind » Thu Jan 08, 2004 1:35 pm

I would think you could have a subject for each users directory. Something like

subject /home/user1 o
/
/home/user1 rwxcd
/bin rx
/usr rx

hhmmm I'm not sure if this would work though as the exec might be /usr/bin/perl program.cgi

axehind
axehind
 
Posts: 13
Joined: Mon Jul 01, 2002 1:32 pm

Postby crazyhorse » Fri Jan 09, 2004 7:20 pm

thanks for your replies. i think i need the suexec wrapper - damned overhead.
crazyhorse
 
Posts: 2
Joined: Wed Jan 07, 2004 4:47 pm


Return to grsecurity support