Goal Reached Thanks to every supporter — we hit 100%!

Goal: 1000 CNY · Raised: 1336 CNY

100%

CVE-2017-9841 PoC — PHPUnit 安全漏洞

Source
Associated Vulnerability
Title: PHPUnit 安全漏洞 (CVE-2017-9841)
Description:Util/PHP/eval-stdin.php in PHPUnit before 4.8.28 and 5.x before 5.6.3 allows remote attackers to execute arbitrary PHP code via HTTP POST data beginning with a "<?php " substring, as demonstrated by an attack on a site with an exposed /vendor folder, i.e., external access to the /vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php URI.
Readme
# phpunit 远程代码执行漏洞(CVE-2017-9841)

composer是php包管理工具,使用composer安装扩展包将会在当前目录创建一个vendor文件夹,并将所有文件放在其中。通常这个目录需要放在web目录外,使用户不能直接访问。

phpunit是php中的单元测试工具,其4.8.19 ~ 4.8.27和5.0.10 ~ 5.6.2版本的`vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php`文件有如下代码:

```php
eval('?>'.file_get_contents('php://input'));
```

如果该文件被用户直接访问到,将造成远程代码执行漏洞。

参考链接:http://phpunit.vulnbusters.com

## 漏洞环境

执行如下命令启动一个php环境,其中phpunit被安装在web目录下。

```
docker-compose build
docker-compose up -d
```

web环境将启动在`http://your-ip:8080`。

## 漏洞复现

直接将PHP代码作为POST Body发送给`http://your-ip:8080/vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php`:

![](1.png)
File Snapshot

Log in to view the POC file snapshot cached by Shenlong Bot

Log in to view
Remarks
    1. It is advised to access via the original source first.
    2. Local POC snapshots are reserved for subscribers — if the original source is unavailable, the local mirror is part of the paid plan.
    3. Mirroring, verifying, and maintaining this POC archive takes ongoing effort, so local snapshots are a paid feature. Your subscription keeps the archive online — thank you for the support. View subscription plans →