{"id":"CVE-2026-24765","aliases":["CVE-2026-24765","GHSA-vvj3-c3rp-c85p"],"related":[],"kind":"vulnerability","state":"published","title":"PHPUnit Vulnerable to Unsafe Deserialization in PHPT Code Coverage Handling","summary":"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.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"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.","source":"cvelist"},{"lang":"en","text":"### Overview\n\nA vulnerability has been discovered 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.\n\n### Technical Details\n\n**Affected Component:** PHPT test runner, method `cleanupForCoverage()`\n**Affected Versions:** <= 8.5.51, <= 9.6.32, <= 10.5.61, <= 11.5.49, <= 12.5.7\n\n### Vulnerable Code Pattern\n\n```php\nif ($buffer !== false) {\n    // Unsafe call without restrictions\n    $coverage = @unserialize($buffer);\n}\n```\n\nThe 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.\n\n### Attack Prerequisites and Constraints\n\nThis vulnerability requires **local file write access** to the location where PHPUnit stores or expects code coverage files for PHPT tests. This can occur through:\n\n* **CI/CD Pipeline Attacks:** A malicious pull request that places a `.coverage` file alongside test files, executed when the CI system runs tests using PHPUnit and collects code coverage information\n* **Local Development Environment:** An attacker with shell access or ability to write files to the project directory\n* **Compromised Dependencies:** A supply chain attack inserting malicious files into a package or monorepo\n\n**Critical Context:** Running test suites from unreviewed pull requests without isolated execution is inherently a code execution risk, independent of this specific vulnerability. This represents a broader class of [Poisoned Pipeline Execution (PPE) attacks](https://owasp.org/www-project-top-10-ci-cd-security-risks/CICD-SEC-04-Poisoned-Pipeline-Execution) affecting CI/CD systems.\n\n### Proposed Remediation Approach\n\nRather 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.\n\n#### Rationale for Error-Based Approach:\n\n1. **Visibility Over Silence:** When an invariant is violated (a `.coverage` file existing before test execution), the error must be visible in CI/CD output, alerting operators to investigate the root cause rather than proceeding with sanitized input\n2. **Operational Security:** A `.coverage` file should never exist before tests run, coverage data is generated by executing tests, not sourced from artifacts. Its presence indicates:\n    * A malicious actor placed it intentionally\n    * Build artifacts from a previous run contaminated the environment\n    * An unexpected filesystem state requiring investigation\n3. **Defense-in-Depth Principle:** Protecting a single deserialization call does not address the fundamental attack surface. Proper mitigations for PPE attacks lie outside PHPUnit's scope:\n    * Isolate CI/CD runners (ephemeral, containerized environments)\n    * Restrict code execution on protected branches\n    * Scan pull requests and artifacts for tampering\n    * Use branch protection rules to prevent unreviewed code execution\n\n### Severity Classification\n\n* **Attack Vector (AV):** Local (L) — requires write access to the file system where tests execute\n* **Attack Complexity (AC):** Low (L) — exploitation is straightforward once the malicious file is placed\n* **Privileges Required (PR):** Low (L) — PR submitter status or contributor role provides sufficient access\n* **User Interaction (UI):** None (N) — automatic execution during standard test execution\n* **Scope (S):** Unchanged (U) — impact remains within the affected test execution context\n* **Confidentiality Impact (C):** High (H) — full remote code execution enables complete system compromise\n* **Integrity Impact (I):** High (H) — arbitrary code execution allows malicious modifications\n* **Availability Impact (A):** High (H) — full code execution permits denial-of-service actions\n\n### Mitigating Factors (Environmental Context)\n\nOrganizations can reduce the effective risk of this vulnerability through proper CI/CD configuration:\n\n* **Ephemeral Runners:** Use containerized, single-use CI/CD runners that discard filesystem state between runs\n* **Code Review Enforcement:** Require human review and approval before executing code from pull requests\n* **Branch Protection:** Enforce branch protection rules that block unreviewed code execution\n* **Artifact Isolation:** Separate build artifacts from source; never reuse artifacts across independent builds\n* **Access Control:** Limit file write permissions in CI environments to authenticated, trusted actors\n\n### Fixed Behaviour\n\nWhen a `.coverage` file is detected for a PHPT test prior to execution, PHPUnit will emit a clear error message identifying the anomalous state. This ensures:\n\n* **Visibility:** The error appears prominently in CI/CD output and test logs\n* **Investigation:** Operations teams can investigate the root cause (potential tampering, environment contamination)\n* **Fail-Fast Semantics:** Test execution stops rather than proceeding with an unexpected state\n\n### Recommendation\n\n**Update to the patched version immediately** if a project runs PHPT tests using PHPUnit with coverage instrumentation in any CI/CD environment that executes code from external contributors. Additionally, audit the project's CI/CD configuration to ensure:\n\n* Pull requests from forks or untrusted sources execute in isolated environments\n* Branch protection rules require human review before code execution\n* CI/CD runners are ephemeral and discarded after each build\n* Build artifacts are not reused across independent runs without validation","format":"markdown","source":"ghsa"},{"lang":"es","text":"PHPUnit es un framework de pruebas para PHP. Se ha descubierto una vulnerabilidad en versiones anteriores a 12.5.8, 11.5.50, 10.5.62, 9.6.33 y 8.5.52 que involucra la deserialización insegura de datos de cobertura de código en la ejecución de pruebas PHPT. La vulnerabilidad existe en el método `cleanupForCoverage()`, que deserializa archivos de cobertura de código sin validación, lo que podría permitir la ejecución remota de código si archivos `.coverage` maliciosos están presentes antes de la ejecución de la prueba PHPT. La vulnerabilidad ocurre cuando un archivo `.coverage`, que no debería existir antes de la ejecución de la prueba, es deserializado sin la restricción del parámetro `allowed_classes`. Un atacante con acceso de escritura de archivos local puede colocar un objeto serializado malicioso con un método `__wakeup()` en el sistema de archivos, lo que lleva a la ejecución de código arbitrario durante las ejecuciones de pruebas con la instrumentación de cobertura de código habilitada. Esta vulnerabilidad requiere acceso de escritura de archivos local a la ubicación donde PHPUnit almacena o espera archivos de cobertura de código para las pruebas PHPT. Esto puede ocurrir a través de ataques a la cadena de CI/CD, el entorno de desarrollo local y/o dependencias comprometidas. En lugar de simplemente sanear silenciosamente la entrada a través de `['allowed_classes' =&gt; false]`, el mantenedor ha optado por hacer explícito el estado anómalo tratando los archivos `.coverage` preexistentes para las pruebas PHPT como una condición de error. A partir de las versiones 12.5.8, 11.5.50, 10.5.62, 9.6.33, cuando se detecta un archivo `.coverage` para una prueba PHPT antes de la ejecución, PHPUnit emitirá un mensaje de error claro que identifique el estado anómalo. Las organizaciones pueden reducir el riesgo efectivo de esta vulnerabilidad a través de una configuración adecuada de CI/CD, incluyendo ejecutores efímeros, aplicación de revisión de código, protección de ramas, aislamiento de artefactos y control de acceso.","source":"nvd"}],"published":"2026-01-27T21:35:54.292Z","modified":"2026-06-17T10:23:33.267Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","score":7.8,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","score":7.8,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","score":7.8,"rating":"HIGH"}],"cwes":["CWE-502"],"affected":[{"ranges":[{"version":"< 8.5.52","status":"affected"},{"version":">= 9.0.0, < 9.6.33","status":"affected"},{"version":">= 10.0.0, < 10.5.62","status":"affected"},{"version":">= 11.0.0, < 11.5.50","status":"affected"},{"version":">= 12.0.0, < 12.5.8","status":"affected"}],"vendor":"sebastianbergmann","product":"phpunit","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"8.5.52"}],"ecosystem":"Packagist","package":"phpunit/phpunit","purl":"pkg:composer/phpunit/phpunit","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"9.0.0","status":"affected","fixed":"9.6.33"}],"ecosystem":"Packagist","package":"phpunit/phpunit","purl":"pkg:composer/phpunit/phpunit","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"10.0.0","status":"affected","fixed":"10.5.62"}],"ecosystem":"Packagist","package":"phpunit/phpunit","purl":"pkg:composer/phpunit/phpunit","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"11.0.0","status":"affected","fixed":"11.5.50"}],"ecosystem":"Packagist","package":"phpunit/phpunit","purl":"pkg:composer/phpunit/phpunit","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"12.0.0","status":"affected","fixed":"12.5.8"}],"ecosystem":"Packagist","package":"phpunit/phpunit","purl":"pkg:composer/phpunit/phpunit","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"8.5.52"},{"status":"affected","introduced":"9.0.0","fixed":"9.6.33"},{"status":"affected","introduced":"10.0.0","fixed":"10.5.62"},{"status":"affected","introduced":"11.0.0","fixed":"11.5.50"},{"status":"affected","introduced":"12.0.0","fixed":"12.5.8"}],"vendor":"phpunit_project","product":"phpunit","cpe":"cpe:2.3:a:phpunit_project:phpunit:*:*:*:*:*:-:*:*","source":"nvd"},{"ranges":[{"status":"affected","version":"11.0"}],"vendor":"debian","product":"debian_linux","cpe":"cpe:2.3:o:debian:debian_linux:11.0:*:*:*:*:*:*:*","source":"nvd"}],"references":[{"url":"https://github.com/sebastianbergmann/phpunit/security/advisories/GHSA-vvj3-c3rp-c85p","tags":["mitigation","vendor-advisory","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/sebastianbergmann/phpunit/commit/3141742e00620e2968d3d2e732d320de76685fda","tags":["patch","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/sebastianbergmann/phpunit/releases/tag/10.5.63","tags":["release-notes","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/sebastianbergmann/phpunit/releases/tag/11.5.50","tags":["release-notes","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/sebastianbergmann/phpunit/releases/tag/12.5.8","tags":["release-notes","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/sebastianbergmann/phpunit/releases/tag/8.5.52","tags":["release-notes","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/sebastianbergmann/phpunit/releases/tag/9.6.33","tags":["release-notes","web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://lists.debian.org/debian-lts-announce/2026/02/msg00009.html","tags":["mailing-list","third-party-advisory","web"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-24765","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/sebastianbergmann/phpunit/commit/613d142f5a8471ca71623ce5ca2795f79248329e","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/FriendsOfPHP/security-advisories/blob/master/phpunit/phpunit/CVE-2026-24765.yaml","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/sebastianbergmann/phpunit","tags":["package"],"sources":["ghsa"]},{"url":"https://owasp.org/www-project-top-10-ci-cd-security-risks/CICD-SEC-04-Poisoned-Pipeline-Execution","tags":["web"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"total","date":"2026-01-28T21:13:53.775Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-24765","url":"https://www.cve.org/CVERecord?id=CVE-2026-24765","licence":"CVE Terms of Use","modified":"2026-02-06T12:09:45.308Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-vvj3-c3rp-c85p","url":"https://github.com/advisories/GHSA-vvj3-c3rp-c85p","licence":"CC-BY-4.0","modified":"2026-05-05T15:55:47.547Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-24765","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-24765","licence":"Public domain","modified":"2026-06-17T10:23:33.267Z"}],"updatedAt":"2026-11-25T22:59:13.248Z","epss":{"score":0.00384,"percentile":0.34617,"date":"2026-12-01T12:00:22.000Z"}}