CVE-2021-3007: Zendframework/zendframework Remote Code Execution Vulnerability

CRITICAL
Advisory Identifier: GHSA-xx8f-qf9f-5fgw
CVSS 9.8
CWE-502
Published
Advisory Summary

CVE-2021-3007 is a CRITICAL (CVSS 9.8) remote code execution vulnerability (CWE-502: Deserialization of Untrusted Data) affecting Zendframework/zendframework libraries in the Packagist ecosystem. The issue involves remote code execution in zendframework and laminas-http. Remediation is available by upgrading affected packages to version 2.14.2.

CVE-2021-3007 at a Glance

CVE Identifier CVE-2021-3007
GHSA Identifier GHSA-xx8f-qf9f-5fgw
Severity CRITICAL
CVSS v3.1 Base Score 9.8
CWE Classification CWE-502: Deserialization of Untrusted Data
Affected Product Zendframework/zendframework
Package Ecosystem Packagist
Published Date
Last Updated

Security Impact

CVSS: 9.8

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

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

How to Fix CVE-2021-3007

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

zendframework/zendframework fixed: Latest secure release
Upgrade zendframework/zendframework to Latest secure release
laminas/laminas-http fixed: 2.14.2
Upgrade laminas/laminas-http to 2.14.2
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 zendframework/zendframework

How to Check if You Are Affected

To determine whether your application is affected by CVE-2021-3007, inspect your project dependencies for Zendframework/zendframework:

inspect dependencies for zendframework/zendframework

Analyze the terminal output to locate any version of Zendframework/zendframework in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.14.2), 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 Zendframework/zendframework, 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

Laminas Project laminas-http before 2.14.2, and Zend Framework 3.0.0, has a deserialization vulnerability that can lead to remote code execution if the content is controllable, related to the __destruct method of the Zend\Http\Response\Stream class in Stream.php. NOTE: Zend Framework is no longer supported by the maintainer. NOTE: the laminas-http vendor considers this a "vulnerability in the PHP language itself" but has added certain type checking as a way to prevent exploitation in (unrecommended) use cases where attacker-supplied data can be deserialized.

CVE-2021-3007 Affected Zendframework/zendframework Versions

2 component(s)
Fixed Versions:
2.14.2
Product / Package Ecosystem Affected Versions Fixed Version
zendframework/zendframework
Packagist
≤ 3.0.0
laminas/laminas-http
Packagist
< 2.14.2
2.14.2

References

Frequently Asked Questions

What is CVE-2021-3007?
CVE-2021-3007 is a security vulnerability in Zendframework/zendframework involving Remote code execution in zendframework and laminas-http under CWE-502: Deserialization of Untrusted Data.
Which Zendframework/zendframework versions are affected?
Affected versions include releases prior to 2.14.2 across affected packages: zendframework/zendframework, laminas/laminas-http.
What version fixes CVE-2021-3007?
Upgrading to 2.14.2 (or the latest patched release for your respective branch) resolves the vulnerability.
Is zendframework/zendframework affected?
Yes, zendframework/zendframework is affected in releases prior to Latest secure release. Upgrade your dependency to Latest secure release or later.
Is laminas/laminas-http affected?
Yes, laminas/laminas-http is affected in releases prior to 2.14.2. Upgrade your dependency to 2.14.2 or later.
What is the CVSS score of CVE-2021-3007?
CVE-2021-3007 has a CVSS v3.1 base score of 9.8 (CRITICAL) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2021-3007?
CVE-2021-3007 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-2021-3007?
Run the dependency tree command: 'inspect dependencies for zendframework/zendframework'. 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-xx8f-qf9f-5fgw",
  "modified" : "2024-04-22T19:04:05Z",
  "published" : "2021-06-08T20:11:19Z",
  "aliases" : [ "CVE-2021-3007" ],
  "summary" : "Remote code execution in zendframework and laminas-http",
  "details" : "Laminas Project laminas-http before 2.14.2, and Zend Framework 3.0.0, has a deserialization vulnerability that can lead to remote code execution if the content is controllable, related to the __destruct method of the Zend\\Http\\Response\\Stream class in Stream.php. NOTE: Zend Framework is no longer supported by the maintainer. NOTE: the laminas-http vendor considers this a \"vulnerability in the PHP language itself\" but has added certain type checking as a way to prevent exploitation in (unrecommended) use cases where attacker-supplied data can be deserialized.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "zendframework/zendframework"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "3.0.0"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "laminas/laminas-http"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.14.2"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-3007"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/laminas/laminas-http/pull/48"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Ling-Yizhou/zendframework3-/blob/main/zend%20framework3%20%E5%8F%8D%E5%BA%8F%E5%88%97%E5%8C%96%20rce.md"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/laminas/laminas-http/commits/2.15.x/src/Response/Stream.php"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/laminas/laminas-http/releases/tag/2.14.2"
  }, {
    "type" : "WEB",
    "url" : "https://research.checkpoint.com/2021/freakout-leveraging-newest-vulnerabilities-for-creating-a-botnet"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-502" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-04-07T18:11:15Z",
    "nvd_published_at" : "2021-01-04T03:15:00Z"
  }
}