GHSA-6363-v5m4-fvq3

Suggest an improvement
Source
https://github.com/advisories/GHSA-6363-v5m4-fvq3
Import Source
https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2024/04/GHSA-6363-v5m4-fvq3/GHSA-6363-v5m4-fvq3.json
JSON Data
https://api.osv.dev/v1/vulns/GHSA-6363-v5m4-fvq3
Aliases
  • CVE-2024-29800
Published
2024-04-12T15:15:46Z
Modified
2024-04-18T16:49:10.797058Z
Severity
  • 8.0 (High) CVSS_V3 - CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:C/C:H/I:H/A:H CVSS Calculator
Summary
timber/timber vulnerable to Deserialization of Untrusted Data
Details

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.

References

Affected packages

Packagist / timber/timber

Package

Name
timber/timber
Purl
pkg:composer/timber/timber

Affected ranges

Type
ECOSYSTEM
Events
Introduced
2.0.0
Fixed
2.1.0

Affected versions

2.*

2.0.0

Packagist / timber/timber

Package

Name
timber/timber
Purl
pkg:composer/timber/timber

Affected ranges

Type
ECOSYSTEM
Events
Introduced
1.24.0
Fixed
1.24.1

Affected versions

1.*

1.24.0

Packagist / timber/timber

Package

Name
timber/timber
Purl
pkg:composer/timber/timber

Affected ranges

Type
ECOSYSTEM
Events
Introduced
0.16.6
Fixed
1.23.1

Affected versions

0.*

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

v1.*

v1.0-rc.1

1.*

1.0-rc2
1.0.0-rc3
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.7.1
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-beta
1.3.0-rc1
1.3.0-rc2
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