LevelBlue Completes Acquisition of Cybereason. Learn more

LevelBlue Completes Acquisition of Cybereason. Learn more

Services
Cyber Advisory
Managed Cloud Security
Data Security
Manage Detection & Response
Email Security
Managed Network Infrastructure Security
Exposure Management
Security Operations Platforms
Incident Readiness & Response
SpiderLabs Threat Intelligence
Solutions
BY TOPIC
Offensive Security
Solutions to maximize your security ROI
Operational Technology
End-to-end OT security
Microsoft Security
Unlock the full power of Microsoft Security
Securing the IoT Landscape
Test, monitor and secure network objects
Why LevelBlue
About Us
Awards and Accolades
LevelBlue SpiderLabs
LevelBlue Security Operations Platforms
Security Colony
Partners
Microsoft
Unlock the full power of Microsoft Security
Technology Alliance Partners
Key alliances who align and support our ecosystem of security offerings

It's been a short while, but we find ourselves again with a Java vulnerability in our hands, this time via a PoC provided by IKVM.NET.

This particular vulnerability is somewhat different than most java vulnerabilities we run into, but feels like a natural progression from the last Java 0day we discussed in our blog (CVE-2013-1493). Both these vulnerabilities allow direct memory manipulation, something which is quite uncommon in Java.
The vulnerability itself has to do with type confusion between an int and a double, causing 8 bytes to be copied instead of 4, thus overwriting a pointer and allowing us to reach otherwise inaccessible area in the memory.

First of all, let's take a look at the source code provided by Jeroen Frijters in two parts:

10186_7d23e8db-dc11-436f-b9ec-c6d0d2940029

The important thing to note here is Union2, which contains an instance of the SystemClass defined below, this will become relevant later on.

Next, we'll take a look at the "disableSecurityManager" method, where the real magic happens!

7956_1054875b-0eca-4849-bef2-b183746dcbeb
What this code basically does is get references, via reflection, to the "TYPE" field within the class that represents double type, and the class that represents integer type. This field is usually used to denote the type of the object (duh..). The first highlighted box shows how we overwrite these values causing a type comparison between two integers to fail, whereas a type comparison between a double and an integer will pass. This overwrite is possible due to insufficient security checks (which are now fixed, in Java 7u21).

The next step will be to get a reference to "System.class" and place it in field2 of Union1.

The second highlighted part in the code will attempt to copy Union1.field1 (int, 4 bytes) into Union2.field1 (int, 4 bytes). However, due to the type confusion we caused above, Union1.field1 will be treated as a double, copying 8 bytes in total: 4 bytes from Union1.field1, and 4 bytes from Union1.field2 (which, as you may recall, is now System.class).

Now Union2.field2 is actually a reference to System.class, but due to the structure of our own defined SystemClass we can try and dereference inner members which are in fact inner members of System.class, including the infamous System.securityManager and disable it (set to null).

Given the exploitability factor of this vulnerability, expect to see it next time you meet an exploit kit. :)

Trustwave SWG customers are, of course, protected against attacks exploiting this vulnerability without any additional updates to the product.

I would like to thank my colleague Arseny Levin, for his help in analyzing this vulnerability.

ABOUT LEVELBLUE

LevelBlue is a globally recognized cybersecurity leader that reduces cyber risk and fortifies organizations against disruptive and damaging cyber threats. Our comprehensive offensive and defensive cybersecurity portfolio detects what others cannot, responds with greater speed and effectiveness, optimizes client investment, and improves security resilience. Learn more about us.

Latest Intelligence

Discover how our specialists can tailor a security program to fit the needs of
your organization.

Request a Demo