Vendor Phpunit Phpunit Src Util Php Eval-stdin.php Cve ((top)) Review
The keyword "vendor/phpunit/phpunit/src/util/php/eval-stdin.php" refers to a critical Remote Code Execution (RCE) vulnerability known as CVE-2017-9841. Despite being years old, it remains a common target for automated web scanners because of the catastrophic access it grants to unauthenticated attackers. What is CVE-2017-9841?
This vulnerability exists in the eval-stdin.php file, which is part of the PHPUnit testing framework. The script was designed to process input for unit tests but was inadvertently left with a major security flaw: it uses eval() on raw data from the php://input wrapper.
The Flaw: The script reads the body of an HTTP POST request and executes it as PHP code if it starts with the tag.
The Impact: An attacker can send a specially crafted POST request to this file and execute any command they want on the server. This can lead to full server compromise, data theft, or the installation of malware. Why Is It Still a Threat? The primary reason this CVE persists is misconfiguration. CVE-2017-9841 Detail - NVD vendor phpunit phpunit src util php eval-stdin.php cve
8. Remediation Steps
-
Update PHPUnit (if used in production – which it shouldn’t be):
composer require --dev phpunit/phpunit:^5.6.3
-
Remove PHPUnit from production entirely:
composer install --no-dev
-
Block access to /vendor/ via web server configuration: The keyword "vendor/phpunit/phpunit/src/util/php/eval-stdin
- Apache (
.htaccess):
<Directory "vendor">
Require all denied
</Directory>
- Nginx:
location ~ /vendor/
deny all;
return 403;
-
Scan for backdoors if the server was previously vulnerable.
Example Exploit
If the file is accessible at:
https://target.com/vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php
An attacker can send:
curl -d "<?php system('id'); ?>" https://target.com/vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php
The server would execute id and return the output.
6. Fixes and Patches
The PHPUnit team released patches in:
- PHPUnit 4.8.28 – removed the
eval-stdin.php file.
- PHPUnit 5.6.3 – same.
The fix was simply deleting the file. No additional security wrapper was added because the file was never meant for production use. Update PHPUnit (if used in production – which
Modern Status: Is This Still a Threat in 2025?
Yes and no.
- PHPUnit 7.0+ (released 2018) removed
eval-stdin.php entirely and replaced it with safer process forking.
- Most modern Composer-aware applications use
symfony/phpunit-bridge or phpunit/phpunit version 9/10, which are safe.
- However, legacy systems, abandoned projects, and misconfigured shared hosting still contain this file. Scans in 2024 showed over 15,000 live servers with reachable
eval-stdin.php endpoints, many in educational or enterprise intranets.
4. Why Does This Happen?
- Misplaced development artifacts: PHPUnit is a development dependency. It should never be installed on a production server. However, many projects run
composer install --no-dev incorrectly or not at all, leaving development tools in production.
- Public
vendor directory: Many developers expose the entire vendor/ directory in the web root without proper .htaccess or web server rules to block access.
- Lack of input validation: The script blindly executes any input.