Bug 1126713 - (CVE-2019-9021) VUL-1: CVE-2019-9021: php5,php7,php53: heap-based buffer over-read in PHAR reading functions in the PHAR extension may allow an
(CVE-2019-9021)
VUL-1: CVE-2019-9021: php5,php7,php53: heap-based buffer over-read in PHAR re...
Status: RESOLVED FIXED
Classification: Novell Products
Product: SUSE Security Incidents
Classification: Novell Products
Component: Incidents
unspecified
Other Other
: P4 - Low : Minor
: ---
Assigned To: Alexandros Toptsoglou
Security Team bot
https://smash.suse.de/issue/225267/
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2019-02-25 06:46 UTC by Marcus Meissner
Modified: 2021-09-14 12:48 UTC (History)
3 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.
Description Marcus Meissner 2019-02-25 06:46:33 UTC
CVE-2019-9021

An issue was discovered in PHP before 5.6.40, 7.x before 7.1.26, 7.2.x before
7.2.14, and 7.3.x before 7.3.1. A heap-based buffer over-read in PHAR reading
functions in the PHAR extension may allow an attacker to read allocated or
unallocated memory past the actual data when trying to parse the file name, a
different vulnerability than CVE-2018-20783. This is related to
phar_detect_phar_fname_ext in ext/phar/phar.c.

References:
http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2019-9021
https://bugs.php.net/bug.php?id=77247
Comment 1 Marcus Meissner 2019-02-25 06:52:25 UTC
QA REPRODUCER:

export USE_ZEND_ALLOC=0
valgrind php -r "new Phar('a/.b');"
Comment 2 Petr Gajdos 2019-03-07 12:51:39 UTC
TW/php7, devel:languages:php:php56/php5: already fixed
Comment 3 Petr Gajdos 2019-03-08 09:00:07 UTC
With the testcase I do not see invalid reads, however there are superfluous conditional jumps in memchr. I have asked reporter of upstream bug for the original testcase, however he had not replied until now.

15/php7, 12/php7, 12/php5

$ USE_ZEND_ALLOC=0 valgrind -q php -r "new Phar('a/.b');"
==11330== Conditional jump or move depends on uninitialised value(s)
==11330==    at 0x4C2D94B: memchr (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==11330==    by 0x6F8077E: phar_detect_phar_fname_ext (phar.c:2022)
==11330==    by 0x6F80FAB: phar_split_fname (phar.c:2229)
==11330==    by 0x6F84884: zim_Phar___construct (phar_object.c:1150)
==11330==    by 0x40F7FA: ZEND_DO_FCALL_SPEC_HANDLER (zend_vm_execute.h:842)
==11330==    by 0x3D5FAA: execute_ex (zend_vm_execute.h:414)
==11330==    by 0x431FE2: zend_execute (zend_vm_execute.h:458)
==11330==    by 0x385636: zend_eval_stringl (zend_execute_API.c:1135)
==11330==    by 0x3857B8: zend_eval_stringl_ex (zend_execute_API.c:1176)
==11330==    by 0x433A7D: do_cli (php_cli.c:1005)
==11330==    by 0x1DE05A: main (php_cli.c:1344)
==11330== 
==11330== Conditional jump or move depends on uninitialised value(s)
==11330==    at 0x4C2D94B: memchr (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==11330==    by 0x6F79F97: phar_detect_phar_fname_ext.constprop.8 (phar.c:2022)
==11330==    by 0x6F7F53D: phar_open_or_create_filename (phar.c:1267)
==11330==    by 0x6F848C9: zim_Phar___construct (phar_object.c:1167)
==11330==    by 0x40F7FA: ZEND_DO_FCALL_SPEC_HANDLER (zend_vm_execute.h:842)
==11330==    by 0x3D5FAA: execute_ex (zend_vm_execute.h:414)
==11330==    by 0x431FE2: zend_execute (zend_vm_execute.h:458)
==11330==    by 0x385636: zend_eval_stringl (zend_execute_API.c:1135)
==11330==    by 0x3857B8: zend_eval_stringl_ex (zend_execute_API.c:1176)
==11330==    by 0x433A7D: do_cli (php_cli.c:1005)
==11330==    by 0x1DE05A: main (php_cli.c:1344)
==11330== 
==11330== Conditional jump or move depends on uninitialised value(s)
==11330==    at 0x4C2D94B: memchr (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==11330==    by 0x6F79F97: phar_detect_phar_fname_ext.constprop.8 (phar.c:2022)
==11330==    by 0x6F7F564: phar_open_or_create_filename (phar.c:1272)
==11330==    by 0x6F848C9: zim_Phar___construct (phar_object.c:1167)
==11330==    by 0x40F7FA: ZEND_DO_FCALL_SPEC_HANDLER (zend_vm_execute.h:842)
==11330==    by 0x3D5FAA: execute_ex (zend_vm_execute.h:414)
==11330==    by 0x431FE2: zend_execute (zend_vm_execute.h:458)
==11330==    by 0x385636: zend_eval_stringl (zend_execute_API.c:1135)
==11330==    by 0x3857B8: zend_eval_stringl_ex (zend_execute_API.c:1176)
==11330==    by 0x433A7D: do_cli (php_cli.c:1005)
==11330==    by 0x1DE05A: main (php_cli.c:1344)
==11330==
$

11sp3/php53:

$ USE_ZEND_ALLOC=0 valgrind -q php -r "new Phar('a/.b');"               
==11420== Invalid read of size 1
==11420==    at 0x4C2C288: memchr (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==11420==    by 0x6C80063: phar_detect_phar_fname_ext (phar.c:2044)
==11420==    by 0x6C803CB: phar_split_fname (phar.c:2292)
==11420==    by 0x6C8E788: zim_Phar___construct (phar_object.c:1184)
==11420==    by 0x5D398D: zend_do_fcall_common_helper_SPEC (zend_vm_execute.h:320)
==11420==    by 0x5AF530: execute (zend_vm_execute.h:107)
==11420==    by 0x575134: zend_eval_stringl (zend_execute_API.c:1198)
==11420==    by 0x5752C8: zend_eval_stringl_ex (zend_execute_API.c:1240)
==11420==    by 0x60EEAC: main (php_cli.c:1228)
==11420==  Address 0x6baac65 is 0 bytes after a block of size 5 alloc'd
==11420==    at 0x4C29F09: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==11420==    by 0x564BCF: _estrndup (zend_alloc.c:2503)
==11420==    by 0x580B02: _zval_copy_ctor_func (zend_variables.c:120)
==11420==    by 0x5AFDCE: ZEND_SEND_VAL_SPEC_CONST_HANDLER (zend_variables.h:45)
==11420==    by 0x5AF530: execute (zend_vm_execute.h:107)
==11420==    by 0x575134: zend_eval_stringl (zend_execute_API.c:1198)
==11420==    by 0x5752C8: zend_eval_stringl_ex (zend_execute_API.c:1240)
==11420==    by 0x60EEAC: main (php_cli.c:1228)
==11420== 
==11420== Invalid read of size 1
==11420==    at 0x4C2C288: memchr (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==11420==    by 0x6C80063: phar_detect_phar_fname_ext (phar.c:2044)
==11420==    by 0x6C84E8E: phar_open_or_create_filename (phar.c:1264)
==11420==    by 0x6C8E7EC: zim_Phar___construct (phar_object.c:1201)
==11420==    by 0x5D398D: zend_do_fcall_common_helper_SPEC (zend_vm_execute.h:320)
==11420==    by 0x5AF530: execute (zend_vm_execute.h:107)
==11420==    by 0x575134: zend_eval_stringl (zend_execute_API.c:1198)
==11420==    by 0x5752C8: zend_eval_stringl_ex (zend_execute_API.c:1240)
==11420==    by 0x60EEAC: main (php_cli.c:1228)
==11420==  Address 0x6baac65 is 0 bytes after a block of size 5 alloc'd
==11420==    at 0x4C29F09: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==11420==    by 0x564BCF: _estrndup (zend_alloc.c:2503)
==11420==    by 0x580B02: _zval_copy_ctor_func (zend_variables.c:120)
==11420==    by 0x5AFDCE: ZEND_SEND_VAL_SPEC_CONST_HANDLER (zend_variables.h:45)
==11420==    by 0x5AF530: execute (zend_vm_execute.h:107)
==11420==    by 0x575134: zend_eval_stringl (zend_execute_API.c:1198)
==11420==    by 0x5752C8: zend_eval_stringl_ex (zend_execute_API.c:1240)
==11420==    by 0x60EEAC: main (php_cli.c:1228)
==11420== 
==11420== Invalid read of size 1
==11420==    at 0x4C2C288: memchr (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==11420==    by 0x6C80063: phar_detect_phar_fname_ext (phar.c:2044)
==11420==    by 0x6C84EB3: phar_open_or_create_filename (phar.c:1269)
==11420==    by 0x6C8E7EC: zim_Phar___construct (phar_object.c:1201)
==11420==    by 0x5D398D: zend_do_fcall_common_helper_SPEC (zend_vm_execute.h:320)
==11420==    by 0x5AF530: execute (zend_vm_execute.h:107)
==11420==    by 0x575134: zend_eval_stringl (zend_execute_API.c:1198)
==11420==    by 0x5752C8: zend_eval_stringl_ex (zend_execute_API.c:1240)
==11420==    by 0x60EEAC: main (php_cli.c:1228)
==11420==  Address 0x6baac65 is 0 bytes after a block of size 5 alloc'd
==11420==    at 0x4C29F09: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==11420==    by 0x564BCF: _estrndup (zend_alloc.c:2503)
==11420==    by 0x580B02: _zval_copy_ctor_func (zend_variables.c:120)
==11420==    by 0x5AFDCE: ZEND_SEND_VAL_SPEC_CONST_HANDLER (zend_variables.h:45)
==11420==    by 0x5AF530: execute (zend_vm_execute.h:107)
==11420==    by 0x575134: zend_eval_stringl (zend_execute_API.c:1198)
==11420==    by 0x5752C8: zend_eval_stringl_ex (zend_execute_API.c:1240)
==11420==    by 0x60EEAC: main (php_cli.c:1228)
==11420==
$

For 15/php7 I get additional, unrelated conditional jumps depending on uninitialized values.

PATCH

http://git.php.net/?p=php-src.git;a=commit;h=48f0f73f75c0059ba5d9b73cb4e5faeeaea49c47

AFTER

$ USE_ZEND_ALLOC=0 valgrind -q php -r "new Phar('a/.b');"
PHP Fatal error:  Uncaught UnexpectedValueException: Cannot create phar 'a/.b', file extension (or combination) not recognised or the directory does not exist in Command line code:1
Stack trace:
#0 Command line code(1): Phar->__construct('a/.b')
#1 {main}
  thrown in Command line code on line 1
$
Comment 4 Petr Gajdos 2019-03-08 09:26:28 UTC
Will submit for: 15/php7, 12/php72, 12/php7, 12/php5, 11sp3/php53.
Comment 5 Petr Gajdos 2019-03-11 21:04:05 UTC
I believe all fixed.
Comment 10 Swamp Workflow Management 2019-04-05 19:19:34 UTC
SUSE-SU-2019:14013-1: An update that fixes 11 vulnerabilities is now available.

Category: security (moderate)
Bug References: 1126711,1126713,1126821,1126823,1127122,1128722,1128883,1128886,1128887,1128889,1128892
CVE References: CVE-2018-20783,CVE-2019-9020,CVE-2019-9021,CVE-2019-9023,CVE-2019-9024,CVE-2019-9637,CVE-2019-9638,CVE-2019-9639,CVE-2019-9640,CVE-2019-9641,CVE-2019-9675
Sources used:
SUSE Linux Enterprise Software Development Kit 11-SP4 (src):    php53-5.3.17-112.58.1
SUSE Linux Enterprise Server 11-SP4 (src):    php53-5.3.17-112.58.1
SUSE Linux Enterprise Point of Sale 11-SP3 (src):    php53-5.3.17-112.58.1
SUSE Linux Enterprise Debuginfo 11-SP4 (src):    php53-5.3.17-112.58.1

*** NOTE: This information is not intended to be used for external
    communication, because this may only be a partial fix.
    If you have questions please reach out to maintenance coordination.
Comment 11 Swamp Workflow Management 2019-04-18 16:12:10 UTC
SUSE-SU-2019:0985-1: An update that fixes 6 vulnerabilities is now available.

Category: security (moderate)
Bug References: 1126711,1126713,1126821,1126823,1127122,1128722
CVE References: CVE-2018-20783,CVE-2019-9020,CVE-2019-9021,CVE-2019-9023,CVE-2019-9024,CVE-2019-9641
Sources used:
SUSE Linux Enterprise Software Development Kit 12-SP4 (src):    php5-5.5.14-109.51.6
SUSE Linux Enterprise Software Development Kit 12-SP3 (src):    php5-5.5.14-109.51.6
SUSE Linux Enterprise Module for Web Scripting 12 (src):    php5-5.5.14-109.51.6

*** NOTE: This information is not intended to be used for external
    communication, because this may only be a partial fix.
    If you have questions please reach out to maintenance coordination.
Comment 12 Swamp Workflow Management 2019-04-23 15:07:11 UTC
openSUSE-SU-2019:1256-1: An update that fixes 6 vulnerabilities is now available.

Category: security (moderate)
Bug References: 1126711,1126713,1126821,1126823,1127122,1128722
CVE References: CVE-2018-20783,CVE-2019-9020,CVE-2019-9021,CVE-2019-9023,CVE-2019-9024,CVE-2019-9641
Sources used:
openSUSE Leap 42.3 (src):    php5-5.5.14-115.1
Comment 14 Swamp Workflow Management 2019-04-29 13:09:26 UTC
openSUSE-SU-2019:1293-1: An update that solves 11 vulnerabilities and has one errata is now available.

Category: security (moderate)
Bug References: 1126711,1126713,1126821,1126823,1127122,1128722,1128883,1128886,1128887,1128889,1128892,1129032
CVE References: CVE-2018-20783,CVE-2019-9020,CVE-2019-9021,CVE-2019-9023,CVE-2019-9024,CVE-2019-9637,CVE-2019-9638,CVE-2019-9639,CVE-2019-9640,CVE-2019-9641,CVE-2019-9675
Sources used:
openSUSE Leap 42.3 (src):    php7-7.0.7-58.1
Comment 16 Swamp Workflow Management 2019-06-11 22:11:21 UTC
SUSE-SU-2019:1461-1: An update that solves 16 vulnerabilities and has two fixes is now available.

Category: security (moderate)
Bug References: 1118832,1119396,1126711,1126713,1126821,1126823,1126827,1127122,1128722,1128883,1128886,1128887,1128889,1128892,1129032,1132837,1132838,1134322
CVE References: CVE-2018-19935,CVE-2018-20783,CVE-2019-11034,CVE-2019-11035,CVE-2019-11036,CVE-2019-9020,CVE-2019-9021,CVE-2019-9022,CVE-2019-9023,CVE-2019-9024,CVE-2019-9637,CVE-2019-9638,CVE-2019-9639,CVE-2019-9640,CVE-2019-9641,CVE-2019-9675
Sources used:
SUSE Linux Enterprise Module for Web Scripting 15 (src):    php7-7.2.5-4.32.1
SUSE Linux Enterprise Module for Packagehub Subpackages 15 (src):    php7-7.2.5-4.32.1
SUSE Linux Enterprise Module for Open Buildservice Development Tools 15 (src):    php7-7.2.5-4.32.1

NOTE: This line indicates an update has been released for the listed product(s). At times this might be only a partial fix. If you have questions please reach out to maintenance coordination.
Comment 19 Swamp Workflow Management 2019-06-18 16:37:47 UTC
openSUSE-SU-2019:1572-1: An update that solves 16 vulnerabilities and has two fixes is now available.

Category: security (moderate)
Bug References: 1118832,1119396,1126711,1126713,1126821,1126823,1126827,1127122,1128722,1128883,1128886,1128887,1128889,1128892,1129032,1132837,1132838,1134322
CVE References: CVE-2018-19935,CVE-2018-20783,CVE-2019-11034,CVE-2019-11035,CVE-2019-11036,CVE-2019-9020,CVE-2019-9021,CVE-2019-9022,CVE-2019-9023,CVE-2019-9024,CVE-2019-9637,CVE-2019-9638,CVE-2019-9639,CVE-2019-9640,CVE-2019-9641,CVE-2019-9675
Sources used:
openSUSE Leap 15.1 (src):    php7-7.2.5-lp151.6.3.1
Comment 20 Swamp Workflow Management 2019-06-18 16:42:57 UTC
openSUSE-SU-2019:1573-1: An update that solves 16 vulnerabilities and has two fixes is now available.

Category: security (moderate)
Bug References: 1118832,1119396,1126711,1126713,1126821,1126823,1126827,1127122,1128722,1128883,1128886,1128887,1128889,1128892,1129032,1132837,1132838,1134322
CVE References: CVE-2018-19935,CVE-2018-20783,CVE-2019-11034,CVE-2019-11035,CVE-2019-11036,CVE-2019-9020,CVE-2019-9021,CVE-2019-9022,CVE-2019-9023,CVE-2019-9024,CVE-2019-9637,CVE-2019-9638,CVE-2019-9639,CVE-2019-9640,CVE-2019-9641,CVE-2019-9675
Sources used:
openSUSE Leap 15.0 (src):    php7-7.2.5-lp150.2.19.1
Comment 21 Marcus Meissner 2019-07-16 06:07:25 UTC
done
Comment 24 OBSbugzilla Bot 2020-05-12 08:00:42 UTC
This is an autogenerated message for OBS integration:
This bug (1126713) was mentioned in
https://build.opensuse.org/request/show/802846 Factory / php7
Comment 25 OBSbugzilla Bot 2020-05-12 14:00:28 UTC
This is an autogenerated message for OBS integration:
This bug (1126713) was mentioned in
https://build.opensuse.org/request/show/802978 Factory / php7
Comment 26 OBSbugzilla Bot 2020-05-13 08:20:25 UTC
This is an autogenerated message for OBS integration:
This bug (1126713) was mentioned in
https://build.opensuse.org/request/show/804946 Factory / php7