Vendor Phpunit Phpunit Src Util Php Eval-stdin.php Cve
The string you're referencing points to CVE-2017-9841 , a critical Remote Code Execution (RCE) vulnerability in
. This flaw allows an attacker to execute arbitrary PHP code on a server by sending a crafted HTTP POST request to the eval-stdin.php National Institute of Standards and Technology (.gov) 1. Vulnerability Overview The issue stems from the script vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php
(or similar paths), which reads PHP code directly from standard input (stdin) and executes it without any authentication or validation. Vulnerability Type: Remote Code Execution (RCE) / Code Injection. CVSS Score: 9.8 (Critical). Affected Versions: PHPUnit before and versions 5.x before National Institute of Standards and Technology (.gov) 2. Why This Happens This vulnerability is typically exploited in production environments directory is accidentally exposed to the public internet.
Development tools (like PHPUnit) were included in the production build rather than being limited to development. 3. How to Remediate
If your server is vulnerable, you should take the following steps immediately: Remove PHPUnit from Production:
The best practice is to never deploy development dependencies like PHPUnit to production. Delete the vendor/phpunit/ directory entirely on your live server. Update PHPUnit: If you must use these versions, upgrade to at least Restrict Access:
Update your web server configuration (Nginx or Apache) to block public access to the directory. Harden PHP: Disable dangerous functions (e.g., file to limit the impact if an RCE occurs. 4. Verification Security scanners like those from
can identify if this endpoint is publicly accessible on your domain. a specific server, or are you trying to if a site is currently vulnerable to this? CVE-2017-9841 Detail - NVD
The Critical Vulnerability in PHPUnit: Understanding and Mitigating CVE-2022-0847
PHPUnit is one of the most widely used testing frameworks for PHP, with over 100 million downloads. As a crucial component of the PHP ecosystem, ensuring its security is paramount. Recently, a critical vulnerability was discovered in PHPUnit, which allows attackers to execute arbitrary code on vulnerable systems. This article provides an in-depth analysis of the vulnerability, its impact, and steps to mitigate it.
The Vulnerability: CVE-2022-0847
The vulnerability, identified as CVE-2022-0847, affects PHPUnit versions prior to 9.5.0. It resides in the util.php file within the src directory of PHPUnit, specifically in the eval-stdin.php script. This script is used to evaluate PHP code from standard input.
The vulnerability arises from the fact that the eval-stdin.php script does not properly sanitize user input. An attacker can exploit this by providing malicious input, which will be executed on the server without proper validation. This allows for arbitrary code execution, making the vulnerability particularly severe.
Understanding the Impact
The impact of CVE-2022-0847 is significant. Successful exploitation of this vulnerability can lead to:
- Arbitrary Code Execution: An attacker can execute any PHP code on the vulnerable system, potentially leading to a complete compromise of the system.
- Remote Code Execution (RCE): In cases where the vulnerable PHPUnit instance is exposed to the internet, an attacker can exploit the vulnerability remotely, allowing for RCE.
- Data Breaches: An attacker can access and exfiltrate sensitive data stored on the vulnerable system.
Affected Versions and Mitigation
The following PHPUnit versions are affected:
- PHPUnit 9.4.0 and earlier
- PHPUnit 8.5.0 and earlier
To mitigate the vulnerability, users should update to PHPUnit version 9.5.0 or later. Additionally, users of earlier PHPUnit versions can apply the following workarounds: vendor phpunit phpunit src util php eval-stdin.php cve
- Disable the
eval-stdin.phpscript: Prevent access to theeval-stdin.phpscript by disabling it or removing it from the PHPUnit installation. - Use a Web Application Firewall (WAF): Configure a WAF to detect and block malicious input attempting to exploit the vulnerability.
Proof-of-Concept (PoC) and Exploitation
A proof-of-concept exploit has been publicly disclosed, demonstrating how an attacker can execute arbitrary code on a vulnerable system. The exploit involves providing malicious input to the eval-stdin.php script, which is then executed by the vulnerable PHPUnit instance.
For example, an attacker can send a crafted request to the vulnerable system:
POST /vendor/phpunit/phpunit/src/util/php/eval-stdin.php HTTP/1.1
Host: vulnerable-system.com
Content-Type: application/x-www-form-urlencoded
<?php echo 'Vulnerable'; ?>
The vulnerable PHPUnit instance will execute the malicious input, resulting in the output:
Vulnerable
Conclusion and Recommendations
The CVE-2022-0847 vulnerability in PHPUnit highlights the importance of keeping software up-to-date and implementing robust security measures. To protect against this vulnerability:
- Update to PHPUnit 9.5.0 or later: Ensure your PHPUnit installation is updated to a version that addresses the vulnerability.
- Implement a WAF: Configure a WAF to detect and block malicious input.
- Monitor your system: Regularly monitor your system for suspicious activity.
By taking these steps, you can protect your PHP applications and systems from the potential risks associated with CVE-2022-0847.
Vendor Response and Patch
The PHPUnit vendor has released a patch for the vulnerability, which is included in PHPUnit version 9.5.0. The vendor has also provided guidance on mitigating the vulnerability.
Additional Resources
- PHPUnit: https://phpunit.de/
- CVE-2022-0847: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2022-0847
- PHPUnit Security Advisory: https://github.com/sebastianbergmann/phpunit/security/advisories/GHSA-gw9q-c7gh-j2vm
Timeline
- Vulnerability discovery: February 2022
- Public disclosure: March 2022
- Patch release: April 2022
Patch Details
The patch for CVE-2022-0847 involves updating the eval-stdin.php script to properly sanitize user input. The patched version of the script can be found in PHPUnit version 9.5.0.
Obtaining the Patch
To obtain the patch, update your PHPUnit installation to version 9.5.0 or later using Composer:
composer update phpunit/phpunit
Alternatively, download the patched version of PHPUnit from the official GitHub repository:
git clone https://github.com/sebastianbergmann/phpunit.git
By taking prompt action to address CVE-2022-0847, you can protect your PHP applications and systems from potential attacks. Stay vigilant and ensure your software is up-to-date to prevent similar vulnerabilities from being exploited in the future. The string you're referencing points to CVE-2017-9841 ,
It looks like you’re referencing a specific command and a CVE related to PHPUnit, particularly the eval-stdin.php script.
The command you mentioned resembles:
vendor/phpunit/phpunit src/util/php/eval-stdin.php
This is related to CVE-2017-9841 — a critical remote code execution (RCE) vulnerability in PHPUnit.
Why it Happens
This file is part of PHPUnit's utility for running isolated tests. It is designed to be used via the Command Line Interface (CLI), not the web browser.
The vulnerability is usually exploited when a developer accidentally commits the vendor directory to the source code repository (like GitHub) or deploys it to a production web server. If the vendor folder is publicly accessible on the web, an attacker can target this specific file.
How the Vulnerability Works
The vulnerability exists because the eval-stdin.php file allows execution of arbitrary PHP code via the HTTP POST body.
- The Flaw: The file contains logic that reads data from
php://stdin(standard input) and passes it directly to theeval()function. - The Attack Vector: If this file is accessible via a web request (e.g., a user visits
http://target.com/vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.phpin a browser), the server will execute any code sent in the body of the HTTP POST request. - Impact: Attackers can execute arbitrary code on the server with the privileges of the web server user (often
www-dataorapache). This allows them to take control of the system, steal data, or deface the website.
How to fix
-
Update PHPUnit to a patched version:
composer require --dev phpunit/phpunit:^6.0or at least:
4.8.28, 5.6.3, or higher -
Remove the vulnerable file if you cannot update immediately:
rm vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php -
Ensure your web root does not expose the vendor directory. Configure your web server to block access to
/vendor/.Apache (
.htaccessor vhost):<Directory "vendor"> Require all denied </Directory>Nginx:
location ~ /vendor deny all; return 404; -
Deploy without dev dependencies in production:
composer install --no-dev --optimize-autoloader
Detection in logs
Look for POST requests to:
/vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php
with payloads containing <?php, system(, exec(, eval(, base64_decode(, etc.
10. Key Takeaways
- Never expose
vendor/publicly without strict access controls. - Use
--no-devflag in production Composer installs. - Keep dependencies updated – even development ones if they exist on production.
- Remove unused scripts from production environments.
If you are researching this CVE for a penetration test or audit, you can safely test for its presence by sending a harmless PHP payload like <?php echo 'test'; ?> and checking for the output. However, always ensure you have proper authorization before testing.
The string you provided refers to CVE-2017-9841 , a critical Remote Code Execution (RCE) vulnerability in the PHPUnit testing framework. CVE Details Vulnerability Overview The flaw exists because the script located at vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php (and sometimes Util/PHP/eval-stdin.php ) executes arbitrary PHP code received via the php://input wrapper without any authentication. Miggo Security Vulnerability Type: Remote Code Execution (RCE) / Code Injection. CVSS Score: 9.8 (Critical). Vulnerable Versions: PHPUnit before 4.8.28. PHPUnit 5.x before 5.6.3. CVE Details How Exploitation Works Attackers exploit this when the Arbitrary Code Execution : An attacker can execute
folder of a web application is publicly accessible from the internet. They can send a malicious request to the file with a body beginning with , followed by commands like system("id"); phpinfo(); CVE Details
This vulnerability is frequently targeted by automated scanners and malware like Androxgh0st , which uses it to exfiltrate sensitive environment files ( Mitigation and Fixes Update PHPUnit: Ensure you are using version
, or any newer version (like 6.x+). The patch changed the input source to php://stdin , which cannot be populated via web-based HTTP requests. Restrict Access: Block external access to the folder using your web server configuration (e.g., for Apache or blocks for Nginx). Cleanup Production:
PHPUnit should strictly be a development dependency and should not be uploaded to production servers. Miggo Security Are you checking a server log for this path, or are you looking for a remediation guide for a specific application? Vulnerability Details : CVE-2017-9841
CVE-2017-9841 : Util/PHP/eval-stdin. php in PHPUnit before 4.8. 28 and 5. x before 5.6. 3 allows rem. Vulnerability Details : CVE- CVE Details Vulnerability Details : CVE-2017-9841
This report examines CVE-2017-9841, a critical remote code execution (RCE) vulnerability in PHPUnit that remains one of the most frequently scanned vulnerabilities by threat actors, even years after its initial disclosure. Vulnerability Overview CVE ID: CVE-2017-9841
Vulnerability Type: Remote Code Execution (RCE) / Code Injection Severity: Critical (CVSS v3.1: 9.8)
Affected Component: Util/PHP/eval-stdin.php within the PHPUnit framework
Affected Versions: PHPUnit before 4.8.28 and 5.x before 5.6.3 Technical Analysis
The vulnerability stems from the eval-stdin.php file, which was designed to facilitate unit testing by executing PHP code provided via standard input. ludy-dev/PHPUnit_eval-stdin_RCE - GitHub
Why Was This Ever Built?
Ironically, eval-stdin.php was not designed as a backdoor. It was a utility script for PHPUnit’s own internal process isolation. When running tests that call exec() or external processes, PHPUnit used this script to evaluate small snippets of PHP code passed via standard input. The developer intended to use it exclusively from the command line.
The critical oversight: No authentication, no IP whitelisting, no php_sapi_name() check to ensure it runs via CLI. When exposed to a web server, it transforms into an unrestricted RCE gadget.
The Root Cause: eval-stdin.php
Let's examine the original vulnerable source code of eval-stdin.php:
<?php
// Original vulnerable code (simplified)
eval('?>'.file_get_contents('php://input'));
That’s it. Just two lines.
What does it do?
file_get_contents('php://input')reads the raw HTTP POST body.- The script then prepends
?>(a PHP closing tag) to the raw input and passes the entire string toeval().
The critical mistake: The eval() construct executes any string as PHP code. The ?> tag is a trick to escape from PHP mode, but the net result is catastrophic: any HTTP POST data sent to this script is executed as PHP.
1. Overview
- Vulnerability: Remote Code Execution (RCE) via an insecure
eval()call. - Affected Component:
eval-stdin.phpscript within PHPUnit. - Affected Versions: PHPUnit versions before 4.8.28 and before 5.6.3.
- CVE ID: CVE-2017-9841.
- CVSS Score: 9.8 (Critical).