Files
vulhub/phpunit/CVE-2017-9841/README.zh-cn.md
Aaron 63285f61aa
Some checks failed
Vulhub Format Check and Lint / format-check (push) Has been cancelled
Vulhub Format Check and Lint / markdown-check (push) Has been cancelled
Vulhub Docker Image CI / longtime-images-test (push) Has been cancelled
Vulhub Docker Image CI / images-test (push) Has been cancelled
first commit
2025-09-06 16:08:15 +08:00

34 lines
1.1 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 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://web.archive.org/web/20170701212357/http://phpunit.vulnbusters.com/
- https://www.ovh.com/blog/cve-2017-9841-what-is-it-and-how-do-we-protect-our-customers/
## 漏洞环境
执行如下命令启动一个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)