php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79267 to much setcookie calls crashes the script
Submitted: 2020-02-12 23:02 UTC Modified: 2020-08-23 04:23 UTC
Votes:3
Avg. Score:5.0 ± 0.0
Reproduced:3 of 3 (100.0%)
Same Version:1 (33.3%)
Same OS:1 (33.3%)
From: williamdes at wdes dot fr Assigned:
Status: No Feedback Package: Reproducible crash
PHP Version: Irrelevant OS: devilbox/php-fpm:7.3-mods
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: williamdes at wdes dot fr
New email:
PHP Version: OS:

 

 [2020-02-12 23:02 UTC] williamdes at wdes dot fr
Description:
------------
As I reported here https://github.com/phpmyadmin/phpmyadmin/issues/15709

To many calls to the setcookie will crash the process.

Reproduced on Docker devilbox/php-fpm:7.1-mods and also 7.2,7.3,8.0 php versions

I am not sure that the error is not due to something else than php.

Test script:
---------------
<?php
setcookie("goto","",1577363177,"/@phpmyadmin/a/","",false);
setcookie("back","",1577363177,"/@phpmyadmin/a/","",false);
for ($i=1; $i < 40; $i++) {
    setcookie("pmaAuth-$i","",1577363177,"/@phpmyadmin/a/","",false);
}

Expected result:
----------------
See 200 success

Actual result:
--------------
502 bad gateway

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-02-13 00:45 UTC] requinix@php.net
-Status: Open +Status: Feedback
 [2020-02-13 00:45 UTC] requinix@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a backtrace to see what is happening behind the scenes. To
find out how to generate a backtrace, please read
http://bugs.php.net/bugs-generating-backtrace.php for *NIX and
http://bugs.php.net/bugs-generating-backtrace-win32.php for Win32

Once you have generated a backtrace, please submit it to this bug
report and change the status back to "Open". Thank you for helping
us make PHP better.


 [2020-02-23 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 [2020-02-23 14:50 UTC] williamdes at wdes dot fr
I will not have time soon to test in debug mode
But I will do it someday :)
 [2020-02-24 12:00 UTC] nikic@php.net
Doesn't reproduce on built-in server at least.
 [2020-02-24 12:10 UTC] nikic@php.net
-Status: No Feedback +Status: Verified
 [2020-02-24 12:10 UTC] nikic@php.net
With FPM I do see a "502 bad gateway", though no actual crash.
 [2020-02-24 12:36 UTC] hennadii dot panasenko at gmail dot com
I'm facing the same issue while trying to send extra one cookie using the code 

setcookie('GLSU', $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], 0, '/' , $_SERVER['SERVER_NAME'], true, true);

When I commented out one of the cookies (other, not this), all works fine.
No 'buben-dances' helped to solve the issue, not changing the cookie data, nor cookie name or any other credentials. It looks like only cookie count matters.

If needed, I'm ready to help to reproduce it.
 [2020-02-24 13:32 UTC] williamdes at wdes dot fr
Thank you for the comments, I am happy to see someone also has the same issue

> If needed, I'm ready to help to reproduce it.

Please go ahead

> With FPM I do see a "502 bad gateway", though no actual crash.

I called this a crash because I assumed that is the case or a response would be sent if the process did end normally
 [2020-02-24 14:51 UTC] hennadii dot panasenko at gmail dot com
I have Debian 9 + Nginx + PHP-FPM(7.2)
What else info do you need?
Please, ask direct questions or give me instructions what to do to help you.
 [2020-02-24 18:07 UTC] requinix@php.net
Is the 502 coming from nginx or php-fpm?
 [2020-02-25 07:40 UTC] hennadii dot panasenko at gmail dot com
The 502 is coming from php-fpm (php-fpm is crashing)?
After a long time debug i've found that issue is coming from the method of deleting a cookie.
In my project i need to update cookie domain from parent to child. To do this, i previously delete the cookie, and on the next line set it again with the new credentials.
Non-working code is:
     setcookie('COOKIENAME', '', 0, '/', 'myhost.com', true, false);
     setcookie('COOKIENAME', 'COOKIEVALUE', 0, '/', 'sub.myhost.com', true, false);

I've found that while i'm deleting a cookie, there is no need to set any additional data, but only name, value and zero-time. Any additional credentials are cause the 502 error. Also, no cookie-name or cookie-value matters.

Working code is:
    setcookie('COOKIENAME', '', 0);
    setcookie('COOKIENAME', 'COOKIEVALUE', 0, '/', 'sub.myhost.com', true, false);

Hope, it will help.
 [2020-08-10 19:33 UTC] williamdes at wdes dot fr
Hi,

Could someone have a look into this one ?, I still reproduce it.

nikic@php.net maybe ?

Regards
 [2020-08-11 08:57 UTC] nikic@php.net
-Status: Verified +Status: Feedback
 [2020-08-11 08:57 UTC] nikic@php.net
I just checked this again. Running FPM behind nginx and the provided test script, I see

2020/08/11 10:51:42 [error] 82419#82419: *2 upstream sent too big header while reading response header from upstream, client: 127.0.0.1, server: _, request: "GET /test.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost"

messages in the error log. After adding

		fastcgi_buffers 16 16k; 
		fastcgi_buffer_size 32k;

to my nginx config, it works fine.

So this looks like a server configuration issue to me. Your web server rejects the massive HTTP header you are sending.
 [2020-08-23 04:23 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 13:01:28 2024 UTC