ThinkPHP 5.0.* 远程命令执行漏洞预警

阅读量315355

|评论1

发布时间 : 2019-01-11 18:00:15

 

0x00 事件背景

2019年1月11日,360CERT发现某安全社区出现关于ThinkPHP5 RCE漏洞的威胁情报,不久之后ThinkPHP5官方与GitHub发布更新。

该更新修复了一处严重漏洞,该漏洞可导致远程命令代码执行

 

0x01 影响范围

ThinkPHP 5.0.x

  • 5.0.x ~ 5.0.23

 

0x02 修复建议

官方在GitHub中进行了更新:版本更新

enter description here

  • 升级代码到最新版本5.0.24
  • 同时建议用户在线上环境中关闭debug模式

 

0x03 漏洞验证

该漏洞危害高,影响严重:

enter description here

 

0x04 漏洞分析

漏洞主要出现在ThinkPHP Request类的method方法中 (thinkphp/library/think/Request.php)

Request类可以实现对HTTP请求的一些设置,其中成员方法method用来获取当前请求类型,其定义如下:

enter description here

当传入的参数为false的时候,会取配置项var_method,其默认值为_method

enter description here

$this->{$this->method}($_POST); 通过post参数_method可以实现对当前类的任意方法进行调用。

通过调用当前类的构造方法可以覆盖任意成员属性的值:

enter description here

这里通过覆盖filter属性,filter属性保存了用于全局过滤的函数。

但是在thinkphp5.0.23中,会对filter值重新赋值为空,导致无法利用。

enter description here

在thinkphp/library/think/App.php中开启debug的时候会调用Request类的param方法。

在thinkphp/library/think/Request.php param方法中会调用到method方法,并将参数设置为true。

enter description here

当参数为true的时候,会调用server方法

enter description here

enter description here

会走到 input方法,通过之前方法覆盖server成员属性值为array(),input方法代码如下:

enter description here最终会调用filterValue形成任意代码执行:

enter description here

 

0x05 时间线

2019-01-11 360CERT发现漏洞威胁情报

2019-01-11 ThinkPHP发布补丁更新

2019-01-11 360CERT发布预警分析

 

0x06 参考链接

  1. ThinkPHP5 github更新

本文由360CERT安全通告原创发布

转载,请参考转载声明,注明出处: https://www.anquanke.com/post/id/169481

安全客 - 有思想的安全新媒体

分享到:微信
+111赞
收藏
360CERT安全通告
分享到:微信

发表评论

内容需知
  • 投稿须知
  • 转载须知
  • 官网QQ群8:819797106
  • 官网QQ群3:830462644(已满)
  • 官网QQ群2:814450983(已满)
  • 官网QQ群1:702511263(已满)
合作单位
  • 安全客
  • 安全客
Copyright © 北京奇虎科技有限公司 360网络攻防实验室 安全客 All Rights Reserved 京ICP备08010314号-66