Thinkphp5这个版本使用还是比较多的,这几天服务器提示有ThinkPHP Request.php 远程代码执行漏洞。
影响版本:ThinkPHP 5.0系列 < 5.0.24t
如何处理,整理如下:
1、处理对应代码
修复方法
打开thinkphp/library/think/Request.php
搜索method方法,改为如下
public function method($method = false){ if (true === $method) { // 获取原始请求类型 return $this->server('REQUEST_METHOD') ?: 'GET'; } elseif (!$this->method) { if (isset($_POST[Config::get('var_method')])) { $method = strtoupper($_POST[Config::get('var_method')]); if (in_array($method, ['GET', 'POST', 'DELETE', 'PUT', 'PATCH'])) { $this->method = $method; $this->{$this->method}($_POST); } else { $this->method = 'POST'; } unset($_POST[Config::get('var_method')]); } elseif (isset($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'])) { $this->method = strtoupper($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']); } else { $this->method = $this->server('REQUEST_METHOD') ?: 'GET'; } } return $this->method; }
打开thinkphp/library/think/App.php
在think\App类的module方法的获取控制器的代码后面加上,找到module方法,搜索“获取控制器名”如图
if (!preg_match('/^[A-Za-z](\w|\.)*$/', $controller)) { throw new HttpException(404, 'controller not exists:' . $controller); }
2、框架升级
进入到代码根目录 执行 composer update
注意:不推荐用这种方法直接升级,容易引起不兼容情况,如果必须特别想这样子升级修复的话 ,建议提前备份好代码。
原文链接:http://www.ay68.net/show/130.html
原创文章,作者:czhdawn,如若转载,请注明出处:https://www.czhdawn.cn/archives/328