漏洞描述
CRMEB知识付费系统的application/admin/controller/setting/SystemAdmin.php文件的index()函数存在漏洞,其未对用户传入的roles参数进行过滤,使得roles参数的值可在where()部分拼接成查询字符串,最终插入到执行的SQL语句中,造成SQL注入。
CRMEB知识付费系统 源码下载链接: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);
}
 
                         
                         
                     
                         
                     
                     
                     
                     
                     
                             
                                    
 
                                         
                                     
                 
                         
                     
                 
         
         
             
         
         
         
		