Apache Shiro权限绕过漏洞(CVE-2020-11989)

Apache Shiro 作为常用的 Java 安全框架,拥有执行身份验证、授权、密码和会话管理等功能,通常会和 Spring 等框架一起搭配使用来开发 Web 应用。

影响范围

  • Apache Shiro < 1.5.3
  • Spring 框架中只使用 Shiro 鉴权

漏洞复现

测试 Demo :

https://github.com/l3yx/springboot-shiro

权限配置如下,其中 /admin 下的路由需要登录才能访问

@Bean
ShiroFilterFactoryBean shiroFilterFactoryBean(){
   ShiroFilterFactoryBean bean = new ShiroFilterFactoryBean();
   bean.setSecurityManager(securityManager());
   bean.setLoginUrl("/login");
   bean.setSuccessUrl("/index");
   bean.setUnauthorizedUrl("/unauthorizedurl");
   Map<String, String> map = new LinkedHashMap<>();
   map.put("/doLogin", "anon");
   map.put("/admin/*", "authc");
   bean.setFilterChainDefinitionMap(map);
   return  bean;
}
---
@GetMapping("/admin/page")
public String admin() {
   return "admin page";
}

maven 打包项目为 test.war ,部署于 Tomcat 。该漏洞成功利用存在下面两个条件

1、应用不能部署在根目录,也就是需要 context-pathserver.servlet.context-path=/test ,如果为根目录则 context-path 为空,就会被 CVE-2020-1957 的 patch 将 URL 格式化,值得注意的是若 Shiro 版本小于 1.5.2 的话那么该条件就不需要

2、Spring 控制器中没有另外的权限校验代码

如果直接访问 /test/admin/page ,会返回302跳转要求登录
在这里插入图片描述
但是访问/;/test/admin/page , 就能直接绕过 Shiro 权限验证,访问到 /admin 路由中的信息
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值