CVE-2026-24765

PHPUnit Vulnerable to Unsafe Deserialization in PHPT Code Coverage Handling

Published Jan 27, 2026 CVSS 3.1 · 7.8 High EPSS < 1% KEV · Not listed
Description
PHPUnit is a testing framework for PHP. A vulnerability has been discovered in versions prior to 12.5.8, 11.5.50, 10.5.62, 9.6.33, and 8.5.52 involving unsafe deserialization of code coverage data in PHPT test execution. The vulnerability exists in the `cleanupForCoverage()` method, which deserializes code coverage files without validation, potentially allowing remote code execution if malicious `.coverage` files are present prior to the execution of the PHPT test. The vulnerability occurs when a `.coverage` file, which should not exist before test execution, is deserialized without the `allowed_classes` parameter restriction. An attacker with local file write access can place a malicious serialized object with a `__wakeup()` method into the file system, leading to arbitrary code execution during test runs with code coverage instrumentation enabled. This vulnerability requires local file write access to the location where PHPUnit stores or expects code coverage files for PHPT tests. This can occur through CI/CD pipeline attacks, the local development environment, and/or compromised dependencies. Rather than just silently sanitizing the input via `['allowed_classes' => false]`, the maintainer has chosen to make the anomalous state explicit by treating pre-existing `.coverage` files for PHPT tests as an error condition. Starting in versions in versions 12.5.8, 11.5.50, 10.5.62, 9.6.33, when a `.coverage` file is detected for a PHPT test prior to execution, PHPUnit will emit a clear error message identifying the anomalous state. Organizations can reduce the effective risk of this vulnerability through proper CI/CD configuration, including ephemeral runners, code review enforcement, branch protection, artifact isolation, and access control.

Analysis

AI-generated

Technical impact

The vulnerability in PHPUnit allows an attacker who can write to the file system to place a malicious serialized object in a hidden ".coverage" file that is automatically deserialized during PHPT test execution. When code coverage instrumentation is enabled, the deserialization call in the cleanupForCoverage() method fails to restrict the classes that can be instantiated, triggering any “'__wakeup'” logic defined in the object. This flaw can lead to arbitrary code execution in the context of the test runner, potentially allowing the attacker to run malicious code, modify artifacts, or exfiltrate data. The impact is severe because any environment that runs PHPUnit tests with coverage enabled becomes vulnerable if it permits writes to the coverage directory.

Affected Systems

The affected products are PHP Unit testing framework versions prior to 12.5.8, 11.5.50, 10.5.62, 9.6.33, and 8.5.52. The vendor is Sebastian Bergmann, the primary maintainer of PHPUnit. The issue is relevant to all installations that use PHPT test execution and enable code coverage, as the flaw resides in the cleanupForCoverage() method that processes coverage files. The fix is delivered in the releases 12.5.8, 11.5.50, 10.5.62, 9.6.33, and 8.5.52, which now raise an explicit error when a pre‑existing ".coverage" file is found.

Risk and Exploitability

The CVSS score of 7.8 indicates high severity, and the EPSS score of less than 1% suggests the flaw is unlikely to be widely exploited at this time. The vulnerability is not listed in the CISA KEV catalog, further implying a lower current exploitation risk. However, exploitation requires the attacker to have write access to the local file system used by PHPUnit to store coverage data. In CI/CD pipelines or shared development environments, gaining such access can be achieved through compromised dependencies or misconfigured runners, enabling the attacker to trigger arbitrary code execution during test runs. The most probable attack vector therefore involves a trusted CI/CD pipeline that has write access to the workspace, combined with code coverage turned on.

Remediation

No solution or workaround provided in the CVE record.

OpenCVE Recommended Actions

  • Apply the latest official PHPUnit releases – 12.5.8, 11.5.50, 10.5.62, 9.6.33, and 8.5.52 – to eliminate the unsafe deserialization path.
  • If an upgrade is not immediately possible, disable code coverage instrumentation for PHPT tests or remove any pre‑existing ".coverage" files from the test run directory before execution.
  • Enforce strict file‑system permissions on the directory where PHPUnit stores coverage data, limiting write access to only those processes that require it, and isolate CI/CD runners or use disposable workers to prevent persistent file‑system exposure.

Generated by OpenCVE AI on April 18, 2026 at 01:54 UTC.

Tracking

Sign in to view the affected projects.

Advisories

Source ID Title
Debian DLA Debian DLA DLA-4470-1 phpunit security update
Github GHSA Github GHSA GHSA-vvj3-c3rp-c85p PHPUnit Vulnerable to Unsafe Deserialization in PHPT Code Coverage Handling
History
Type Values Removed Values Added
First Time appeared Debian
Debian debian Linux
Phpunit Project
Phpunit Project phpunit
CPEs cpe:2.3:a:phpunit_project:phpunit:*:*:*:*:*:-:*:*
cpe:2.3:o:debian:debian_linux:11.0:*:*:*:*:*:*:*
Vendors & Products Debian
Debian debian Linux
Phpunit Project
Phpunit Project phpunit
Type Values Removed Values Added
Metrics ssvc

{'options': {'Automatable': 'no', 'Exploitation': 'none', 'Technical Impact': 'total'}, 'version': '2.0.3'}

Type Values Removed Values Added
First Time appeared Sebastianbergmann
Sebastianbergmann phpunit
Vendors & Products Sebastianbergmann
Sebastianbergmann phpunit
Type Values Removed Values Added
Description PHPUnit is a testing framework for PHP. A vulnerability has been discovered in versions prior to 12.5.8, 11.5.50, 10.5.62, 9.6.33, and 8.5.52 involving unsafe deserialization of code coverage data in PHPT test execution. The vulnerability exists in the `cleanupForCoverage()` method, which deserializes code coverage files without validation, potentially allowing remote code execution if malicious `.coverage` files are present prior to the execution of the PHPT test. The vulnerability occurs when a `.coverage` file, which should not exist before test execution, is deserialized without the `allowed_classes` parameter restriction. An attacker with local file write access can place a malicious serialized object with a `__wakeup()` method into the file system, leading to arbitrary code execution during test runs with code coverage instrumentation enabled. This vulnerability requires local file write access to the location where PHPUnit stores or expects code coverage files for PHPT tests. This can occur through CI/CD pipeline attacks, the local development environment, and/or compromised dependencies. Rather than just silently sanitizing the input via `['allowed_classes' => false]`, the maintainer has chosen to make the anomalous state explicit by treating pre-existing `.coverage` files for PHPT tests as an error condition. Starting in versions in versions 12.5.8, 11.5.50, 10.5.62, 9.6.33, when a `.coverage` file is detected for a PHPT test prior to execution, PHPUnit will emit a clear error message identifying the anomalous state. Organizations can reduce the effective risk of this vulnerability through proper CI/CD configuration, including ephemeral runners, code review enforcement, branch protection, artifact isolation, and access control.
Title PHPUnit Vulnerable to Unsafe Deserialization in PHPT Code Coverage Handling
Weaknesses CWE-502
References
Metrics cvssV3_1

{'score': 7.8, 'vector': 'CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H'}

Weaknesses
  • CWE-502

    Deserialization of Untrusted Data

Sources

Status
PUBLISHED
Assigner
GitHub_M
Published
Updated
Feb 6, 2026, 12:09 PM
Reserved
Jan 26, 2026, 9:06 PM
Status
Analyzed
Published
Jan 27, 2026, 10:15 PM
Modified
Jun 17, 2026, 10:23 AM
Severity
Important
Public date
Jan 27, 2026, 9:35 PM