phpunit is a popular testing framework for PHP. The file vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php is part of PHPUnit's internal tooling, designed to evaluate PHP code provided via stdin . It was originally intended to be used in specific, secure testing environments to run code in separate processes.
: If STDIN is empty, eval('?>') does nothing — not a problem.
: During deployment, the system checks if a /vendor or node_modules folder exists within the public-facing document root.
The core vulnerability exists because the script uses PHP's raw input stream wrapper ( php://input ) paired with the dangerous eval() function.
: The vendor directory should never be publicly accessible from the web. Move it outside the web root or use .htaccess /Nginx rules to deny all access to it.
The presence of this file in a public web root is a . Here are the steps to secure your application: 1. Never Expose the Vendor Folder
Website owners often ask: "Can I just block indexing?"
The presence of index of /vendor/phpunit/phpunit/src/Util/PHP/ is a major security red flag. The eval-stdin.php file represents an easy entry point for remote code execution. Immediate action to block access to the vendor directory is recommended for any production PHP application.
: The eval-stdin.php script allows for the evaluation of PHP code that is piped to it via standard input. This can be particularly useful in certain development or testing workflows.
testing framework—is left publicly accessible on a web server. The CVE-2017-9841 Vulnerability Vulnerability Type: Unauthenticated Remote Code Execution (RCE). Target File: /vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php Root Cause: eval-stdin.php script was designed to process code via standard input ( ). However, in vulnerable versions, it used file_get_contents('php://input') coupled with
This class is a utility used by PHPUnit to execute PHP code in an isolated process. Specifically, it handles the logic for:
eval-stdin.php was a helper script used by PHPUnit to evaluate PHP code passed via standard input. It was part of PHPUnit’s internal process isolation mechanism – when running tests in separate processes, PHPUnit would pipe code to this script, which would then eval() it.
由于该漏洞极具价值,安全社区开发了大量自动化扫描和利用工具。例如 ,它使用 Go 语言编写,支持高并发多线程,能快速检测一个列表中的网站是否存在漏洞。它会尝试扫描多个常见路径,并将存在漏洞的目标保存下来。
The core flaw lies in the file's dangerously simple design. In vulnerable versions of PHPUnit (any version prior to 4.8.28 or 5.x prior to 5.6.3), the eval-stdin.php script contained a line of code that directly exposes the server:
The server processes this request, executes the system('id') command, and sends the server's system identity details back to the attacker. From there, malicious actors can download malware, steal databases, or take full control of the host. How to Check If Your Server is Vulnerable