Ecosyste.ms: Advisories

An open API service providing security vulnerability metadata for many open source software ecosystems.

Security Advisories: GSA_kwCzR0hTQS02MzYzLXY1bTQtZnZxM84AA68U

timber/timber vulnerable to Deserialization of Untrusted Data

Summary

Timber is vulnerable to PHAR deserialization due to a lack of checking the input before passing it into the file_exists() function. If an attacker can upload files of any type to the server, he can pass in the phar:// protocol to unserialize the uploaded file and instantiate arbitrary PHP objects. This can lead to remote code execution especially when Timber is used with frameworks with documented POP chains like Wordpress/ vulnerable developer code.

Details

The vulnerability lies in the run function within the toJpg.php file. The two parameters passed into it are not checked or sanitized, hence an attacker could potentially inject malicious input leading to Deserialization of Untrusted Data, allowing for remote code execution:
image

PoC

Setup the following code in /var/www/html: vuln.php represents our use of Timber functions and phar-poc.php represents code with a vulnerable POP chain.
image
image
As an attacker, we generate our PHAR payload using the following exploit script:
image
Generate with:
image
then change extension file from .phar to valid extension as svg,jpg,...
image
and execute vuln.php with php vuln.php, you should see whoami being executed:
image
image

Impact

This vulnerability is capable of remote code execution if Timber is used with frameworks or developer code with vulnerable POP chains.

Recommended Fix

Filter the phar:// protocol.

Permalink: https://github.com/advisories/GHSA-6363-v5m4-fvq3
JSON: https://advisories.ecosyste.ms/api/v1/advisories/GSA_kwCzR0hTQS02MzYzLXY1bTQtZnZxM84AA68U
Source: GitHub Advisory Database
Origin: Unspecified
Severity: High
Classification: General
Published: about 1 month ago
Updated: about 1 month ago


CVSS Score: 8.1
CVSS vector: CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:C/C:H/I:H/A:H

Identifiers: GHSA-6363-v5m4-fvq3, CVE-2024-29800
References: Repository: https://github.com/timber/timber
Blast Radius: 21.6

Affected Packages

packagist:timber/timber
Dependent packages: 104
Dependent repositories: 464
Downloads: 2,064,988 total
Affected Version Ranges: >= 0.16.6, < 1.23.1, = 1.24.0, = 2.0.0
Fixed in: 1.23.1, 1.24.1, 2.1.0
All affected versions: 0.16.6, 0.16.8, 0.17.0, 0.17.2, 0.18.0, 0.18.1, 0.19.0, 0.19.1, 0.19.2, 0.20.0, 0.20.1, 0.20.2, 0.20.3, 0.20.4, 0.20.5, 0.20.6, 0.20.7, 0.20.8, 0.20.9, 0.20.10, 0.21.0, 0.21.2, 0.21.3, 0.21.4, 0.21.5, 0.21.6, 0.21.7, 0.21.8, 0.21.9, 0.21.10, 0.22.0, 0.22.1, 0.22.2, 0.22.3, 0.22.4, 0.22.5, 0.22.6, 1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4, 1.0.5, 1.1.0, 1.1.1, 1.1.2, 1.1.3, 1.1.4, 1.1.5, 1.1.6, 1.1.7, 1.1.8, 1.1.9, 1.1.10, 1.1.11, 1.1.12, 1.2.0, 1.2.1, 1.2.2, 1.2.3, 1.2.4, 1.3.0, 1.3.1, 1.3.2, 1.3.3, 1.3.4, 1.4.0, 1.4.1, 1.5.0, 1.5.1, 1.5.2, 1.6.0, 1.7.0, 1.7.1, 1.8.0, 1.8.1, 1.8.2, 1.8.3, 1.8.4, 1.9.0, 1.9.1, 1.9.2, 1.9.3, 1.9.4, 1.9.5, 1.10.0, 1.10.1, 1.11.0, 1.12.0, 1.12.1, 1.13.0, 1.14.0, 1.15.0, 1.15.1, 1.15.2, 1.16.0, 1.17.0, 1.18.0, 1.18.1, 1.18.2, 1.19.0, 1.19.1, 1.19.2, 1.20.0, 1.21.0, 1.22.0, 1.22.1, 1.23.0, 1.24.0, 2.0.0
All unaffected versions: 1.23.1, 1.24.1, 2.1.0, 2.2.0