You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First register the user, the permission is:user
(首先,注册用户,权限是user)
@Component
public class StpInterfaceImpl implements StpInterface {
@Override
public List<String> getPermissionList(Object loginId, String loginType) {
List<String> list = new ArrayList<String>();
list.add("user");
return list;
}
}
Register an interceptor whose interception address is:admin/**,Need permission:admin
(注册一个拦截器,地址是admin/**,需要权限admin)
@Configuration
public class SaTokenConfigure implements WebMvcConfigurer {
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new SaInterceptor(handler -> {
SaRouter
.match("/**")
.notMatch("/user/doLogin")
.check(r -> StpUtil.checkLogin());
SaRouter.match("admin/**", r -> StpUtil.checkPermission("admin"));
})).addPathPatterns("/**");
}
}
Then write a login interface, an admin interface, the interface address is:/admin/** or /admin/*
(然后写一个登录接口,一个admin接口,admin接口地址是/admin/**或者/admin/*)
@RestController
public class UserController {
// Test login, browser access: http://localhost:8081/user/doLogin?username=zhang&password=123456
@RequestMapping("/user/doLogin")
public String doLogin(String username, String password) {
if("zhang".equals(username) && "123456".equals(password)) {
StpUtil.login(10001);
return "success";
}
return "fail";
}
@RequestMapping("/admin/**") // or "/admin/*"
public String getPassword() {
return "flag{m4ra7h0n}";
}
}
The text was updated successfully, but these errors were encountered:
m4ra7h0n
changed the title
SaToken和Spring对uri处理的差异化引发的越权漏洞(SaToken and Spring's differential handling of URIs raises overreach vulnerabilities)
SaToken和Spring对uri处理的差异化引发的越权漏洞(SaToken and Spring's differential handling of URIs raises authorization bypass vulnerabilities)
Sep 29, 2023
使用版本:
SaToken version <= 1.36.0
复现步骤:
First register the user, the permission is:
user
(首先,注册用户,权限是
user
)Register an interceptor whose interception address is:
admin/**
,Need permission:admin
(注册一个拦截器,地址是
admin/**
,需要权限admin
)Then write a login interface, an admin interface, the interface address is:
/admin/**
or/admin/*
(然后写一个登录接口,一个admin接口,admin接口地址是
/admin/**
或者/admin/*
)Login first(http://localhost:8081/user/doLogin?username=zhang&password=123456)
(首先登录)
Then access: /admin/anything
(然后访问/admin/anything)
修复建议
参考CVE-2023-20860
The text was updated successfully, but these errors were encountered: