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

RuoYi issue4: Unauthorized Role Assignment Deletion

Vulnerability call chain

1.1 Summary

RuoYi has a missing authorization vulnerability: Unauthorized Role Assignment Deletion. 越权撤销目标用户角色,导致权限被移除。

  • Attack precondition: 拥有 system:role:edit
  • Affected authorization property: ``sys_user_role.user_id, sys_user_role.role_id
  • Security impact: 越权撤销目标用户角色,导致权限被移除。

1.2 Exploit path

POST /system/role/authUser/cancel/system/role/authUser/cancelAll,提交任意 roleId/userId(s)

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#L262

  259      @Log(title = "角色管理", businessType = BusinessType.GRANT)260      @PostMapping("/authUser/cancel")261      @ResponseBody262      public AjaxResult cancelAuthUser(SysUserRole userRole)263      {264          return toAjax(roleService.deleteAuthUser(userRole));265      }266  267      /**268       * 批量取消授权269       */270      @RequiresPermissions("system:role:edit")271      @Log(title = "角色管理", businessType = BusinessType.GRANT)272      @PostMapping("/authUser/cancelAll")273      @ResponseBody274      public AjaxResult cancelAuthUserAll(Long roleId, String userIds)275      {276          return toAjax(roleService.deleteAuthUsers(roleId, userIds));277      }278  279      /**280       * 选择用户281       */282      @RequiresPermissions("system:role:list")283      @GetMapping("/authUser/selectUser/{roleId}")
  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#L377

  374      {375          return roleMapper.updateRole(role);376      }377  378      /**379       * 取消授权用户角色380       * 381       * @param userRole 用户和角色关联信息382       * @return 结果383       */384      @Override385      public int deleteAuthUser(SysUserRole userRole)386      {387          return userRoleMapper.deleteUserRoleInfo(userRole);388      }389  390      /**391       * 批量取消授权用户角色392       * 393       * @param roleId 角色ID394       * @param userIds 需要删除的用户数据ID395       * @return 结果
  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#L38

   35  		</foreach>36  	</insert>37  	38  	<delete id="deleteUserRoleInfo" parameterType="SysUserRole">39  		delete from sys_user_role where user_id=#{userId} and role_id=#{roleId}40  	</delete>41  	42  	<delete id="deleteUserRoleInfos">43  	    delete from sys_user_role where role_id=#{roleId} and user_id in44   	    <foreach collection="userIds" item="userId" open="(" separator="," close=")">45   	        #{userId}46              </foreach> 47  	</delete>48  </mapper> 
  1. roleService.c

Evidence location: https://github.com/yangzongzhuan/RuoYi/blob/master/roleService.c
5. 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.

删除前调用 roleService.checkRoleDataScope(roleId) 和每个 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.gsyq.cn/news/1547725.html

相关文章:

  • 2026 年人来灯亮智能开关推荐:优智者感应灵敏 - 思溯深度专栏
  • 用过才敢说!2026年最值得用的专业AI论文平台
  • 2026内江焊缝探伤检测权威机构排行 TOP 本地高频选择,无损检测 + UT+RT+PT 检测 附电话地址 - 中安检测集团
  • hu
  • 2026黔南焊缝探伤检测权威机构排行 TOP 本地高频选择,无损检测 + UT+RT+PT 检测 附电话地址 - 中安检测集团
  • Hermes Agent Skill Runtime 架构拆解:让 AI Agent 不再从零开始
  • 终极免费浏览器AI图像标注工具:make-sense.ai完全指南
  • 2026随州焊缝探伤检测权威机构排行 TOP 本地高频选择,无损检测 + UT+RT+PT 检测 附电话地址 - 中安检测集团
  • 基于MOBI文件解析的Kindle封面元数据修复技术
  • 拉萨市空调维修/中央空调维修|本地避坑指南,满分五星平台|欧米到家首选 - 欧米到家
  • 2026柳州焊缝探伤检测权威机构排行 TOP 本地高频选择,无损检测 + UT+RT+PT 检测 附电话地址 - 中安检测集团
  • 2026内蒙古焊缝探伤检测权威机构排行 TOP 本地高频选择,无损检测 + UT+RT+PT 检测 附电话地址 - 中安检测集团
  • 授权委托书公证办理周期大概多久?授权委托书公证不用本人到场能操作吗?
  • TPU2协处理器:嵌入式实时系统定时任务的硬件化解决方案
  • 2026六安焊缝探伤检测权威机构排行 TOP 本地高频选择,无损检测 + UT+RT+PT 检测 附电话地址 - 中安检测集团
  • 2026连云港焊缝探伤检测权威机构排行 TOP 本地高频选择,无损检测 + UT+RT+PT 检测 附电话地址 - 中安检测集团
  • 数字员工是什么?熊猫智汇在AI销售工具中的作用与价值是什么?
  • 2026韶关焊缝探伤检测权威机构排行 TOP 本地高频选择,无损检测 + UT+RT+PT 检测 附电话地址 - 中安检测集团
  • 2026年 武汉GEO优化服务商推荐榜:精准推广/全域运营/流量优化与排名提升的深度解析 - 品牌发掘
  • 2026年国内激光砍树设备品牌实力排行盘点 - 起跑123
  • 2026黔西焊缝探伤检测权威机构排行 TOP 本地高频选择,无损检测 + UT+RT+PT 检测 附电话地址 - 中安检测集团
  • [PWNHUB 公开赛 2018]傻 fufu 的工作日
  • 2026开封焊缝探伤检测权威机构排行 TOP 本地高频选择,无损检测 + UT+RT+PT 检测 附电话地址 - 中安检测集团
  • SQLyog社区版:免费高效的MySQL数据库管理终极指南
  • 2026克拉玛依焊缝探伤检测权威机构排行 TOP 本地高频选择,无损检测 + UT+RT+PT 检测 附电话地址 - 中安检测集团
  • 昆山兴运建设工程有限公司:化工厂/厂房/超市拆除回收专业服务商 - 品牌推荐官
  • 四川无尘洁净车间建造者-四川华川洁净公司 - 华川洁净
  • RimWorld模组管理的终极解决方案:RimSort完整指南
  • 2026葫芦岛焊缝探伤检测权威机构排行 TOP 本地高频选择,无损检测 + UT+RT+PT 检测 附电话地址 - 中安检测集团
  • 2026上海品质团建服务商排行TOP6 - 陀螺团建