Bugzilla – Bug 1127122
VUL-1: CVE-2018-20783: php5,php7,php53: buffer over-read in PHAR reading functions
Last modified: 2023-10-26 10:35:33 UTC
rh#1680545 In PHP before 5.6.39, 7.x before 7.0.33, 7.1.x before 7.1.25, and 7.2.x before 7.2.13, a buffer over-read in PHAR reading functions may allow an attacker to read allocated or unallocated memory past the actual data when trying to parse a .phar file. This is related to phar_parse_pharfile in ext/phar/phar.c. References: https://bugzilla.redhat.com/show_bug.cgi?id=1680545 http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2018-20783 http://people.canonical.com/~ubuntu-security/cve/2018/CVE-2018-20783.html http://php.net/ChangeLog-5.php http://php.net/ChangeLog-7.php https://bugs.php.net/bug.php?id=77143
affected codestreams: - SUSE:SLE-11-SP3:Update - SUSE:SLE-12:Update - SUSE:SLE-15:Update not affected: - SUSE:SLE-10-SP3:Update - SUSE:SLE-11:Update
BEFORE 15/php7, 12/php7, 12/php5, 11sp3/php53 $ USE_ZEND_ALLOC=0 valgrind -q php -d phar.readonly=0 -r "var_dump(new Phar('php-oob4.phar',0,'project.phar'));" ==7995== Invalid read of size 4 ==7995== at 0x6F7B28F: memcpy (string3.h:51) ==7995== by 0x6F7B28F: phar_parse_pharfile (phar.c:971) ==7995== by 0x6F7B28F: phar_open_from_fp.isra.7 (phar.c:1716) ==7995== by 0x6F7EF83: phar_create_or_parse_filename (phar.c:1346) ==7995== by 0x6F7F809: phar_open_or_create_filename (phar.c:1314) ==7995== by 0x6F84879: zim_Phar___construct (phar_object.c:1167) ==7995== by 0x40F7FA: ZEND_DO_FCALL_SPEC_HANDLER (zend_vm_execute.h:842) ==7995== by 0x3D5FAA: execute_ex (zend_vm_execute.h:414) ==7995== by 0x431FE2: zend_execute (zend_vm_execute.h:458) ==7995== by 0x385636: zend_eval_stringl (zend_execute_API.c:1135) ==7995== by 0x3857B8: zend_eval_stringl_ex (zend_execute_API.c:1176) ==7995== by 0x433A7D: do_cli (php_cli.c:1005) ==7995== by 0x1DE05A: main (php_cli.c:1344) ==7995== Address 0x6da7baa is 0 bytes after a block of size 10 alloc'd ==7995== at 0x4C29110: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==7995== by 0x6F7B104: phar_parse_pharfile (phar.c:722) ==7995== by 0x6F7B104: phar_open_from_fp.isra.7 (phar.c:1716) ==7995== by 0x6F7EF83: phar_create_or_parse_filename (phar.c:1346) ==7995== by 0x6F7F809: phar_open_or_create_filename (phar.c:1314) ==7995== by 0x6F84879: zim_Phar___construct (phar_object.c:1167) ==7995== by 0x40F7FA: ZEND_DO_FCALL_SPEC_HANDLER (zend_vm_execute.h:842) ==7995== by 0x3D5FAA: execute_ex (zend_vm_execute.h:414) ==7995== by 0x431FE2: zend_execute (zend_vm_execute.h:458) ==7995== by 0x385636: zend_eval_stringl (zend_execute_API.c:1135) ==7995== by 0x3857B8: zend_eval_stringl_ex (zend_execute_API.c:1176) ==7995== by 0x433A7D: do_cli (php_cli.c:1005) ==7995== by 0x1DE05A: main (php_cli.c:1344) ==7995== PHP Fatal error: Uncaught UnexpectedValueException: internal corruption of phar "/127122/php-oob4.phar" (buffer overrun) in Command line code:1 Stack trace: #0 Command line code(1): Phar->__construct('php-oob4.phar', 0, 'project.phar') #1 {main} thrown in Command line code on line 1 $ PATCH http://git.php.net/?p=php-src.git;a=commit;h=48f0f73f75c0059ba5d9b73cb4e5faeeaea49c47 AFTER $ USE_ZEND_ALLOC=0 valgrind -q "php" "-d" "phar.readonly=0" "-r" "var_dump(new Phar('php-oob4.phar',0,'project.phar'));" PHP Fatal error: Uncaught exception 'UnexpectedValueException' with message 'internal corruption of phar "/127122/php-oob4.phar" (truncated manifest header)' in Command line code:1 Stack trace: #0 Command line code(1): Phar->__construct('php-oob4.phar', 0, 'project.phar') #1 {main} thrown in Command line code on line 1 $
Will submit for: 15/php7, 12/php72, 12/php7, 12/php5, 11sp3/php53
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 $
Apologize, comment 4 was meant for the other php-phar bug, please disregard it.
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
Created attachment 806536 [details] php-oob4.phar QA REPRODUCER: USE_ZEND_ALLOC=0 valgrind php -d phar.readonly=0 -r "var_dump(new Phar('php-oob4.phar',0,'project.phar'));" should not report invalid reads from valgrind
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
released
This is an autogenerated message for OBS integration: This bug (1127122) was mentioned in https://build.opensuse.org/request/show/802846 Factory / php7
This is an autogenerated message for OBS integration: This bug (1127122) was mentioned in https://build.opensuse.org/request/show/802978 Factory / php7
This is an autogenerated message for OBS integration: This bug (1127122) was mentioned in https://build.opensuse.org/request/show/804946 Factory / php7
This is an autogenerated message for OBS integration: This bug (1127122) was mentioned in https://build.opensuse.org/request/show/805287 Factory / php7
This is an autogenerated message for OBS integration: This bug (1127122) was mentioned in https://build.opensuse.org/request/show/1120490 Backports:SLE-15-SP5 / php81