Bug 1260683 - (CVE-2015-6836) CVE-2015-6836 php: SOAP serialize_function_call() type confusion
CVE-2015-6836 php: SOAP serialize_function_call() type confusion
Status: CLOSED WONTFIX
Product: Security Response
Classification: Other
Component: vulnerability (Show other bugs)
unspecified
All Linux
low Severity low
: ---
: ---
Assigned To: Red Hat Product Security
impact=low,public=20150829,reported=2...
: Security
Depends On: 1260684 1305854 1305855
Blocks: 1260756 1306180
  Show dependency treegraph
 
Reported: 2015-09-07 08:49 EDT by Adam Mariš
Modified: 2016-03-15 16:57 EDT (History)
19 users (show)

See Also:
Fixed In Version: php 5.4.45, php 5.5.29, php 5.6.13
Doc Type: Bug Fix
Doc Text:
A flaw was discovered in the way PHP performed object unserialization. Specially crafted input processed by the unserialize() function could cause a PHP application to crash or, possibly, execute arbitrary code.
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-10-09 17:18:08 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Adam Mariš 2015-09-07 08:49:34 EDT
A type confusion occurs within SOAP serialize_function_call due to an insufficient validation of the headers field. In the SoapClient's __call method, the verify_soap_headers_array check is applied only to headers retrieved from zend_parse_parameters; problem is that a few lines later, soap_headers could be updated or even replaced with values from the __default_headers object fields. 

Vulnerable code:

if (zend_hash_find(Z_OBJPROP_P(this_ptr), "__default_headers", sizeof("__default_headers"), (void **) &tmp) == SUCCESS && Z_TYPE_PP(tmp) == IS_ARRAY) {
2913        HashTable *default_headers = Z_ARRVAL_P(*tmp);
2914        if (soap_headers) {
2915            if (!free_soap_headers) {
2916                HashTable *t =  emalloc(sizeof(HashTable));
2917                zend_hash_init(t, 0, NULL, ZVAL_PTR_DTOR, 0);
2918                zend_hash_copy(t, soap_headers, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *));
2919                soap_headers = t;
2920                free_soap_headers = 1;
2921            }
2922            zend_hash_internal_pointer_reset(default_headers);
2923            while (zend_hash_get_current_data(default_headers, (void**)&tmp) == SUCCESS) {
2924                Z_ADDREF_PP(tmp);
2925                zend_hash_next_index_insert(soap_headers, tmp, sizeof(zval *), NULL);
2926                zend_hash_move_forward(default_headers);
2927            }
2928        } else {
2929            soap_headers = Z_ARRVAL_P(*tmp);
2930            free_soap_headers = 0;
2931        }

In such case, the soap_headers array is no longer assured to be holding Objects only, thus leading to a type confusion when serialize_function_call will try to access its elements through

4351    HashTable *ht = Z_OBJPROP_PP(header);

Upstream report:

https://bugs.php.net/bug.php?id=70388

Upstream patch:

http://git.php.net/?p=php-src.git;a=commitdiff;h=e201f01ac17243a1e5fb6a3911ed8e21b1619ac1
Comment 1 Adam Mariš 2015-09-07 08:50:04 EDT
Created php tracking bugs for this issue:

Affects: fedora-all [bug 1260684]
Comment 2 Adam Mariš 2015-09-09 04:43:11 EDT
CVE assignment:

http://seclists.org/oss-sec/2015/q3/524
Comment 3 Fedora Update System 2015-09-14 18:19:43 EDT
php-5.6.13-1.fc21 has been pushed to the Fedora 21 stable repository. If problems still persist, please make note of it in this bug report.
Comment 4 Fedora Update System 2015-09-14 19:18:43 EDT
php-5.6.13-1.fc22 has been pushed to the Fedora 22 stable repository. If problems still persist, please make note of it in this bug report.
Comment 5 Fedora Update System 2015-09-18 14:41:11 EDT
php-5.6.13-1.fc23 has been pushed to the Fedora 23 stable repository. If problems still persist, please make note of it in this bug report.
Comment 6 Tomas Hoger 2015-10-09 16:46:33 EDT
This issue happens when untrusted input is unserialized.  Doing so it documented as being unsafe:

  http://php.net/manual/en/function.unserialize.php

  Do not pass untrusted user input to unserialize(). Unserialization can
  result in code being loaded and executed due to object instantiation and
  autoloading, and a malicious user may be able to exploit this. Use a safe,
  standard data interchange format such as JSON (via json_decode() and
  json_encode()) if you need to pass serialized data to the user.
Comment 7 Tomas Hoger 2015-10-09 16:48:54 EDT
Affected code is part of the SOAP extension.  In Red Hat products, this extension is packaged separately in the php-soap subpackages.  Systems without php-soap installed can not be affected by this issue.  Removal of the package can be used to mitigate the issue on systems that do not require SOAP extension.
Comment 8 Tomas Hoger 2015-10-09 17:18:08 EDT
This issue affects PHP packages in Red Hat Enterprise Linux 5, 6 and 7, and Red Hat Software Collections.  As it is triggered by unserializing untrusted inputs, which is documented as being unsafe, there is currently no plan to backport the fix.  Future product updates may correct this issue if they rebase PHP packages to newer upstream version.

Statement:

Red Hat Product Security has rated this issue as having Low security impact. This issue is not currently planned to be addressed in future updates. For additional information, refer to the Issue Severity Classification: https://access.redhat.com/security/updates/classification/.
Comment 11 errata-xmlrpc 2016-03-15 16:57:38 EDT
This issue has been addressed in the following products:

  Red Hat Software Collections for Red Hat Enterprise Linux 7.1 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 6.6 EUS
  Red Hat Software Collections for Red Hat Enterprise Linux 6.7 EUS
  Red Hat Software Collections for Red Hat Enterprise Linux 6

Via RHSA-2016:0457 https://rhn.redhat.com/errata/RHSA-2016-0457.html

Note You need to log in before you can comment on or make changes to this bug.