Bug #65602 [Opn->Fbk]: PHP 5.5.x stalls: Allowed memory size exhausted. openssl_x509_parse() problem ?

From: Date: Mon, 15 Jul 2019 17:29:10 +0000
Subject: Bug #65602 [Opn->Fbk]: PHP 5.5.x stalls: Allowed memory size exhausted. openssl_x509_parse() problem ?
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-221794@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=65602&edit=1

 ID:                 65602
 Updated by:         cmb@php.net
 Reported by:        mail at tgries dot de
 Summary:            PHP 5.5.x stalls: Allowed memory size exhausted.
                     openssl_x509_parse() problem ?
-Status:             Open
+Status:             Feedback
 Type:               Bug
 Package:            OpenSSL related
 Operating System:   Linux
 PHP Version:        5.5.3
-Assigned To:        
+Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

I cannot reproduce this with current PHP-7.2.  Can anybody else
reproduce this with a still supported PHP version[1]?

[1] <https://www.php.net/supported-versions.php>


Previous Comments:
------------------------------------------------------------------------
[2016-09-23 14:41:30] php at pzystorm dot de

I have this segfault error with this cert:

-----BEGIN CERTIFICATE-----
MIIFJjCCBA6gAwIBAgIHKAOS9pUMTDANBgkqhkiG9w0BAQsFADCBtDELMAkGA1UE
BhMCVVMxEDAOBgNVBAgTB0FyaXpvbmExEzARBgNVBAcTClNjb3R0c2RhbGUxGjAY
BgNVBAoTEUdvRGFkZHkuY29tLCBJbmMuMS0wKwYDVQQLEyRodHRwOi8vY2VydHMu
Z29kYWRkeS5jb20vcmVwb3NpdG9yeS8xMzAxBgNVBAMTKkdvIERhZGR5IFNlY3Vy
ZSBDZXJ0aWZpY2F0ZSBBdXRob3JpdHkgLSBHMjAeFw0xNDEyMDYwMDEzMThaFw0x
NzEyMTUyMDExMjFaMD0xITAfBgNVBAsTGERvbWFpbiBDb250cm9sIFZhbGlkYXRl
ZDEYMBYGA1UEAwwPKi53b3JkcHJlc3Mub3JnMIIBIjANBgkqhkiG9w0BAQEFAAOC
AQ8AMIIB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0NbW4RP5BcRIjdihfjjLLEfu
sT7KzKWPeb6msjEunKlzEZa9uvmFUz3zCWu9Z0p7QCaudGz9ldJxoOiPxXK2R5qd
T5AJvhH7+WpuxF6RXbjzpkcXOWB2gcidTI/Bw59a90X/ZoJJyaTT2iXP8cYECtwn
Mxo4/P3vJYtE3QFnev7zP+o5CT0gzCmjb9sLOvZE5fRxm+PEefyaFHMebNCElGtC
ZpM3tyeiqyIQK61TeTTSusxnCFjXIDa0tjQ=
-----END CERTIFICATE-----

Just save it in a file (f.ex. test.pem) and call this php code:

<?php
$ssl = openssl_x509_parse(file_get_contents('test.pem'));
print_r($ssl);
?>

Error in the Apache log file is:
[core:notice] [pid 16919] AH00052: child pid 16925 exit signal Segmentation fault (11)

No further debug information availavle, although "LogLevel debug"

------------------------------------------------------------------------
[2014-01-10 17:35:46] nginx-mark at zedwood dot com

The function, openssl_x509_parse() works fine on most certificates.  I think it is getting tripped
up on a certain certificate, perhaps the google cert with 100s of subjectAltNames.  Can you post the
certificate which triggered the out of memory issue, it will help to research the issue if the
behavior is reproducible.

------------------------------------------------------------------------
[2013-09-01 23:08:18] mail at tgries dot de

again, just to make it clear: in most of the cases it works. Stalls only now and then. Webserver is
Apache, and a restart solves the problem immediately, but this is not a solution.

I suppose, there's a bug in PHP or openssl function.

------------------------------------------------------------------------
[2013-09-01 23:05:07] mail at tgries dot de

Description:
------------
I noticed now and then the following problem with the new 5.5.2 and 5.5.3 version, which makes the
PHP stalling in a short script which uses openssl calls to print server certificates.


PHP Fatal error:  Allowed memory size of 209715200 bytes exhausted (tried to allocate 736849521
bytes) in /srv/www-ssl/scripts/MySimpleCertificateViewer/index.php on line 70

line 70: $certArray = openssl_x509_parse( $cp );

It is currently unclear, why this stall happens, but I want to early report this problem to you
developers.

The script is short and available here https://github.com/Wikinaut/MySimpleCertificateViewer
.


Test script:
---------------
The script is short and available here https://github.com/Wikinaut/MySimpleCertificateViewer
.




------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=65602&edit=1


Thread (6 messages)

« previous php.bugs (#221794) next »