#37679 [Opn->Bgs]: Fork bomb with system() and exec()

From: Date: Sun, 04 Jun 2006 09:21:13 +0000
Subject: #37679 [Opn->Bgs]: Fork bomb with system() and exec()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-98011@lists.php.net to get a copy of this message
ID: 37679 Updated by: edink@php.net Reported By: mdon at names dot co dot uk -Status: Open +Status: Bogus Bug Type: CGI related Operating System: CentOS 4.2 PHP Version: 4.4.2 New Comment: This is expected behaviour of the cgi sapi. You are supposed to used cli version of PHP to execute command line scripts. Avoiding problems like this was one of the reasons cli version of PHP was made in the first place. Previous Comments: ------------------------------------------------------------------------ [2006-06-02 13:59:45] mdon at names dot co dot uk Description: ------------ Forking a process to run a second PHP script using system() or exec() creates a fork bomb in CGI version of PHP 4.4.2. This appears to be due to the $PATH_TRANSLATED environment variable not being cleared correctly and is reproducible from the command line. Reproduce code: --------------- test1.php: <?php system("php -q test2.php")?> test2.php <?php echo "hello, i'm test2.php\n"?> Expected result: ---------------- When test1.php is run via a web server or from the command line, I would expect to just see the output of test2.php. Actual result: -------------- Running test1.php via a web server (Zeus 4.3r2 in our case) creates a fork bomb, which looks like this in ps: 17522 2:49 \_ zeus.cgi 16666 0:00 | \_ php 16668 0:00 | | \_ php -q test2.php 16670 0:00 | | \_ php -q test2.php 16672 0:00 | | \_ php -q test2.php 16674 0:00 | | \_ php -q test2.php 16676 0:00 | | \_ php -q test2.php ...etc... With some help from the Zeus developers, we have determined that this appears to be due to the $PATH_TRANSLATED environment variable not being cleared correctly. This can be replicated from the command line as follows: export PATH_TRANSLATED="test1.php"; php test1.php PHP was configured with the following options: ./configure --prefix=/usr/local --enable-bcmath --with- freetype-dir --enable-ftp --with-mysql=/usr --with- mssql=/usr/local --with-mcrypt=/usr/local/lib/libmcrypt --with-zlib-dir=/usr/local --with-pspell --with-curl -- with-imap=/usr/local/imap-2002e --with-gd --with-jpeg- dir --with-png-dir --with-libdir=/usr/lib --with-ttf -- with-xml --enable-xslt --with-xslt-sablot --with-sablot- js --enable-mbstring --with-config-file-path=/usr/local/ bin --with-pear --with-openssl ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=37679&edit=1

« previous php.bugs (#98011) next »