php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #67587 Redirection loop on nginx with FPM
Submitted: 2014-07-07 20:02 UTC Modified: -
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: cweiske@php.net Assigned:
Status: Closed Package: PHAR related
PHP Version: 5.6Git-2014-07-07 (Git) OS:
Private report: No CVE-ID:
 [2014-07-07 20:02 UTC] cweiske@php.net
Description:
------------
nginx running php via fpm gives an endless redirection loop for .phar files.

$ curl -si http://phorkie.kylewm.com/phpinfo.phar/www/index.php|grep Location
Location: /phpinfo.phar/www/index.php


Problem is the CGI detection in Phar::webPhar() which only knows about "cgi-fcgi" and "cgi", but not about "cgi-fpm" as it is reported here:

> if ((strlen(sapi_module.name) == sizeof("cgi-fcgi")-1 && !strncmp(sapi_module.name, "cgi-fcgi", sizeof("cgi-fcgi")-1))
>    || (strlen(sapi_module.name) == sizeof("cgi")-1 && !strncmp(sapi_module.name, "cgi", sizeof("cgi")-1))) {

http://git.php.net/?p=php-src.git;a=blob;f=ext/phar/phar_object.c;h=75aadfbc540b9929b0af563e365990c69b1ca315;hb=HEAD#l608

Seems similar to bug #53537.

Test script:
---------------
<?php
if (file_exists('phpinfo.phar')) {
    unlink('phpinfo.phar');
}
$phar = new Phar('phpinfo.phar');
$phar->addFromString('www/index.php', '<?php phpinfo();?>');
$phar->setStub(
    '<?php Phar::webPhar(null, "www/index.php"); echo "cli\n"; __HALT_COMPILER(); ?>'
);
?>


Expected result:
----------------
no redirection loop.

Actual result:
--------------
$ curl -si http://phorkie.kylewm.com/phpinfo.phar/www/index.php|grep Location
Location: /phpinfo.phar/www/index.php


Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-07-07 20:06 UTC] cweiske@php.net
It's actually "fpm-fcgi", not "cgi-fpm".
 [2014-07-08 19:56 UTC] stas@php.net
Automatic comment on behalf of cweiske@cweiske.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=0bf50a8302af94357595a21877e224fa42729e25
Log: Fix bug #67587: Redirection loop on nginx with FPM
 [2014-07-08 19:56 UTC] stas@php.net
-Status: Open +Status: Closed
 [2014-07-08 19:56 UTC] stas@php.net
Automatic comment on behalf of cweiske@cweiske.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=e65e013e15f49d82ede44af8bdd52c27c0cd8274
Log: Fix bug #67587: Redirection loop on nginx with FPM
 [2014-07-08 19:56 UTC] stas@php.net
Automatic comment on behalf of cweiske@cweiske.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=e76d3cba96dc2297fdb3b4e47b9a923f8fc2913d
Log: Fix bug #67587: Redirection loop on nginx with FPM
 [2014-07-09 10:08 UTC] dmitry@php.net
Automatic comment on behalf of cweiske@cweiske.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=e65e013e15f49d82ede44af8bdd52c27c0cd8274
Log: Fix bug #67587: Redirection loop on nginx with FPM
 [2014-07-09 10:08 UTC] dmitry@php.net
Automatic comment on behalf of cweiske@cweiske.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=0bf50a8302af94357595a21877e224fa42729e25
Log: Fix bug #67587: Redirection loop on nginx with FPM
 [2014-07-09 10:08 UTC] dmitry@php.net
Automatic comment on behalf of cweiske@cweiske.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=e76d3cba96dc2297fdb3b4e47b9a923f8fc2913d
Log: Fix bug #67587: Redirection loop on nginx with FPM
 [2014-07-21 09:31 UTC] ab@php.net
Automatic comment on behalf of cweiske@cweiske.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=e65e013e15f49d82ede44af8bdd52c27c0cd8274
Log: Fix bug #67587: Redirection loop on nginx with FPM
 [2014-07-21 09:31 UTC] ab@php.net
Automatic comment on behalf of cweiske@cweiske.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=0bf50a8302af94357595a21877e224fa42729e25
Log: Fix bug #67587: Redirection loop on nginx with FPM
 [2014-07-21 10:02 UTC] ab@php.net
Automatic comment on behalf of cweiske@cweiske.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=e65e013e15f49d82ede44af8bdd52c27c0cd8274
Log: Fix bug #67587: Redirection loop on nginx with FPM
 [2014-07-21 10:02 UTC] ab@php.net
Automatic comment on behalf of cweiske@cweiske.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=0bf50a8302af94357595a21877e224fa42729e25
Log: Fix bug #67587: Redirection loop on nginx with FPM
 [2014-07-21 10:02 UTC] ab@php.net
Automatic comment on behalf of cweiske@cweiske.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=e76d3cba96dc2297fdb3b4e47b9a923f8fc2913d
Log: Fix bug #67587: Redirection loop on nginx with FPM
 [2014-07-30 09:52 UTC] tyrael@php.net
Automatic comment on behalf of cweiske@cweiske.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=e65e013e15f49d82ede44af8bdd52c27c0cd8274
Log: Fix bug #67587: Redirection loop on nginx with FPM
 [2014-07-30 09:52 UTC] tyrael@php.net
Automatic comment on behalf of cweiske@cweiske.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=0bf50a8302af94357595a21877e224fa42729e25
Log: Fix bug #67587: Redirection loop on nginx with FPM
 [2014-10-07 23:14 UTC] stas@php.net
Automatic comment on behalf of cweiske@cweiske.de
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=0bf50a8302af94357595a21877e224fa42729e25
Log: Fix bug #67587: Redirection loop on nginx with FPM
 [2014-10-07 23:25 UTC] stas@php.net
Automatic comment on behalf of cweiske@cweiske.de
Revision: http://git.php.net/?p=php-src-security.git;a=commit;h=0bf50a8302af94357595a21877e224fa42729e25
Log: Fix bug #67587: Redirection loop on nginx with FPM
 
PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Sun Mar 29 06:04:53 2015 UTC