Facebook Google Plus Twitter LinkedIn YouTube RSS Menu Search Resource - BlogResource - WebinarResource - ReportResource - Eventicons_066 icons_067icons_068icons_069icons_070

[R1] Oracle WebLogic RMI Registry UnicastRef Object Java Deserialization Remote Code Execution

Critical

Synopsis

Back in November of 2015, WebLogic was patched by Oracle to disallow deserialization of some dangerous Java objects. Oracle achieved this by blacklisting these specific packages:

  1. org.apache.commons.collections.functors
  2. com.sun.org.apache.xalan.internal.xsltc.trax
  3. javassist
  4. org.codehaus.groovy.runtime.ConvertedClosure
  5. org.codehaus.groovy.runtime.ConversionHandler
  6. org.codehaus.groovy.runtime.MethodClosure

This protected WebLogic from the original ysoserial serializable payloads like CommonCollections1 and Groovy1. Furthermore, this successfully protected WebLogic from new ysoserial payloads like CommonCollection3 (released in February 2016). However, it does not protect WebLogic from all payloads.

RMI Connect Back

On February 24, 2016 the Jenkins build server project released a security advisory. One of the vulnerabilities, SECURITY-232 aka CVE-2016-0788, indicated that it was possible for an unauthenticated remote attacker to open a JMRP (Java Remote Method Protocol) listener which allowed for remote code execution. JRMP is used in conjunction with RMI (Remote Method Invocation). RMI is great for a deserialization attack since the communication is built around the serialization and deserialization of objects. Research into how CVE-2016-0788 works yielded two interesting finds.

The first was a full implementation of that attack in Jenkins’ unit tests. The second interesting find was that the researcher credited with CVE-2016-0788, Moritz Bechler, forked ysoserial and published a number of new/undisclosed payloads.

In the case of WebLogic, we are interested in yososerial's JRMPListener.java payload. This serializes a RemoteObjectInvocationHandler which uses a UnicastRef object to establish a TCP connection to a remote server in order to get at the remote server's RMI registry. This connection uses JRMP so the client will deserialize whatever the server responds with, achieving unauthenticated remote code execution.

Exploiting WebLogic

To demonstrate the issue to ZDI and Oracle, Tenable created two scripts. The first script is a server that listens for the callback, called jrmp_listener.py. When the connect back connects to jrmp_listener.py it will send a CommonCollections3 payload in response which will trigger the RCE on WebLogic. The second script sends the serialized object to WebLogic via t3 on TCP port 7001 (just like the original FoxGlove attack), called jrmp_connect_back.py. In order to exploit WebLogic, jrmp_listener.py must be executed before jrmp_connect_back.py. The result of the exploitation will cause the connect back, which exists on its own thread, to be executed multiple times (which means an attacker could deliver multiple payloads).

Solution

Oracle has released WebLogic 12.2.1.2 to address this vulnerability.

Disclosure Timeline

2016-03-03 - Issue discovered
2016-03-15 - Final testing of issue
2016-03-16 - Submitted to ZDI, case bainesjr0002
2016-04-12 - ZDI indicates they cannot reproduce on 12.2.1, asks Tenable to look confirm
2016-04-13 - Tenable confirms RCE was unsuccessful on 12.2.1 but provides a PoC for 12.1.3
2016-04-13 - ZDI acknowledges new information, will evaluate
2016-04-26 - ZDI says "It seems that this one was tested against older version and it no longer hits for us. Do you agree?"
2016-04-27 - Tenable does not agree, asks for clarification from ZDI
2016-04-27 - ZDI acknowledges feedback, will gather information.
2016-05-02 - ZDI declines case bainesjr0002 due to failure to gain execution on 12.2.1. ZDI closes bainesjr0002
2016-05-05 - Tenable rewrites PoC to work with 12.2.1. Resubmitted to ZDI, case bainesjr0008 opened
2016-06-03 - ZDI indicates they "can't get this to hit" and provide Tenable with a stack trace.
2016-06-06 - The provided stack trace looks a little off so Tenable asks for further details. Tenable reverified that the attack does work on their test setup using 12.2.1 and the lastest Java (1.8.0_92)
2016-06-06 - Tenable realizes there is a bug in the PoC which causes deserialization failure if the connect back address is 13 bytes or longer. Ask ZDI if they can work around the bug else a new script will be produced.
2016-06-06 - ZDI confirms they can work around the bug
2016-06-13 - ZDI accepts and pays $1k.
2016-06-30 - ZDI reports issue to vendor
2017-01-17 - Oracle releases Jan 2017 CPU with fix
2017-01-24 - ZDI publishes issue (ZDI-17-055)

All information within TRA advisories is provided “as is”, without warranty of any kind, including the implied warranties of merchantability and fitness for a particular purpose, and with no guarantee of completeness, accuracy, or timeliness. Individuals and organizations are responsible for assessing the impact of any actual or potential security vulnerability.

Tenable takes product security very seriously. If you believe you have found a vulnerability in one of our products, we ask that you please work with us to quickly resolve it in order to protect customers. Tenable believes in responding quickly to such reports, maintaining communication with researchers, and providing a solution in short order.

For more details on submitting vulnerability information, please see our Vulnerability Reporting Guidelines page.

If you have questions or corrections about this advisory, please email [email protected]