Skip to content
Laskyr

phpunit/phpunit security advisory

CVE-2026-24765: Unsafe Deserialization in PHPT Code Coverage Handling in phpunit/phpunit

CVE-2026-24765 is a high-severity PHP object injection vulnerability in the PHP package phpunit/phpunit (CVSS 7.8), published 27 January 2026. It is fixed in 8.5.52, 9.6.33, 10.5.62, 11.5.50 and 12.5.8, one per release line; earlier versions on each line are affected. Exploiting it needs a low-privilege user account.

high 7.8 published 2026-01-27 · updated 2026-06-17

Fixed in phpunit/phpunit 8.5.52, 9.6.33, 10.5.62, 11.5.50 and 12.5.8

This PHP object injection issue affects phpunit/phpunit in 5 release lines: >= 0, < 8.5.52; >= 9.0.0, < 9.6.33; >= 10.0.0, < 10.5.62; >= 11.0.0, < 11.5.50; >= 12.0.0, < 12.5.8. Upgrade to the fixed version for your release line (8.5.52, 9.6.33, 10.5.62, 11.5.50 and 12.5.8). The newest release, 13.4.6, is not affected.

Affected versions
>= 0, < 8.5.52
>= 9.0.0, < 9.6.33
>= 10.0.0, < 10.5.62
>= 11.0.0, < 11.5.50
>= 12.0.0, < 12.5.8
Fixed in
8.5.52, 9.6.33, 10.5.62, 11.5.50, 12.5.8
Newest release
13.4.6
Severity
High · CVSS 7.8
Type
PHP object injection
CWE-502
Exploited in the wild
Not on the CISA KEV list
checked 2026-11-04

Is your phpunit/phpunit version affected?

Run composer show phpunit/phpunit in your project, then enter the version. We check it against this and every other known phpunit/phpunit advisory.

Who can exploit CVE-2026-24765

CVSS vector (scored by GitHub): CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

Your app is only exposed if it uses the affected part of phpunit/phpunit. The advisory below says which part that is. If you are not sure, upgrade anyway: it costs less than finding out.

How to fix CVE-2026-24765 in phpunit/phpunit

  1. Find the installed version: composer show phpunit/phpunit. If you never required it yourself, composer why phpunit/phpunit shows which package pulls it in.
  2. Update it: composer update phpunit/phpunit --with-all-dependencies. You need the fixed version for your release line (8.5.52, 9.6.33, 10.5.62, 11.5.50 and 12.5.8).
  3. If Composer will not go that high, your composer.json constraint is holding it back. Widen it (for example "phpunit/phpunit": "^12.5.8" if you can take that version), or upgrade the package that requires it.
  4. Run composer audit. It reads the same advisory data and should no longer list CVE-2026-24765.
  5. Commit composer.lock and deploy it. On the server, run composer install --no-dev from the lock file, not composer update.

If you cannot upgrade yet

General hardening for PHP object injection issues while the upgrade waits. None of it replaces the fix.

The CVE-2026-24765 advisory

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.

Description from the CVE record, published by GitHub (the CVE Numbering Authority), via the NVD entry for CVE-2026-24765. Advisory title: “Unsafe Deserialization in PHPT Code Coverage Handling”.

References

Other phpunit/phpunit advisories

Related

Need help patching or upgrading? Laskyr does PHP and Laravel security fixes and upgrades. Tell us what you run and we reply with a plan and a price.

Ask about a fix

Where this data comes from

First hour checklist

If the site was just hacked, read the emergency kit before you delete files. The page is free. Email is optional.

Read the emergency kit