Phar Vulnerabilities Patched in Drupal, TYPO3
Updates released this week for the Drupal and TYPO3 open source content management systems (CMSs) patch vulnerabilities related to how Phar archives are handled.
The Phar (PHP Archive) package format enables developers to place all the files of a PHP application inside a single archive.
While the Phar format is highly useful, researcher Sam Thomas showed last year that it can also be abused for insecure deserialization — via the Phar stream wrapper— and arbitrary code execution by disguising malicious Phar files as text or image files. Stream wrappers are used by PHP to implement complex file handling functionality.
The security hole was addressed by TYPO3 developers a month after disclosure by introducing a Phar stream wrapper interceptor designed to ensure that Phar archives actually have a .phar extension and check Phar file metadata for potentially insecure serialized objects.
However, researchers have since discovered that the protection provided by the Phar stream wrapper interceptor, which has been released as open source, can be bypassed. A total of three bypass methods have been identified: one disclosed in October 2018 and two made public this week.
This means malicious actors could still upload specially crafted Phar files and possibly execute arbitrary code.
TYPO3 developers said the vulnerabilities affect versions 2.0.0-2.1.0 and 3.0.0-3.1.0 of the stream wrapper package and they have been addressed with the release of versions 3.1.1 (for PHP 7.0 and later) and 2.1.1 (for PHP 5.3 and later).
One of the bypass methods, which involves a path traversal issue, has also been found to impact Drupal, which also uses the TYPO3 interceptor. Drupal developers have classified the flaw as “moderately critical,” with a NIST Common Misuse Scoring System score of 14 out of 25, and patched it with the release of versions 7.67, 8.6.16 and 8.7.1.
This is not the first time Drupal has released updates designed to prevent attacks involving Phar files. In January, developers announced that .phar had been added to the list of dangerous extensions, and that the Phar stream wrapper had been disabled by default for Drupal 7 websites using versions of PHP prior to 5.3.2 to eliminate the risks highlighted by Thomas and a member of the Drupal security team.