一 漏洞描述
Apache Shiro是一款开源安全框架,提供身份验证、授权、密码学和会话管理。Shiro框架直观、易用,同时也能提供健壮的安全性。
在Apache Shiro 1.5.2以前的版本中,在使用Spring动态控制器时,攻击者通过构造..;
这样的跳转,可以绕过Shiro中对目录的权限限制。
kali 环境配置
安装https协议、CA证书、dirmngr
apt-get update
apt-get install -y apt-transport-https ca-certificates
apt-get install dirmngr
添加GPG密钥并添加更新源
curl -fsSL https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/debian/gpg | sudo apt-key add -
echo ‘deb https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/debian/ buster stable’ | sudo tee /etc/apt/sources.list.d/docker.list
系统更新以及安装docker
apt-get update&&apt install docker-ce
启动docker服务器 和compose
service docker start || apt install docker-compose
下载vulhub
git clone https://github.com/vulhub/vulhub.git
二 漏洞复现
访问网址:ip:端口 登录admin vulhub并抓包 页面显示302重定向
构造一个恶意请求/xxx/..;/admin/
以绕过身份验证检查并访问管理页面
三 漏洞分析
这个应用中对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;
}
修复方案
https://github.com/apache/shiro/commit/3708d7907016bf2fa12691dff6ff0def1249b8ce#diff-98f7bc5c0391389e56531f8b3754081aR139
修改了requestURI
的获取方式,经过更准确的解析获取
参考链接
- https://github.com/apache/shiro/commit/3708d7907016bf2fa12691dff6ff0def1249b8ce#diff-98f7bc5c0391389e56531f8b3754081aL139
- https://xz.aliyun.com/t/8281
b8ce#diff-98f7bc5c0391389e56531f8b3754081aL139- https://xz.aliyun.com/t/8281
- https://blog.spoock.com/2020/05/09/cve-2020-1957/