[CVE-2020-11989]Apache Shiro权限绕过漏洞

影响范围:

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

环境搭建:
https://github.com/threedr3am/learnjavabug/blob/master/shiro/auth-bypass(shiro%3C1.5.3)/

注意这里配置的是:
/bypass/*,而不是/bypass/**/bypass/**是不能用这个漏洞来绕过的。
在这里插入图片描述

这个洞利用价值不大,基本使用shiro做认证的系统,都会利用/** authc兜底

注:

  • *:匹配一个或者多个任意的字符。
  • **:匹配零个或者多个目录。

参考:
https://jingyan.baidu.com/article/2fb0ba40fd4c0000f2ec5fd1.html

利用方式一:

通过访问 http://localhost:8080/bypass/bypass/aaa%252Faaa (两次编码的"aaa/aaa") 绕过接口/bypass的认证控制
漏洞点在于tomcat只会对url进行一次解码,而shiro进行了两次解码
两次解码后,路径变成 http://localhost:8080/bypass/bypass/aaa/aaa 绕过了权限 “/bypass/*” 的match

利用方式二:

通过访问 http://localhost:8080/;/bypass/bypass/111 绕过接口/bypass的认证控制
漏洞点在于shiro会对;分号进行截断,访问的 /;/bypass/bypass/111 变成了 / ,自然就绕过了权限 “/bypass/*” 的match

https://github.com/threedr3am/learnjavabug/blob/master/shiro/auth-bypass(shiro%3C1.5.3)/src/main/java/me/threedr3am/bug/shiro/bypass/auth/controller/BypassTestController.java

org\apache\shiro\shiro-web\1.5.2\shiro-web-1.5.2.jar!\org\apache\shiro\web\util\WebUtils#decodeAndCleanUriString(HttpServletRequest request, String uri)
在这里插入图片描述

调试tomcat

为了了解Tomcat如何对请求URL进行解析处理的,
需要下的断点在:
org\apache\tomcat\embed\tomcat-embed-core\8.5.43\tomcat-embed-core-8.5.43.jar!\org\apache\catalina\connector\CoyoteAdapter#service(Request req, Response res)
参考:
Tomcat URL解析差异性导致的安全问题

然后在这里下断点:

postParseSuccess = this.postParseRequest(req, request, res, response);

在这里插入图片描述

利用方式一的总结:

当进入应用后我们的请求页面被解析成/hello/a%2fa,所以它可以进入到spring controller中的/hello/{name},但是因为shiro再次做了url解码,导致判断的uri成为了/hello/a/a 它不属于我们配置的权限判断地址/hello/*。
此绕过核心原理可以归因为shiro与spring对RFC标准实现的差异。

参考

  • https://xlab.tencent.com/cn/2020/06/30/xlab-20-002/
  • https://mp.weixin.qq.com/s/yb6Tb7zSTKKmBlcNVz0MBA

猜你喜欢

转载自blog.csdn.net/caiqiiqi/article/details/107209038