CVE-2021-23420: Codeception/codeception Deserialization Of Untrusted Data Vulnerability

CRITICAL
Advisory Identifier: GHSA-4574-qv3w-fcmg
CVSS 9.8
CWE-502
Published
Advisory Summary

CVE-2021-23420 is a CRITICAL (CVSS 9.8) deserialization of untrusted data vulnerability (CWE-502: Deserialization of Untrusted Data) affecting Codeception/codeception libraries in the Packagist ecosystem. The issue involves deserialization of untrusted data in codeception/codeception. Remediation is available by upgrading affected packages to version 3.1.3, 4.1.22.

CVE-2021-23420 at a Glance

CVE Identifier CVE-2021-23420
GHSA Identifier GHSA-4574-qv3w-fcmg
Severity CRITICAL
CVSS v3.1 Base Score 9.8
CWE Classification CWE-502: Deserialization of Untrusted Data
Affected Product Codeception/codeception
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-23420

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

codeception/codeception fixed: 3.1.3
Upgrade codeception/codeception to 3.1.3
codeception/codeception fixed: 4.1.22
Upgrade codeception/codeception to 4.1.22
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 codeception/codeception

How to Check if You Are Affected

To determine whether your application is affected by CVE-2021-23420, inspect your project dependencies for Codeception/codeception:

inspect dependencies for codeception/codeception

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

This affects the package codeception/codeception from 4.0.0 before 4.1.22 and before 3.1.3. The RunProcess class can be leveraged as a gadget to run arbitrary commands on a system that is deserializing user input without validation.

CVE-2021-23420 Affected Codeception/codeception Versions

2 component(s)
Fixed Versions:
3.1.34.1.22
Product / Package Ecosystem Affected Versions Fixed Version
codeception/codeception
Packagist
< 3.1.3
3.1.3
codeception/codeception
Packagist
≥ 4.0.0
< 4.1.22
4.1.22

References

Frequently Asked Questions

What is CVE-2021-23420?
CVE-2021-23420 is a security vulnerability in Codeception/codeception involving Deserialization of Untrusted Data in codeception/codeception under CWE-502: Deserialization of Untrusted Data.
Which Codeception/codeception versions are affected?
Affected versions include releases prior to 3.1.3, 4.1.22 across affected packages: codeception/codeception.
What version fixes CVE-2021-23420?
Upgrading to 3.1.3, 4.1.22 (or the latest patched release for your respective branch) resolves the vulnerability.
Is codeception/codeception affected?
Yes, codeception/codeception is affected in releases prior to 3.1.3, 4.1.22. Upgrade your dependency to 3.1.3, 4.1.22 or later.
What is the CVSS score of CVE-2021-23420?
CVE-2021-23420 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-23420?
CVE-2021-23420 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-23420?
Run the dependency tree command: 'inspect dependencies for codeception/codeception'. 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-4574-qv3w-fcmg",
  "modified" : "2021-08-30T19:17:39Z",
  "published" : "2021-09-01T18:36:15Z",
  "aliases" : [ "CVE-2021-23420" ],
  "summary" : " Deserialization of Untrusted Data in codeception/codeception",
  "details" : "This affects the package codeception/codeception from 4.0.0 before 4.1.22 and before 3.1.3. The RunProcess class can be leveraged as a gadget to run arbitrary commands on a system that is deserializing user input without validation.",
  "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" : "codeception/codeception"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.1.3"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "codeception/codeception"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "4.0.0"
      }, {
        "fixed" : "4.1.22"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-23420"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Codeception/Codeception/pull/6241"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Codeception/Codeception/commit/802a108057d250ee563120eaa5365a519afc0a71"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Codeception/Codeception/commit/cbce9ea7f4664052fa1ac6b36f5b5a6dbd864d71"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/Codeception/Codeception"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Codeception/Codeception/blob/4.1/CHANGELOG-4.x.md#4122"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Codeception/Codeception/blob/4.1/ext/RunProcess.php#L52"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/FriendsOfPHP/security-advisories/blob/master/codeception/codeception/CVE-2021-23420.yaml"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/JinYiTong/poc"
  }, {
    "type" : "ADVISORY",
    "url" : "https://github.com/advisories/GHSA-4574-qv3w-fcmg"
  }, {
    "type" : "WEB",
    "url" : "https://snyk.io/vuln/SNYK-PHP-CODECEPTIONCODECEPTION-1324585"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-502" ],
    "severity" : "CRITICAL",
    "github_reviewed" : true,
    "github_reviewed_at" : "2021-08-30T19:17:39Z",
    "nvd_published_at" : "2021-08-11T13:15:00Z"
  }
}