taibeihacker
Moderator
0x00 漏洞描述
Apache Shiro是一個強大且易用的Java安全框架,執行身份驗證、授權、密碼和會話管理。之前Apache Shiro身份驗證繞過漏洞CVE-2020-11989的修復補丁存在缺陷,在1.5.3及其之前的版本,由於shiro在處理url時與spring仍然存在差異,依然存在身份校驗繞過漏洞由於處理身份驗證請求時出錯,遠程攻擊者可以發送特製的HTTP請求,繞過身份驗證過程並獲得對應用程序的未授權訪問。0x01 漏洞影响
Apache Shiro 1.6.00x02 环境搭建
1.下載項目到本地https://github.com/l3yx/springboot-...iroLoginController中的後台驗證/admin/page替換為/admin/{name}

0x03 代码说明
1.ShiroConfig.java(pringboot-shiro-master\src\main\java\org\syclover\srpingbootshiro\ShiroConfig.java)權限配置, 當請求/admin/* 資源時, 302 跳轉到登陸頁面進行身份認證

0x04 漏洞复现
1.不在請求路由中指定資源名稱時,不觸發身份驗證,也無資源返回:





0x05 漏洞分析
可以看到出問題的地方在org.apache.shiro.web.util.Webutils#getPathWithinApplication,shiro1.5.3進行了修改,直接在這裡下斷點,然後dubug調試


public String admin2() {
return 'please login, admin';
}http://192.168.1.9:8080/srpingboot-shiro-0.0.1-SNAPSHOT/admin/*


跟進removeSemicolon

同樣,將;後的內容截斷,包括;
再看下Spring如何處理

Spring沒有問題,獲取到的是/admin/;page,然後將;page作為一整個字符串,匹配/admin/{name}路由,導致越權
再看下是怎麼處理URL的
`org.springframework.web.util.UrlPathHelper#decodeAndCleanUriString

removeSemicolonContent # 去除;及以後部分
decodeRequestString # 進行urldecode解碼
getSanitizedPath # 將//替換為/而shiro則相反

//line 111
public static String getPathWithinApplication(HttpServletRequest request) {
return normalize(removeSemicolon(getServletPath(request) + getPathInfo(request)));
}pring-web-5.2.5.RELEASE.jar//org.springframework.web.util.UrlPathHelper.java
//line 459
private String decodeAndCleanUriString(HttpServletRequest request, String uri) {
uri=removeSemicolonContent(uri);
uri=decodeRequestString(request, uri);
uri=getSanitizedPath(uri);
return uri;
}