ruoyi系统权限漏洞
contains更改为equals或者matches,否则会导致权限只要包含admin中字符即可获取超级管理员权限。
1 2 3
| "admin".contains("a"); "admin".contains("b");
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| package com.ruoyi.common.security.auth;
public class AuthLogic { private static final String ALL_PERMISSION = "*:*:*";
private static final String SUPER_ADMIN = "admin";
public boolean hasPermi(Collection<String> authorities, String permission) { return authorities.stream().filter(StringUtils::hasText) .anyMatch(x -> ALL_PERMISSION.matches(x) || PatternMatchUtils.simpleMatch(x, permission)); }
public boolean hasRole(Collection<String> roles, String role) { return roles.stream().filter(StringUtils::hasText) .anyMatch(x -> SUPER_ADMIN.matches(x) || PatternMatchUtils.simpleMatch(x, role)); } }
|