漏洞描述
This is a filter bypass exploit that results in arbitrary file upload and remote code execution. The class.upload.php script filters "dangerous files and content" and renames them to the txt file extension. It also does different type of transformation on the uploaded image, which would normally destroy any injected payload, even if the file extension filter could be bypassed.
The file extension filter is a blacklist, so any time a new extension is introduced (in this case pht), or any has been missed, a PHP file can be uploaded. The content must still be a valid image however and will still go through the imagecreatefromjpeg and similar functions. For this purpose I wrote the inject.php script which will essentially bruteforce its way through different images until it finds one where the payload will not be destroyed by the process done in class.upload.php. This effectively gives us an arbitrary file upload and a very stealthy code execution since it's still a valid image and will be displayed like one on pages where uploaded.
解决建议
官方补丁:https://github.com/verot/class.upload.php/blob/2.0.5/src/class.upload.php#L3068
参考链接
https://github.com/jra89/CVE-2019-19634
https://github.com/verot/class.upload.php/blob/2.0.4/src/class.upload.php#L3068
https://medium.com/@jra8908/cve-2019-19634-arbitrary-file-upload-in-class-upload-php-ccaf9e13875e