Trustwave's 2024 Retail Report Series Highlights Alarming E-Commerce Threats and Growing Fraud Against Retailers. Learn More

Trustwave's 2024 Retail Report Series Highlights Alarming E-Commerce Threats and Growing Fraud Against Retailers. Learn More

Services
Managed Detection & Response

Eliminate active threats with 24/7 threat detection, investigation, and response.

Co-Managed SOC (SIEM)

Maximize your SIEM investment, stop alert fatigue, and enhance your team with hybrid security operations support.

Advisory & Diagnostics

Advance your cybersecurity program and get expert guidance where you need it most.

Penetration Testing

Test your physical locations and IT infrastructure to shore up weaknesses before exploitation.

Database Security

Prevent unauthorized access and exceed compliance requirements.

Email Security

Stop email threats others miss and secure your organization against the #1 ransomware attack vector.

Digital Forensics & Incident Response

Prepare for the inevitable with 24/7 global breach response in-region and available on-site.

Firewall & Technology Management

Mitigate risk of a cyberattack with 24/7 incident and health monitoring and the latest threat intelligence.

Solutions
BY TOPIC
Microsoft Security
Unlock the full power of Microsoft Security
Offensive Security
Solutions to maximize your security ROI
Rapidly Secure New Environments
Security for rapid response situations
Securing the Cloud
Safely navigate and stay protected
Securing the IoT Landscape
Test, monitor and secure network objects
Why Trustwave
About Us
Awards and Accolades
Trustwave SpiderLabs Team
Trustwave Fusion Security Operations Platform
Trustwave Security Colony
Partners
Technology Alliance Partners
Key alliances who align and support our ecosystem of security offerings
Trustwave PartnerOne Program
Join forces with Trustwave to protect against the most advance cybersecurity threats

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 TRUSTWAVE

Trustwave 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