漏洞描述
CRMEB知識付費系統(tǒng)的application/admin/controller/setting/SystemAdmin.php文件的index()函數存在漏洞,其未對用戶傳入的roles參數進行過濾,使得roles參數的值可在where()部分拼接成查詢字符串,最終插入到執(zhí)行的SQL語句中,造成SQL注入。
CRMEB知識付費系統(tǒng) 源碼下載鏈接:https://gitee.com/ZhongBangKeJi/crmeb_zzff_class
漏洞利用條件
1. 需要登錄管理后臺。
漏洞文件及代碼
漏洞文件:application/admin/controller/setting/SystemAdmin.php
漏洞函數:index ()
漏洞代碼:
第39行,通過getMore()函數將get方式提交的參數賦值給$where,此過程中未進行任何過濾;
第46行,$where作為參數傳遞給AdminModel::systemPage()函數
漏洞文件:application/admin/model/system/SystemAdmin.php
漏洞函數:systemPage ()
漏洞代碼:
第161行,可以看到where()中把$where[roles]直接拼接,組成一個字符串,因此可以在$where[roles]中插入單引號,閉合’%, 隨后插入SQL語句;
修復方法:
修改文件:application/admin/model/system/SystemAdmin.php
修改函數:systemPage ()
public static function systemPage($where){
$model = new self;
if (isset($where['name']) && $where['name'] != '') {
$model = $model->where('account|real_name', 'LIKE', "%$where[name]%");
}
if (isset($where['roles']) && $where['roles'] != '') {
$model = $model->where('roles', 'LIKE', "%$where[roles]%");
}
if (isset($where['level'])) {
$model = $model->where('level', $where['level']);
}
$model = $model->where('is_del', 0);
return self::page($model, function ($admin, $key) {
$admin->roles = SystemRole::where('id', 'IN', $admin->roles)->column('role_name');
}, $where);
}