1. 程式人生 > 其它 >滲透乾貨分享:spring-boot-actuator-logview 檔案包含漏洞復現

滲透乾貨分享:spring-boot-actuator-logview 檔案包含漏洞復現

雨筍教育小編又來分享乾貨了,常見檔案包含漏洞復現分析:

前言

日常搬磚過程中在github發現的一個CVE,https://github.com/ARPSyndicate/kenzer-templates/blob/1f1dd550ddbde72cbe378452973b93b3e62003f5/jaeles/cvescan/medium/CVE-2021-21234.yam 看著帶了springboot就分析了下

環境搭建

git clone https://github.com/cristianeph/vulnerability-actuator-log-viewer

啟動之後訪問 //localhost:8887/manage/log/

漏洞復現分析

根據springboot啟動日誌發現/log/view 對應的方法為eu.hinsch.spring.boot.actuator.logview.LogViewEndpoint.view

對應程式碼

@RequestMapping("/view")

public void view(@RequestParam String filename,

@RequestParam(required = false) String base,

@RequestParam(required = false) Integer tailLines,

HttpServletResponse response) throws IOException {

securityCheck(filename);

response.setContentType(MediaType.TEXT_PLAIN_VALUE);

Path path = loggingPath(base);

FileProvider fileProvider = getFileProvider(path);

if (tailLines != null) {

fileProvider.tailContent(path, filename, response.getOutputStream(), tailLines);

}

else {

fileProvider.streamContent(path, filename, response.getOutputStream());

}

}

先從RequestParam獲取filename引數,然後呼叫securityCheck進行檢查,判斷filename是否包含..

安全檢查通過之後,將application.properties中logging.path和base拼接,返回path,base從RequestParam獲取,並未經過securityCheck

然後生成fileProvider 在呼叫 streamContent

將path和base拼接,然後用fileinputstream開啟,造成任意檔案讀取

想要和雨筍的大佬們一起挖漏洞嗎?滲透測試課程等你來報名,趁這個暑假悄悄拔尖

滲透測試零基礎公開課:https://ke.qq.com/course/3383785?quicklink=1

加v:邀請請滲透測試交流群718860842