2019年4月17日,Oracle WebLogic wls9-async反序列化远程命令执行漏洞(CVE-2019-2725)来势迅猛,如何发现和修复此漏洞备受业内人士关注,本文将为大家一一解开这些谜题。
漏洞描述
2019年4月17日,国家信息安全漏洞共享平台(CNVD)收录了由中国民生银行股份有限公司报送的Oracle WebLogic wls9-async反序列化远程命令执行漏洞(CNVD-C-2019-48814)。此漏洞存在于weblogic自带的wls9_async_response.war组件中,攻击者利用该漏洞,可在未授权的情况下远程执行命令。
CNVD对该漏洞的综合评级为“高危”,重点是那种架构简单,外网直接访问weblogic的应用(具体内容见:http://www.cnvd.org.cn/webinfo/show/4989),截止发稿定义漏洞为CVE-2019-2725。
Oracle官网于2019年4月27日发布了WebLogic 10.3.6.0和12.1.3.0版本的漏洞修复补丁。
影响范围
受该漏洞影响的版本:Weblogic: 9.2~12.1.3(特别是外网直接访问weblogic的应用)
漏洞分析
总体来说每一个weblogic server实例都会发布一个内部的异步web service应用( bea_wls9_async_response.war),该服务处理异步请求响应功能。但可以使用参数禁用它。
Disabling The Internal Asynchronous Service
By default, every WebLogic Server instance deploys an internal asynchronous Web Service that handes the asynchronous request-response feature. To specify that you do not want to deploy this internal service, start the WebLogic Server instance using the -Dweblogic.wsee.skip.async.response=true Java system property.
One reason for disabling the asynchronous service is if you use a WebLogic Server instance as a Web proxy to a WebLogic cluster. In this case, asynchronous messages will never get to the cluster, as required, because the asynchronous service on the proxy server consumes them instead. For this reason, you must disable the asynchronous service on the proxy server using the system property.
漏洞排查:
存在此漏洞的系统访问网址http://ip:port/_async/AsyncResponseService,会出现以下页面:
哪种应用可以禁用:
如果确认WebLogic domain没有使用异步webservices,那么完全可以禁用这个组件。
如何确认是否使用异步webservices:
使用weblogic异步webservices一般会引用下面三个weblogic自带的class:
import weblogic.wsee.async.AsyncPreCallContext;
import weblogic.wsee.async.AsyncCallContextFactory;
import weblogic.wsee.async.AsyncPostCallContext.
使用weblogic异步webservices示例:
package examples.webservices.async_req_res;import weblogic.jws.WLHttpTransport;import weblogic.jws.ServiceClient; import weblogic.jws.AsyncResponse; import weblogic.jws.AsyncFailure; import weblogic.wsee.async.AsyncPreCallContext; import weblogic.wsee.async.AsyncCallContextFactory; import weblogic.wsee.async.AsyncPostCallContext; import javax.jws.WebService;import javax.jws.WebMethod;import examples.webservices.async_req_res.StockQuotePortType; import java.rmi.RemoteException;@WebService(name="StockQuoteClientPortType", serviceName="StockQuoteClientService", targetNamespace="http://examples.org/")@WLHttpTransport(contextPath="asyncClient", serviceUri="StockQuoteClient", portName="StockQuoteClientServicePort")/** * Client Web Service that invokes the StockQuote Service asynchronously. */public class StockQuoteClientImpl { @ServiceClient(wsdlLocation="http://localhost:7001/async/StockQuote?WSDL", serviceName="StockQuoteService", portName="StockQuote") private StockQuotePortType port; @WebMethod public void asyncOperation (String symbol, String userName) throws RemoteException { AsyncPreCallContext apc = AsyncCallContextFactory.getAsyncPreCallContext(); apc.setProperty("userName", userName); try { port.getQuoteAsync(apc, symbol ); System.out.println("in getQuote method of StockQuoteClient WS"); } catch (RemoteException re) { System.out.println("RemoteException thrown"); throw new RuntimeException(re); } } @AsyncResponse(target="port", operation="getQuote") public void onGetQuoteAsyncResponse(AsyncPostCallContext apc, int quote) { // Get the userName property we set on AsyncPreCallContext String userName = (String)apc.getProperty("userName"); System.out.println("-------------------"); System.out.println(username + " Got quote " + quote ); System.out.println("-------------------"); } @AsyncFailure(target="port", operation="getQuote") public void onGetQuoteAsyncFailure(AsyncPostCallContext apc, Throwable e) { System.out.println("-------------------"); e.printStackTrace(); System.out.println("-------------------"); } }
整改建议
更新补丁修复
4月27日官方已经发布WebLogic 10.3.6.0和12.1.3.0版本的漏洞修复补丁,这两个版本可以通过打补丁的方式修复,其它未发布补丁的版本只能通过临时方法修复此漏洞。
10.3.6.0版本:
Jan PSU 10.3.6.0.190115 Patch 28710912 + Overlay Patch 29694149 on 10.3.6.0.190115 for CVE-2019-2725
Apr PSU 10.3.6.0.190416 Patch 29204678 + Overlay Patch 29694149 on 10.3.6.0.190416 for CVE-2019-2725
12.1.3.0版本:
Jan 2019 PSU 12.1.3.0.190115 Patch 28710923 + (Patch should be available on April 29, 2019 for CVE-2019-2725)
Apr 2019 PSU 12.1.3.0.190416 Patch 29204657 + (Patch should be available on April 29, 2019 for CVE-2019-2725)
注意:根据当前的psu选择合适的补丁号;先打季度psu,然后才能打针对这个漏洞的补丁
临时修复方案一:启动脚本中禁用异步WebService
在启动脚本中添加参数 -Dweblogic.wsee.skip.async.response=true,可以禁用此组件, 从而避免此漏洞。但只适用与没有使用异步WebService的环境。
示例:
调整前效果:
调整后效果:组件访问被禁用:
临时修复方案二:删除异步WebService的war包
删除$WLS_HOME/server/lib下的bea_wls9_async_response.war包
删除$DOMAIN_HOME/servers/下的bea_wls9_async_response.war包
示例如下:
find /weblogic/Middleware/wlserver_10.3/lib -name bea_wls9_async_response.war
find /weblogic/domains/base_domain/servers -name bea_wls9_async_response.war
注意:在删除bea_wls9_async_response.war前,必须确认应用程序未使用此war包
临时修复方案三:防火墙、负载均衡器实施限制
在防火墙、负载均衡器等前端设备上加策略禁止访问带有这种/_async上下文根。
《云和恩墨技术通讯》(5月刊)下载链接:
https://cs.enmotech.com/docDownload/2806(复制链接到浏览器中打开,或者点击“阅读原文”立即下载)
复制以上链接或者点击“阅读原文”抢先下载,下载需要注册墨天轮。