当前位置: 首页 > news >正文

RuoYi issue3: Unauthorized Role Assignment To Users

Vulnerability call chain

1.1 Summary

RuoYi has a missing authorization vulnerability: Unauthorized Role Assignment To Users. 给不可见用户授予角色,改变其 RBAC membership 和后续权限集合。

  • Attack precondition: 拥有 system:role:edit,且目标 roleId 可见。
  • Affected authorization property: ``sys_user_role.user_id, sys_user_role.role_id
  • Security impact: 给不可见用户授予角色,改变其 RBAC membership 和后续权限集合。

1.2 Exploit path

POST /system/role/authUser/selectAll,提交不在操作者 DataScope 内的 userIds

1.3 Key code evidence

  1. ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java

Evidence location: https://github.com/yangzongzhuan/RuoYi/blob/master/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java#L310

  307      @Log(title = "角色管理", businessType = BusinessType.GRANT)308      @PostMapping("/authUser/selectAll")309      @ResponseBody310      public AjaxResult selectAuthUserAll(Long roleId, String userIds)311      {312          roleService.checkRoleDataScope(roleId);313          return toAjax(roleService.insertAuthUsers(roleId, userIds));314      }315  316      /**317       * 加载角色部门(数据权限)列表树318       */319      @RequiresPermissions("system:role:edit")320      @GetMapping("/deptTreeData")
  1. ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java

Evidence location: https://github.com/yangzongzhuan/RuoYi/blob/master/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java#L403

  400          return userRoleMapper.deleteUserRoleInfos(roleId, Convert.toLongArray(userIds));401      }402  403      /**404       * 批量选择授权用户角色405       * 406       * @param roleId 角色ID407       * @param userIds 需要授权的用户数据ID408       * @return 结果409       */410      @Override411      public int insertAuthUsers(Long roleId, String userIds)412      {413          Long[] users = Convert.toLongArray(userIds);414          // 新增用户与角色管理415          List<SysUserRole> list = new ArrayList<SysUserRole>();416          for (Long userId : users)417          {418              SysUserRole ur = new SysUserRole();
  1. ruoyi-system/target/classes/mapper/system/SysUserRoleMapper.xml

Evidence location: https://github.com/yangzongzhuan/RuoYi/blob/master/ruoyi-system/target/classes/mapper/system/SysUserRoleMapper.xml#L31

   28          </foreach> 29   	</delete>30  	31  	<insert id="batchUserRole">32  		insert into sys_user_role(user_id, role_id) values33  		<foreach item="item" index="index" collection="list" separator=",">34  			(#{item.userId},#{item.roleId})35  		</foreach>36  	</insert>37  	38  	<delete id="deleteUserRoleInfo" parameterType="SysUserRole">
  1. ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java

Evidence location: https://github.com/yangzongzhuan/RuoYi/blob/master/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java#L456

  453       * @param userId 用户id454       */455      @Override456      public void checkUserDataScope(Long userId)457      {458          if (!ShiroUtils.isAdmin())459          {460              SysUser user = new SysUser();461              user.setUserId(userId);462              List<SysUser> users = SpringUtils.getAopProxy(this).selectUserList(user);463              if (StringUtils.isEmpty(users))464              {465                  throw new ServiceException("没有权限访问用户数据!");466              }467          }468      }469  470      /**
  1. userService.c

Evidence location: https://github.com/yangzongzhuan/RuoYi/blob/master/userService.c

3. Root Cause Analysis

Root Cause 1: Missing server-side authorization on the vulnerable operation.

The endpoint accepts user-controlled authorization-sensitive identifiers or fields, but the write/read path does not prove that the current caller may operate on the target object.

Root Cause 2: Missing object-scope or grant-bound validation.

The implementation relies on endpoint access, UI filtering, or object existence checks instead of enforcing target ownership, tenant boundary, role ceiling, or grantable-resource constraints at the service layer.

对每个待授权 userId 调用 userService.checkUserDataScope(userId),并禁止对超级管理员用户进行授权变更。

5. Verification after fix

  • Unauthorized callers receive HTTP 403 or equivalent rejection.
  • Out-of-scope target identifiers are rejected before database writes or sensitive reads.
  • Role, permission, tenant, organization, ownership, or grant-bound ceilings are enforced server-side.
  • Direct HTTP requests are rejected even when front-end controls are hidden.
http://www.jsqmd.com/news/1035846/

相关文章:

  • 终极Windows热键冲突检测指南:Hotkey Detective让键盘快捷键重获新生
  • 2026西双版纳焊缝探伤检测权威机构排行 TOP 本地高频选择,无损检测 + UT+RT+PT 检测 附电话地址 - 中安检测集团
  • 2026山西焊缝探伤检测权威机构排行 TOP 本地高频选择,无损检测 + UT+RT+PT 检测 附电话地址 - 中安检测集团
  • 2026绥化焊缝探伤检测权威机构排行 TOP 本地高频选择,无损检测 + UT+RT+PT 检测 附电话地址 - 中安检测集团
  • 2026最新教育垂直领域学科大模型与教学智能体建设方案排行 - 起跑123
  • 如何3分钟完成Adobe软件快速激活:Adobe-GenP完整使用指南
  • JEEWMS issue3: `updateDataRule` 可改写角色数据规则
  • OneNote转Markdown终极指南:如何用onenote-md-exporter实现无损格式转换
  • 2026石家庄焊缝探伤检测权威机构排行 TOP 本地高频选择,无损检测 + UT+RT+PT 检测 附电话地址 - 中安检测集团
  • 2026锡林郭勒盟焊缝探伤检测权威机构排行 TOP 本地高频选择,无损检测 + UT+RT+PT 检测 附电话地址 - 中安检测集团
  • 东北景区文旅对讲运维科普 淡旺季对讲机通讯设备适配与故障标准化解决方案----黑龙江单工科技有限公司 - 无线电评测大师
  • 2026石嘴山焊缝探伤检测权威机构排行 TOP 本地高频选择,无损检测 + UT+RT+PT 检测 附电话地址 - 中安检测集团
  • SSRF 302跳转
  • 2026新乡焊缝探伤检测权威机构排行 TOP 本地高频选择,无损检测 + UT+RT+PT 检测 附电话地址 - 中安检测集团
  • LLM上下文压缩:在有限窗口中保留关键信息的工程策略
  • 计算机毕业设计之办公耗材管理系统
  • 5年,一个程序员是如何把私有化在线客服系统做到第一名的
  • 2026延安焊缝探伤检测权威机构排行 TOP 本地高频选择,无损检测 + UT+RT+PT 检测 附电话地址 - 中安检测集团
  • 2026乌鲁木齐焊缝探伤检测权威机构排行 TOP 本地高频选择,无损检测 + UT+RT+PT 检测 附电话地址 - 中安检测集团
  • SSRF DNS重绑定绕过法
  • 2026南阳焊缝探伤检测权威机构排行 TOP 本地高频选择,无损检测 + UT+RT+PT 检测 附电话地址 - 中安检测集团
  • RuoYi issue4: Unauthorized Role Assignment Deletion
  • 2026陕西焊缝探伤检测权威机构排行 TOP 本地高频选择,无损检测 + UT+RT+PT 检测 附电话地址 - 中安检测集团
  • MonkeyCode开源版API调试工具:在云IDE里直接测试接口(免费,替代Postman)
  • 全栈应用的状态同步:从前后端割裂到实时一致,分布式数据的协调方案
  • 2026 年人来灯亮智能开关推荐:优智者感应灵敏 - 思溯深度专栏
  • 2026 亨得利辟谣维权完整版:全网仿冒售后电话曝光 + 原厂维保收费标准对照(建议保存) - 亨得利官方维修中心
  • 2026年 道路沥青路面/彩色沥青道路/沥青混凝土厂家推荐榜单:覆盖小区、园区、停车场与厂房地坪混凝土的优质品牌解析 - 品牌发掘
  • Loop:Agent发展的第四个Engineering已经来了
  • 2026内江焊缝探伤检测权威机构排行 TOP 本地高频选择,无损检测 + UT+RT+PT 检测 附电话地址 - 中安检测集团