An integer overflow vulnerability in php_html_entities() was found, allowing to construct string with length outside of integer range.
Created php tracking bugs for this issue:
Affects: fedora-all [bug 1340745]
php-5.6.22-1.fc22 has been pushed to the Fedora 22 stable repository. If problems still persist, please make note of it in this bug report.
This isn't very practical issue because of the default memory limits set in PHP. To trigger this, attacker needs to be able to provide sufficiently large input (more than 300MB or 350MB depending on flags used when calling htmlspecialchars() function) that would cause the PHP internal function php_escape_html_entities_ex() to generate output of more than 2GB. That's not possible in the default configuration of the Red Hat PHP packages, which limits memory a script can use to 128MB.
Additionally, in PHP versions prior to 5.4, length variables (oldlen, newlen) in php_escape_html_entities_ex() are of type int, while they are size_t in 5.4 and newer. The int variables are casted to size_t when calling emalloc() or erealloc(), leading to attempt to allocate close to SIZE_MAX memory, which fails. Hence in PHP 5.3 and earlier, php_escape_html_entities_ex() can't return string large enough to trigger this flaw.
In affected versions, this can be mitigated by setting proper memory_limit rather than executing scripts without any limit.
This issue has been addressed in the following products:
Red Hat Software Collections for Red Hat Enterprise Linux 6
Red Hat Software Collections for Red Hat Enterprise Linux 6.7 EUS
Red Hat Software Collections for Red Hat Enterprise Linux 7
Red Hat Software Collections for Red Hat Enterprise Linux 7.2 EUS
Red Hat Software Collections for Red Hat Enterprise Linux 7.3 EUS
Via RHSA-2016:2750 https://rhn.redhat.com/errata/RHSA-2016-2750.html