Trustwave SpiderLabs Uncovers Ov3r_Stealer Malware Spread via Phishing and Facebook Advertising. Learn More

Trustwave SpiderLabs Uncovers Ov3r_Stealer Malware Spread via Phishing and Facebook Advertising. Learn More

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.

Microsoft Exchange Server Attacks
Stay protected against emerging threats
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
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
SpiderLabs Blog

Java is So Confusing...

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:


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!

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.

Latest SpiderLabs Blogs

Hunting For Integer Overflows In Web Servers

Allow me to set the scene and start proceedings off with a definition of an integer overflow, according to Wikipedia:

Read More

Welcome to Adventures in Cybersecurity: The Defender Series

I’m happy to say I’m done chasing Microsoft certifications (AZ104/AZ500/SC100), and as a result, I’ve had the time to put some effort into a blog series that hopefully will entertain and inform you...

Read More

Trustwave SpiderLabs: Insights and Solutions to Defend Educational Institutions Against Cyber Threats

Security teams responsible for defending educational institutions at higher education and primary school levels often find themselves facing harsh lessons from threat actors who exploit the numerous...

Read More