# 簡介:
Struts2是一個開源的Web開發框架,被廣泛使用。由于Struts2的底層性導致整個Web系統對其安全性的依賴程度高。最近,有兩個安全漏洞被公布了:S2-045,S2-046
# 危害:
* 高危(0day)
* 無前置條件
* 可執行任意命令,上傳shell
# 成因:
主要是因為Struts2默認文件上傳解析器jakarta的使用
* S2-045:It is possible to perform a RCE attack with a malicious Content-Type value. If the Content-Type value isn't valid an exception is thrown which is then used to display an error message to a user.
* S2-046:It is possible to perform a RCE attack with a malicious Content-Disposition value or with improper Content-Length header. If the Content-Disposition / Content-Length value is not valid an exception is thrown which is then used to display an error message to a user. This is a different vector for the same vulnerability described in S2-045 (CVE-2017-5638).
# 檢測工具:
* 上github直接搜索S2-045,S2-046
* Apache官方也有開源的POC
* 白帽子也開源了不少POC
# Getshell的方法:
達到觸發異常的條件,將shellcode 注入到content-type與filtename就行了
# 防御:
* 更新至最新版本
* 在WAF或者應用本身添加filter,針對POC字段
* 嚴格過濾Content-Type,filename中的內容,嚴謹ognl表達式相關字段
* 刪除commons-fileupload-x.x.x.jar文件,文件上傳不可用