CVE-2024-29800: Timber/timber Timber/timber Vulnerable To Deserialization Of Vulnerability

HIGH
Advisory Identifier: GHSA-6363-v5m4-fvq3
CVSS 8.0
CWE-502 CWE-73
Published
Advisory Summary

CVE-2024-29800 is a HIGH (CVSS 8.0) timber/timber vulnerable to deserialization of vulnerability (CWE-502: Deserialization of Untrusted Data) affecting Timber/timber libraries in the Packagist ecosystem. The issue involves timber/timber vulnerable to deserialization of untrusted data. Remediation is available by upgrading affected packages to version 2.1.0, 1.24.1, 1.23.1.

CVE-2024-29800 at a Glance

CVE Identifier CVE-2024-29800
GHSA Identifier GHSA-6363-v5m4-fvq3
Severity HIGH
CVSS v3.1 Base Score 8.0
CWE Classification CWE-502: Deserialization of Untrusted Data
Affected Product Timber/timber
Package Ecosystem Packagist
Published Date
Last Updated

Security Impact

CVSS: 8.0

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:C/C:H/I:H/A:H).

Attack Vector Network (AV:N)
Attack Complexity High (AC:H)
Privileges Required High (PR:H)
User Interaction None (UI:N)
Scope Changed (S:C)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2024-29800

To remediate this vulnerability, upgrade all affected Timber/timber dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

timber/timber fixed: 2.1.0
Upgrade timber/timber to 2.1.0
timber/timber fixed: 1.24.1
Upgrade timber/timber to 1.24.1
timber/timber fixed: 1.23.1
Upgrade timber/timber to 1.23.1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for timber/timber

How to Check if You Are Affected

To determine whether your application is affected by CVE-2024-29800, inspect your project dependencies for Timber/timber:

inspect dependencies for timber/timber

Analyze the terminal output to locate any version of Timber/timber in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.1.0), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-502: Deserialization of Untrusted Data, where the product deserializes untrusted data without sufficiently ensuring that the resulting data will be valid. In Timber/timber, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### 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](https://github.com/timber/timber/assets/89630690/bcd6d031-33c6-4cc5-96b7-b72f0cf0e26c) ### 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](https://github.com/timber/timber/assets/89630690/967f0a16-3b7e-4b58-84cb-c1dee3291339) ![image](https://github.com/timber/timber/assets/89630690/78bb98cf-0cd2-4635-aa01-a1eea571d0fc) As an attacker, we generate our PHAR payload using the following exploit script: ![image](https://github.com/timber/timber/assets/89630690/d823e76a-fb07-468e-aed1-97b304d53ee5) Generate with: ![image](https://github.com/timber/timber/assets/89630690/d3d57333-a113-468a-8b27-dc6bc1fca4e7) then change extension file from .phar to valid extension as svg,jpg,... ![image](https://github.com/timber/timber/assets/89630690/c4fdbd25-e828-4408-9feb-168f2e301d7a) and execute vuln.php with php vuln.php, you should see whoami being executed: ![image](https://github.com/timber/timber/assets/89630690/e341de8d-555c-4390-86a1-469b11cf0ffc) ![image](https://github.com/timber/timber/assets/89630690/17afdb95-10ed-4c52-a93d-95eb1f60a146) ### 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.

CVE-2024-29800 Affected Timber/timber Versions

3 component(s)
Fixed Versions:
2.1.01.24.11.23.1
Product / Package Ecosystem Affected Versions Fixed Version
timber/timber
Packagist
≥ 2.0.0
< 2.1.0
All 1 versions
2.0.0
2.1.0
timber/timber
Packagist
≥ 1.24.0
< 1.24.1
All 1 versions
1.24.0
1.24.1
timber/timber
Packagist
≥ 0.16.6
< 1.23.1
1.23.1

References

Frequently Asked Questions

What is CVE-2024-29800?
CVE-2024-29800 is a security vulnerability in Timber/timber involving timber/timber vulnerable to Deserialization of Untrusted Data under CWE-502: Deserialization of Untrusted Data.
Which Timber/timber versions are affected?
Affected versions include releases prior to 2.1.0, 1.24.1, 1.23.1 across affected packages: timber/timber.
What version fixes CVE-2024-29800?
Upgrading to 2.1.0, 1.24.1, 1.23.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is timber/timber affected?
Yes, timber/timber is affected in releases prior to 2.1.0, 1.24.1, 1.23.1. Upgrade your dependency to 2.1.0, 1.24.1, 1.23.1 or later.
What is the CVSS score of CVE-2024-29800?
CVE-2024-29800 has a CVSS v3.1 base score of 8.0 (HIGH) with vector string CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:C/C:H/I:H/A:H.
What CWE is associated with CVE-2024-29800?
CVE-2024-29800 is classified under CWE-502: Deserialization of Untrusted Data (The product deserializes untrusted data without sufficiently ensuring that the resulting data will be valid.).
How can I check Packagist dependencies for CVE-2024-29800?
Run the dependency tree command: 'inspect dependencies for timber/timber'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-6363-v5m4-fvq3",
  "modified" : "2024-04-18T16:32:20Z",
  "published" : "2024-04-12T15:15:46Z",
  "aliases" : [ "CVE-2024-29800" ],
  "summary" : "timber/timber vulnerable to Deserialization of Untrusted Data",
  "details" : "### Summary\nTimber 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.\n\n### Details\nThe 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:\n![image](https://github.com/timber/timber/assets/89630690/bcd6d031-33c6-4cc5-96b7-b72f0cf0e26c)\n\n### PoC\nSetup 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.\n![image](https://github.com/timber/timber/assets/89630690/967f0a16-3b7e-4b58-84cb-c1dee3291339)\n![image](https://github.com/timber/timber/assets/89630690/78bb98cf-0cd2-4635-aa01-a1eea571d0fc)\nAs an attacker, we generate our PHAR payload using the following exploit script:\n![image](https://github.com/timber/timber/assets/89630690/d823e76a-fb07-468e-aed1-97b304d53ee5)\nGenerate with:\n![image](https://github.com/timber/timber/assets/89630690/d3d57333-a113-468a-8b27-dc6bc1fca4e7)\nthen change extension file from .phar to valid extension as svg,jpg,...\n![image](https://github.com/timber/timber/assets/89630690/c4fdbd25-e828-4408-9feb-168f2e301d7a)\nand execute vuln.php with php vuln.php, you should see whoami being executed:\n![image](https://github.com/timber/timber/assets/89630690/e341de8d-555c-4390-86a1-469b11cf0ffc)\n![image](https://github.com/timber/timber/assets/89630690/17afdb95-10ed-4c52-a93d-95eb1f60a146)\n\n### Impact\nThis vulnerability is capable of remote code execution if Timber is used with frameworks or developer code with vulnerable POP chains.\n\n### Recommended Fix\nFilter the phar:// protocol.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:C/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "timber/timber"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "2.0.0"
      }, {
        "fixed" : "2.1.0"
      } ]
    } ],
    "versions" : [ "2.0.0" ]
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "timber/timber"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "1.24.0"
      }, {
        "fixed" : "1.24.1"
      } ]
    } ],
    "versions" : [ "1.24.0" ]
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "timber/timber"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0.16.6"
      }, {
        "fixed" : "1.23.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/timber/timber/security/advisories/GHSA-6363-v5m4-fvq3"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/timber/timber/issues/2971"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/timber/timber/commit/13c6b0f60346304f2eed4da1e0bb51566518de4a"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/FriendsOfPHP/security-advisories/blob/master/timber/timber/CVE-2024-29800.yaml"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/timber/timber"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-502", "CWE-73" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-04-12T15:15:46Z",
    "nvd_published_at" : null
  }
}