Multiple Vulnerabilities in PHP Could Allow for Arbitrary Code Execution

ITS Advisory Number: 
2018-003
Date(s) Issued: 
Tuesday, January 9, 2018
Subject: 
Multiple Vulnerabilities in PHP Could Allow for Arbitrary Code Execution
Overview: 

Multiple vulnerabilities have been discovered in PHP, the most severe of which could allow an attacker to execute arbitrary code. PHP is a programming language originally designed for use in web-based applications with HTML content. PHP supports a wide variety of platforms and is used by numerous web-based software applications. Successfully exploiting the most severe of these vulnerabilities could allow for arbitrary code execution in the context of the affected application. Depending on the privileges associated with the application, an attacker could install programs; view, change, or delete data; or create new accounts with full user rights. Failed exploitation could result in a denial-of-service condition.

THREAT INTELLIGENCE:

There are currently no reports of these vulnerabilities being exploited in the wild.

Systems Affected: 
  • PHP 7.2 prior to 7.2.1

  • PHP 7.1 prior to 7.1.13

  • PHP 7.0 prior to 7.0.27

  • PHP 5.0 prior to 5.6.33

RISK
GOVERNMENT
Large and medium government entities: 
High
Small government entities: 
High
BUSINESS
Large and medium business entities: 
High
Small business entities: 
High
Home Users: 
Low
Description: 

Multiple vulnerabilities have been discovered in PHP, the most severe of which could allow an attacker to execute arbitrary code. Details of these vulnerabilities are as below:

Version 7.2.1:

  • Bug #64938 (libxml_disable_entity_loader setting is shared between requests).
  • Bug #73124 (php_ini_scanned_files() not reporting correctly).
  • Bug #73830 (Directory does not exist).
  • Bug #74183 (preg_last_error not returning error code after error).
  • Bug #74782 (remove file name from output to avoid XSS).
  • Bug #74862 (Unable to clone instance when private __clone defined).
  • Bug #75074 (php-process crash when is_file() is used with strings longer 260 chars).
  • Bug #75384 (PHP seems incompatible with OneDrive files on demand).
  • Bug #75409 (accept EFAULT in addition to ENOSYS as indicator that getrandom() is missing).
  • Bug #75511 (fread not free unused buffer).
  • Bug #75514 (mt_rand returns value outside [$min,$max]+ on 32-bit) (Remi).
  • Bug #75525 (Access Violation in vcruntime140.dll).
  • Bug #75535 (Inappropriately parsing HTTP response leads to PHP segment fault).
  • Bug #75540 (Segfault with libzip 1.3.1).
  • Bug #75556 (Invalid opcode 138/1/1).
  • Bug #75570 ("Narrowing occurred during type inference" error).
  • Bug #75571 (Potential infinite loop in gdImageCreateFromGifCtx).
  • Bug #75573 (Segmentation fault in 7.1.12 and 7.0.26).
  • Bug #75574 (putenv does not work properly if parameter contains non-ASCII unicode character).
  • Bug #75579 (Interned strings buffer overflow may cause crash).
  • Bug #75608 ("Narrowing occurred during type inference" error).

Version 7.1.13:

  • Bug #60471 (Random "Invalid request (unexpected EOF)" using a router script).
  • Bug #64938 (libxml_disable_entity_loader setting is shared between requests).
  • Bug #73124 (php_ini_scanned_files() not reporting correctly).
  • Bug #73830 (Directory does not exist).
  • Bug #74183 (preg_last_error not returning error code after error).
  • Bug #74782 (remove file name from output to avoid XSS).
  • Bug #74862 (Unable to clone instance when private __clone defined).
  • Bug #75074 (php-process crash when is_file() is used with strings longer 260 chars).
  • Bug #75384 (PHP seems incompatible with OneDrive files on demand).
  • Bug #75409 (accept EFAULT in addition to ENOSYS as indicator that getrandom() is missing).
  • Bug #75511 (fread not free unused buffer).
  • Bug #75514 (mt_rand returns value outside [$min,$max]+ on 32-bit) (Remi).
  • Bug #75535 (Inappropriately parsing HTTP response leads to PHP segment fault).
  • Bug #75540 (Segfault with libzip 1.3.1).
  • Bug #75570 ("Narrowing occurred during type inference" error).
  • Bug #75571 (Potential infinite loop in gdImageCreateFromGifCtx).
  • Bug #75573 (Segmentation fault in 7.1.12 and 7.0.26).
  • Bug #75574 (putenv does not work properly if parameter contains non-ASCII unicode character).
  • Bug #75579 (Interned strings buffer overflow may cause crash).
  • Bug #75608 ("Narrowing occurred during type inference" error).

Version 7.0.27:

  • Bug #60471 (Random "Invalid request (unexpected EOF)" using a router script).
  • Bug #64938 (libxml_disable_entity_loader setting is shared between requests).
  • Bug #74183 (preg_last_error not returning error code after error).
  • Bug #74782 (Reflected XSS in .phar 404 page).
  • Bug #75384 (PHP seems incompatible with OneDrive files on demand).
  • Bug #75409 (accept EFAULT in addition to ENOSYS as indicator that getrandom() is missing).
  • Bug #75535 (Inappropriately parsing HTTP response leads to PHP segment fault).
  • Bug #75540 (Segfault with libzip 1.3.1).
  • Bug #75571 (Potential infinite loop in gdImageCreateFromGifCtx).
  • Bug #75573 (Segmentation fault in 7.1.12 and 7.0.26).
  • Bug #75579 (Interned strings buffer overflow may cause crash). 

Version 5.6.33:

  • Bug #74782 (Reflected XSS in .phar 404 page).
  • Bug #75571 (Potential infinite loop in gdImageCreateFromGifCtx).

Successfully exploiting the most severe of these vulnerabilities could allow for arbitrary code execution in the context of the affected application. Depending on the privileges associated with the application, an attacker could install programs; view, change, or delete data; or create new accounts with full user rights. Failed exploitation could result in a denial-of-service condition.

Actions: 
  • Verify no unauthorized system modifications have occurred on system before applying patch.

  • After appropriate testing, immediately upgrade to the latest version of PHP.

  • Apply the principle of Least Privilege to all systems and services.

  • Remind users not to visit websites or follow links provided by unknown or untrusted sources.

References: 

NOTE: Visiting these links may trigger an IDS signature match for a Possible Encrypted Webshell Download. This is a false positive alert that is matching content on the pages below.



PHP:

http://php.net/ChangeLog-7.php#7.2.1

http://php.net/ChangeLog-7.php#7.1.13

http://php.net/ChangeLog-7.php#7.0.27

http://php.net/ChangeLog-5.php#5.6.33