Nytro Posted February 5, 2013 Report Posted February 5, 2013 Java SE CPU Feb 2013 Updates ExplainedAuthored by Adam Gowdiak | Site security-explorations.comThese are the technical details surrounding security issues reported by Security Explorations to Oracle and addressed in the Feb 2013 SE CPU update.Hello All,Below, we are providing you with technical details regardingsecurity issues reported by us to Oracle and addressed by thecompany in a recent Feb 2013 Java SE CPU [1].[Issue 29]This issue allows for the creation of arbitrary Proxy objectsfor interfaces defined in restricted packages. Proxy objectsdefined in a NULL class loader namespaces are of a particularinterest here. Such objects can be used to manipulate instancesof certain restricted classes.In our Proof of Concept code we create such a proxy object forthe com.sun.xml.internal.bind.v2.model.nav.Navigator interface.In order to use the aforementioned proxy object, we need aninstance of that interface too. We obtain it with the help ofIssue 28, which allows to access arbitrary field objects fromrestricted classes and interfaces. As a result, by combiningIssue 27-29, one can use Navigator interface and make use ofits sensitive Reflection API functionality such as obtainingaccess to methods of arbitrary classes. That condition can befurther leveraged to obtain a complete JVM security bypass.Please, note that our Proof of Concept code for Issues 27-29was reported to Oracle in Apr 2012 and depending Issues 27-28were addressed by the company sooner than Issue 29. Testingof the PoC will thus give best results on older versions ofJava SE 7.[Issue 50]Issue 50 allows to violate a fundamental security constraintof Java VM, which is type safety. This vulnerability is anotherinstance of the problem related to the unsafe deserializationimplemented by com.sun.corba.se.impl.io.ObjectStreamClass class.Its first instance was fixed by Oracle in Oct 2011 [2] and itstemmed from the fact that during deserialization insufficienttype checks were done with respect to object references thatwere written to target object instance created by the means ofdeserialization. Such a reference writing was accomplished withthe use of a native functionality of sun.corba.Bridge class.The problem that we found back in Sep 2012 was very similar tothe first one. It was located in the same code (class) and wasalso exploiting direct writing of object references to memorywith the use of putObject method. While the first type confusionissue allowed to write object references of incompatible typesto correct field offsets, Issue 50 relied on the possibility towrite object references of incompatible types to...invalid fieldoffsets.It might be also worth to mention that Issue 50 was found tobe present in Java SE Embedded [3]. That is Java version thatis based on desktop Java SE and is used in today’s most powerfulembedded systems such as aircraft and medical systems [4]. Weverified that Oracle Java SE Embedded ver. 7 Update 6 from 10Aug 2012 for ARM / Linux contained vulnerable implementationof ObjectStreamClass class.Unfortunately, we don't know any details regarding the impactof Issue 50 in the embedded space (which embedded systems arevulnerable to it, whether any feasible attack vectors exist,etc.). So, it's up to Oracle to clarify any potential concernsin that area.[Issue 52]Issue 52 relies on the possibility to call no-argument methodson arbitrary objects or classes. The vulnerability has its originin com.sun.jmx.mbeanserver.Introspector class which is locatedin the same package as the infamous MBeanInstantiator bug foundin the wild in early Jan 2013. The flaw stems from insecure callto invoke method of java.lang.reflect.Method class: if (method != null) return method.invoke(obj, new Object[0]);In our Proof of Concept code we exploit the above implementationby making a call to getDeclaredMethods method of java.lang.Classclass to gain access to methods of restricted classes. This isaccomplished with the use of the following code sequence:Introspector.elementFromComplex((Object)clazz,"declaredMethods")Access to public method objects of arbitrary restricted classesis sufficient to achieve a complete Java VM security sandboxcompromise. We make use of DefiningClassLoader exploit vectorfor that purpose.[Issue 53]Issue 53 stems from the fact that Oracle's implementation of newsecurity levels introduced by the company in Java SE 7 Update 10did not take into account the fact that Applets can be instantiatedwith the use of serialization. Such a possibility is indicated bothin HTML 4 Specification [5] as well as in Oracle's code.HTML 4 Specification contains the following description for the"object" attribute of APPLET element:object = cdata [CS] This attribute names a resource containing a serialized representation of an applet's state. It is interpreted relative to the applet's codebase. The serialized data contains the applet's class name but not the implementation. The class name is used to retrieve the implementation from a class file or archive.Additionally, Java 7 Update 10 (and 11) reveal the following codelogic when it comes to the implementation of new security features(Java Control Panel security levels).[excerpt from sun.plugin2.applet.Plugin2Manager class] String object_attr = getSerializedObject(); String code_attr = getCode(); ... if(code_attr != null) { Class class1 = plugin2classloader.loadCode(code_attr); ... if(class1 != null) if (fireAppletSSVValidation()) ... } else { if(!isSecureVM) return;adapter.instantiateSerialApplet(plugin2classloader,object_attr); ... }The above clearly shows that the conditional block implementingApplet instantiation via deserialization does not contain a callto fireAppletSSVValidation method. This method conducts importantsecurity checks corresponding to security levels configured byJava Control Panel. The lack of a call to security checking methodis equivalent to "no protection at all" as it allows for a silentJava exploit in particular.What's worth mentioning is that for Google Chrome the followingHTML sequence needed to be used to activate target Applet code:<object type="application/x-java-applet" object="BlackBox.ser">---We have made our original reports sent to Oracle and describingIssues 29, 50, 52 and 53 available for download from our projectdetails page:http://www.security-explorations.com/en/SE-2012-01-details.htmlAlong with those reports we have also published the results ofour quick Vulnerability Fix Experiment regarding Issue 50. We'venever heard a word from Oracle regarding it. Company's fix forIssue 50 is not a mirror of the one we had proposed, but it doesrely on Class object instances for hashtable access / caching oftranslated ObjectStreamClass fields.At the end, we would like to question Oracle's evaluation of theimpact of Java vulnerabilities fixed by the Feb 2013 Java SE CPU.Oracle emphasized that patched vulnerabilities affect primarilyJava Plugin / desktop environments and that only 3 of them applyto client and server deployments of Java. The 3 vulnerabilitiesOracle refers to are specifically the following ones:CVE-2013-0437 Subcomponent 2DCVE-2013-1478 Subcomponent 2DCVE-2013-1480 Subcomponent AWTNone of the vulnerabilities above seem to refer to the componentswhere our discoveries were made (i.e. CORBA, JMX / BEANS).The tests we have conducted yesterday against the latest versionof Oracle GlassFish Server 3.1.2.2 (with security manager enabled)and RMI Registry from JDK 7 Update 11 confirmed the possibility tolaunch an attack against remote RMI server with the use of a JavaSE vulnerability. We tested Issues patched by the recent CPU suchas the MBeanInstantiator bug, Issue 50 and 52 and were able to:1) remotely load custom classes into the target Java RMI server (over RMI protocol),2) completely break Java security sandbox with the use of a Java SE vulnerability (the one which "can be exploited only through untrusted Java Web Start applications / untrusted Java applets" according to Oracle's CPU).Although Oracle is aware [6] that Java SE vulnerabilities can bealso exploited "in servers, by supplying malicious input to APIsin the vulnerable server component", the company rather underminessuch a possibility by delivering a message that a majority of thevulnerabilities affect Java Plugin in the web browser or that insome cases, the exploitation scenario of Java SE bugs on serversis very improbable.In general, relying on a vulnerable Java SE version makes all ofthe products depending on it potentially vulnerable unless thereis absolutely *no way* that a vulnerable component can be reachedby an attacker. As long as an attack vector through RMI protocolis valid, a potential for remote exploitation of security issuesin Java SE on servers should be always concerned.Thank You.Best Regards,Adam Gowdiak---------------------------------------------Security Explorationshttp://www.security-explorations.com"We bring security research to the new level"---------------------------------------------References:[1] Oracle Java SE Critical Patch Update Advisory - February 2013http://www.oracle.com/technetwork/topics/security/javacpufeb2013-1841061.html[2] Oracle Java IIOP Deserialization Type Confusion Remote Code Execution Vulnerability http://www.zerodayinitiative.com/advisories/ZDI-11-306/[3] Oracle Java SE Embeddedhttp://www.oracle.com/us/technologies/java/embedded/standard-edition/overview/index.html[4] Oracle making embedded Java pushhttp://www.infoworld.com/d/application-development/oracle-making-embedded-java-push-203168[5] HTML 4 Specification, Including an applet: the APPLET element http://www.w3.org/TR/html401/struct/objects.html#h-13.4[6] February 2013 Critical Patch Update for Java SE Releasedhttps://blogs.oracle.com/security/entry/february_2013_critical_patch_updateSursa: Java SE CPU Feb 2013 Updates Explained ? Packet Storm Quote
Nytro Posted February 6, 2013 Author Report Posted February 6, 2013 + Java SE Proof Of Concept Code ? Packet Storm Quote