VYPR
High severityOSV Advisory· Published Jan 27, 2026· Updated Feb 6, 2026

PHPUnit Vulnerable to Unsafe Deserialization in PHPT Code Coverage Handling

CVE-2026-24765

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.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
phpunit/phpunitPackagist
< 8.5.528.5.52
phpunit/phpunitPackagist
>= 9.0.0, < 9.6.339.6.33
phpunit/phpunitPackagist
>= 10.0.0, < 10.5.6210.5.62
phpunit/phpunitPackagist
>= 11.0.0, < 11.5.5011.5.50
phpunit/phpunitPackagist
>= 12.0.0, < 12.5.812.5.8

Affected products

1

Patches

2
613d142f5a84

Merge branch '11.5' into 12.5

https://github.com/sebastianbergmann/phpunitSebastian BergmannJan 27, 2026via ghsa
1 file changed · +8 1
  • src/Runner/Phpt/TestCase.php+8 1 modified
    @@ -471,7 +471,14 @@ private function cleanupForCoverage(): RawCodeCoverageData
             }
     
             if ($buffer !== false) {
    -            $coverage = @unserialize($buffer, ['allowed_classes' => false]);
    +            $coverage = @unserialize(
    +                $buffer,
    +                [
    +                    'allowed_classes' => [
    +                        RawCodeCoverageData::class,
    +                    ],
    +                ],
    +            );
     
                 if ($coverage === false) {
                     /**
    
3141742e0062

Do not run PHPT test when its temporary file for code coverage information exists

https://github.com/sebastianbergmann/phpunitSebastian BergmannJan 26, 2026via ghsa
5 files changed · +49 1
  • ChangeLog-8.5.md+7 0 modified
    @@ -2,6 +2,12 @@
     
     All notable changes of the PHPUnit 8.5 release series are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles.
     
    +## [8.5.52] - 2026-MM-DD
    +
    +### Changed
    +
    +* To prevent Poisoned Pipeline Execution (PPE) attacks using prepared `.coverage` files in pull requests, a PHPT test will no longer be run if the temporary file for writing code coverage information already exists before the test runs
    +
     ## [8.5.51] - 2026-01-24
     
     ### Changed
    @@ -374,6 +380,7 @@ All notable changes of the PHPUnit 8.5 release series are documented in this fil
     * [#3967](https://github.com/sebastianbergmann/phpunit/issues/3967): Cannot double interface that extends interface that extends `\Throwable`
     * [#3968](https://github.com/sebastianbergmann/phpunit/pull/3968): Test class run in a separate PHP process are passing when `exit` called inside
     
    +[8.5.52]: https://github.com/sebastianbergmann/phpunit/compare/8.5.51...8.5
     [8.5.51]: https://github.com/sebastianbergmann/phpunit/compare/8.5.50...8.5.51
     [8.5.50]: https://github.com/sebastianbergmann/phpunit/compare/8.5.49...8.5.50
     [8.5.49]: https://github.com/sebastianbergmann/phpunit/compare/8.5.48...8.5.49
    
  • src/Runner/PhptTestCase.php+22 1 modified
    @@ -93,7 +93,10 @@ public function __construct(string $filename, ?AbstractPhpProcess $phpUtil = nul
             $this->ensureFileExists($filename);
     
             $this->filename = $filename;
    -        $this->phpUtil  = $phpUtil ?: AbstractPhpProcess::factory();
    +
    +        $this->ensureCoverageFileDoesNotExist();
    +
    +        $this->phpUtil = $phpUtil ?: AbstractPhpProcess::factory();
         }
     
         /**
    @@ -829,4 +832,22 @@ private function ensureFileExists(string $filename): void
                 );
             }
         }
    +
    +    /**
    +     * @throws Exception
    +     */
    +    private function ensureCoverageFileDoesNotExist(): void
    +    {
    +        $files = $this->getCoverageFiles();
    +
    +        if (file_exists($files['coverage'])) {
    +            throw new Exception(
    +                sprintf(
    +                    'File %s exists, PHPT test %s will not be executed',
    +                    $files['coverage'],
    +                    $this->filename
    +                )
    +            );
    +        }
    +    }
     }
    
  • tests/end-to-end/_files/phpt-coverage-file-exists/test.coverage+0 0 added
  • tests/end-to-end/_files/phpt-coverage-file-exists/test.phpt+7 0 added
    @@ -0,0 +1,7 @@
    +--TEST--
    +test
    +--FILE--
    +<?php declare(strict_types=1);
    +print 'test';
    +--EXPECT--
    +test
    
  • tests/end-to-end/phpt/phpt-coverage-file-exists.phpt+13 0 added
    @@ -0,0 +1,13 @@
    +--TEST--
    +Error when code coverage file exists
    +--FILE--
    +<?php declare(strict_types=1);
    +$_SERVER['argv'][] = '--do-not-cache-result';
    +$_SERVER['argv'][] = '--no-configuration';
    +$_SERVER['argv'][] = \realpath(__DIR__ . '/../_files/phpt-coverage-file-exists/test.phpt');
    +
    +require_once __DIR__ . '/../../bootstrap.php';
    +
    +PHPUnit\TextUI\Command::main();
    +--EXPECTF--
    +Fatal error: Uncaught PHPUnit\Runner\Exception: File %stest.coverage exists, PHPT test %stest.phpt will not be executed%A
    

Vulnerability mechanics

Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

13

News mentions

0

No linked articles in our index yet.