漏洞描述
由于ThinkPHP5框架对控制器名没有进行足够的安全检测,导致在没有开启强制路由的情况下,黑客构造特定的请求,可直接GetWebShell。
漏洞评级
严重
影响版本
ThinkPHP 5.0系列 < 5.0.23
ThinkPHP 5.1系列 < 5.1.31
安全版本
ThinkPHP 5.0系列 5.0.23
ThinkPHP 5.1系列 5.1.31
ThinkPHP5.*版本发布安全更新
本次版本更新主要涉及一个安全更新,由于框架对控制器名没有进行足够的检测会导致在没有开启强制路由的情况下可能的getshell
漏洞,受影响的版本包括5.0
和5.1
版本,推荐尽快更新到最新版本。
手动修正
5.1版本
在think\route\dispatch\Url
类的parseUrl
方法,解析控制器后加上
if ($controller && !preg_match('/^[A-Za-z](\w|\.)*$/', $controller)) {
throw new HttpException(404, 'controller not exists:' . $controller);
}

5.0版本
在think\App
类的module
方法的获取控制器的代码后面加上
if (!preg_match('/^[A-Za-z](\w|\.)*$/', $controller)) {
throw new HttpException(404, 'controller not exists:' . $controller);
}