由於框架對控制器名沒有進行足夠的檢測會導致在沒有開啟強制路由的情況下可能的getshell漏洞。最直接的影響為index.php直接被篡改成首頁html的內容!
5.0版本
thinkphp/library/think/App.php 類的module方法的獲取控制器的代碼后面加上
if (!preg_match('/^[A-Za-z](\w|\.)*$/', $controller)) {
throw new HttpException(404, 'controller not exists:' . $controller);
}
5.1版本
thinkphp/library/think/route/dispatch/Url.php 類的parseUrl方法,解析控制器后加上 添加
if ($controller && !preg_match('/^[A-Za-z](\w|\.)*$/', $controller)) {
throw new HttpException(404, 'controller not exists:' . $controller);
}
驗證成功 即可。