Bugzilla – Bug 1126713
VUL-1: CVE-2019-9021: php5,php7,php53: heap-based buffer over-read in PHAR reading functions in the PHAR extension may allow an
Last modified: 2023-10-26 10:35:28 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
QA REPRODUCER: export USE_ZEND_ALLOC=0 valgrind php -r "new Phar('a/.b');"
TW/php7, devel:languages:php:php56/php5: already fixed
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 $
Will submit for: 15/php7, 12/php72, 12/php7, 12/php5, 11sp3/php53.
I believe all fixed.
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.
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.
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
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
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.
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
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
done
This is an autogenerated message for OBS integration: This bug (1126713) was mentioned in https://build.opensuse.org/request/show/802846 Factory / php7
This is an autogenerated message for OBS integration: This bug (1126713) was mentioned in https://build.opensuse.org/request/show/802978 Factory / php7
This is an autogenerated message for OBS integration: This bug (1126713) was mentioned in https://build.opensuse.org/request/show/804946 Factory / php7
This is an autogenerated message for OBS integration: This bug (1126713) was mentioned in https://build.opensuse.org/request/show/1120490 Backports:SLE-15-SP5 / php81