Bug 910659 (CVE-2014-8142) - VUL-0: CVE-2014-8142: php5: NULL pointer dereference in unserialize.c
Summary: VUL-0: CVE-2014-8142: php5: NULL pointer dereference in unserialize.c
Status: RESOLVED FIXED
Alias: CVE-2014-8142
Product: SUSE Security Incidents
Classification: Novell Products
Component: Incidents (show other bugs)
Version: unspecified
Hardware: Other Other
: P3 - Medium : Minor
Target Milestone: ---
Deadline: 2015-04-13
Assignee: Security Team bot
QA Contact: Security Team bot
URL: https://smash.suse.de/issue/111684/
Whiteboard: maint:released:sle10-sp3:60656 maint:...
Keywords:
Depends on: 907519
Blocks:
  Show dependency treegraph
 
Reported: 2014-12-18 12:59 UTC by Alexander Bergmann
Modified: 2020-05-18 11:54 UTC (History)
6 users (show)

See Also:
Found By: Security Response Team
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Comment 1 Swamp Workflow Management 2014-12-18 23:00:58 UTC
bugbot adjusting priority
Comment 2 Petr Gajdos 2014-12-19 07:51:06 UTC
We have to decide first how to resolve bug 907519.
Comment 3 Petr Gajdos 2014-12-30 08:14:33 UTC
Afected down to 10sp3.
Comment 4 Petr Gajdos 2014-12-30 08:15:53 UTC
Test:

<?php 
var_dump(unserialize('a:6:{a:6:{s:3:"322";s:3:"bar";s:3:"bar";s:3:"foo";a:6:{a:6:{s:3:"322";s:3:"bar";s:3:"bar";s:3:"foo";s:3:"bar";a:6:{a:6:{s:3:"322";s:3:"bar";s:3:"bar";s:3:"foo";a:6:{a:6:{s:3:"322";s:3:"bar";s:3:"b22";s:3:"bar";s:3:"bar";s:3:"foo";s:3:"bar";a:6:{a:6:{s:3:"322";s:3:"bar";s:3:"bar";s:3:"foo";s:3:"bar";s:3:"bar";')); 
?>
Comment 5 Petr Gajdos 2014-12-30 08:16:35 UTC
Patch:

--- a/ext/standard/var_unserializer.re
+++ b/ext/standard/var_unserializer.re
@@ -59,7 +59,13 @@ static inline void var_push(php_unserialize_data_t *var_hashx, zval **rval)
 
 PHPAPI void var_push_dtor(php_unserialize_data_t *var_hashx, zval **rval)
 {
-       var_entries *var_hash = (*var_hashx)->last_dtor;
+       var_entries *var_hash;
+
+       if (!var_hashx || !*var_hashx) {
+               return;
+       }
+
+       var_hash = (*var_hashx)->last_dtor;
 #if VAR_ENTRIES_DBG
        fprintf(stderr, "var_push_dtor(%ld): %d\n", var_hash?var_hash->used_slots:-1L, Z_TYPE_PP(rval));
 #endif
Comment 6 Petr Gajdos 2014-12-30 08:17:51 UTC
Factory: fixed trough update to 5.6.4
Comment 7 Petr Gajdos 2014-12-30 15:37:16 UTC
Tested on sle12 and 13.2; patch fixes the problem there.
Comment 8 Petr Gajdos 2015-01-15 12:42:35 UTC
Alexander, this fix is not complete, see CVE-2015-0231. Could you please file another bug?
Comment 9 Petr Gajdos 2015-01-21 07:54:54 UTC
(In reply to Petr Gajdos from comment #8)
> Alexander, this fix is not complete, see CVE-2015-0231. Could you please
> file another bug?

php bug for CVE-2015-0231:
https://bugs.php.net/bug.php?id=68710
Comment 11 Petr Gajdos 2015-01-21 12:04:43 UTC
(In reply to Alexander Bergmann from comment #0)
> PHP NULL pointer dereference in unserialize.c
> 
> http://git.php.net/?p=php-src.git;a=commitdiff;
> h=13f1c276ab72cf1a8a400fd013b9289d0018a340

The CVE-2015-0231 fix forced me to reread php-security@ threads and I have realized that this is not actually correct. This is just fixing another problem exposed by testcase from comment 4.

So we have three issues here, as far as I can tell:

(1) Null ptr deref (CVE not assigned?)
https://bugs.php.net/bug.php?id=68545
http://git.php.net/?p=php-src.git;a=commitdiff;h=13f1c276ab72cf1a8a400fd013b9289d0018a340

(2) CVE-2014-8142:
https://bugs.php.net/bug.php?id=68594
http://git.php.net/?p=php-src.git;a=commitdiff;h=630f9c33c23639de85c3fd306b209b538b73b4c9

(3) CVE-2015-0231:
https://bugs.php.net/bug.php?id=68710
http://git.php.net/?p=php-src.git;a=commitdiff;h=e63f7b47e1937821e75e9862284c3150e1b1d524;hp=fc6aa939f59c9be0febe0fa141629e49541bab8c

Security team, please double check.
Comment 12 Petr Gajdos 2015-01-21 13:27:19 UTC
TESTCASE summary:

(In reply to Petr Gajdos from comment #11)
> (1) Null ptr deref (CVE not assigned?)
see comment 4

> (2) CVE-2014-8142:
<?php

for ($i=4; $i<100; $i++) {

var_dump($i);

$m = new StdClass();

$u = array(1);

$m->aaa = array(1,2,&$u,4,5);
$m->bbb = 1;
$m->ccc = &$u;
$m->ddd = str_repeat("A", $i);

$z = serialize($m);
$z = str_replace("bbb", "aaa", $z);
var_dump($z);
$y = unserialize($z);
var_dump($y);
}
?>

> (3) CVE-2015-0231:
<?php
for ($i=4; $i<100; $i++) {
    $m = new StdClass();

    $u = array(1);

    $m->aaa = array(1,2,&$u,4,5);
    $m->bbb = 1;
    $m->ccc = &$u;
    $m->ddd = str_repeat("A", $i);

    $z = serialize($m);
    $z = str_replace("aaa", "123", $z);
    $z = str_replace("bbb", "123", $z);
    $y = unserialize($z);
    $z = serialize($y);
}
?>

All testcases causes segfault for vulnerable php versions.
Comment 14 Petr Gajdos 2015-01-21 15:34:52 UTC
setting needinfo just for bugzilla testing purposes
Comment 15 Bernhard Wiedemann 2015-01-26 09:00:07 UTC
This is an autogenerated message for OBS integration:
This bug (910659) was mentioned in
https://build.opensuse.org/request/show/282815 Factory / php5
Comment 16 Petr Gajdos 2015-02-02 11:37:17 UTC
Removing needinfo set for testing purposes.
Comment 21 Petr Gajdos 2015-02-09 11:51:05 UTC
Packages submitted.
Comment 23 Swamp Workflow Management 2015-02-11 16:27:05 UTC
An update workflow for this issue was started.
This issue was rated as moderate.
Please submit fixed packages until 2015-02-25.
When done, reassign the bug to security-team@suse.de.
https://swamp.suse.de/webswamp/wf/60653
Comment 24 Swamp Workflow Management 2015-02-19 11:05:06 UTC
openSUSE-SU-2015:0325-1: An update that fixes 5 vulnerabilities is now available.

Category: security (moderate)
Bug References: 907519,910659,911663,911664,914690
CVE References: CVE-2014-8142,CVE-2014-9426,CVE-2014-9427,CVE-2015-0231,CVE-2015-0232
Sources used:
openSUSE 13.2 (src):    php5-5.6.1-8.1
openSUSE 13.1 (src):    php5-5.4.20-38.1
Comment 25 Swamp Workflow Management 2015-02-24 10:05:57 UTC
SUSE-SU-2015:0365-1: An update that fixes four vulnerabilities is now available.

Category: security (important)
Bug References: 907519,910659,911664,914690
CVE References: CVE-2014-8142,CVE-2014-9427,CVE-2015-0231,CVE-2015-0232
Sources used:
SUSE Linux Enterprise Software Development Kit 12 (src):    php5-5.5.14-11.3
SUSE Linux Enterprise Module for Web Scripting 12 (src):    php5-5.5.14-11.3
Comment 26 Swamp Workflow Management 2015-02-25 07:08:34 UTC
SUSE-SU-2015:0370-1: An update that fixes three vulnerabilities is now available.

Category: security (moderate)
Bug References: 907519,910659,914690
CVE References: CVE-2014-8142,CVE-2015-0231,CVE-2015-0232
Sources used:
SUSE Linux Enterprise Software Development Kit 11 SP3 (src):    php53-5.3.17-0.33.1
SUSE Linux Enterprise Server 11 SP3 for VMware (src):    php53-5.3.17-0.33.1
SUSE Linux Enterprise Server 11 SP3 (src):    php53-5.3.17-0.33.1
Comment 28 Swamp Workflow Management 2015-03-30 15:09:08 UTC
An update workflow for this issue was started.
This issue was rated as moderate.
Please submit fixed packages until 2015-04-13.
When done, reassign the bug to security-team@suse.de.
https://swamp.suse.de/webswamp/wf/61384
Comment 29 Swamp Workflow Management 2016-06-21 11:11:42 UTC
SUSE-SU-2016:1638-1: An update that fixes 85 vulnerabilities is now available.

Category: security (important)
Bug References: 884986,884987,884989,884990,884991,884992,885961,886059,886060,893849,893853,902357,902360,902368,910659,914690,917150,918768,919080,921950,922451,922452,923945,924972,925109,928506,928511,931421,931769,931772,931776,933227,935074,935224,935226,935227,935229,935232,935234,935274,935275,938719,938721,942291,942296,945412,945428,949961,968284,969821,971611,971612,971912,973351,973792,976996,976997,977003,977005,977991,977994,978827,978828,978829,978830,980366,980373,980375,981050,982010,982011,982012,982013,982162
CVE References: CVE-2004-1019,CVE-2006-7243,CVE-2014-0207,CVE-2014-3478,CVE-2014-3479,CVE-2014-3480,CVE-2014-3487,CVE-2014-3515,CVE-2014-3597,CVE-2014-3668,CVE-2014-3669,CVE-2014-3670,CVE-2014-4049,CVE-2014-4670,CVE-2014-4698,CVE-2014-4721,CVE-2014-5459,CVE-2014-8142,CVE-2014-9652,CVE-2014-9705,CVE-2014-9709,CVE-2014-9767,CVE-2015-0231,CVE-2015-0232,CVE-2015-0273,CVE-2015-1352,CVE-2015-2301,CVE-2015-2305,CVE-2015-2783,CVE-2015-2787,CVE-2015-3152,CVE-2015-3329,CVE-2015-3411,CVE-2015-3412,CVE-2015-4021,CVE-2015-4022,CVE-2015-4024,CVE-2015-4026,CVE-2015-4116,CVE-2015-4148,CVE-2015-4598,CVE-2015-4599,CVE-2015-4600,CVE-2015-4601,CVE-2015-4602,CVE-2015-4603,CVE-2015-4643,CVE-2015-4644,CVE-2015-5161,CVE-2015-5589,CVE-2015-5590,CVE-2015-6831,CVE-2015-6833,CVE-2015-6836,CVE-2015-6837,CVE-2015-6838,CVE-2015-7803,CVE-2015-8835,CVE-2015-8838,CVE-2015-8866,CVE-2015-8867,CVE-2015-8873,CVE-2015-8874,CVE-2015-8879,CVE-2016-2554,CVE-2016-3141,CVE-2016-3142,CVE-2016-3185,CVE-2016-4070,CVE-2016-4073,CVE-2016-4342,CVE-2016-4346,CVE-2016-4537,CVE-2016-4538,CVE-2016-4539,CVE-2016-4540,CVE-2016-4541,CVE-2016-4542,CVE-2016-4543,CVE-2016-4544,CVE-2016-5093,CVE-2016-5094,CVE-2016-5095,CVE-2016-5096,CVE-2016-5114
Sources used:
SUSE Linux Enterprise Server 11-SP2-LTSS (src):    php53-5.3.17-47.1