Trustwave SpiderLabs Uncovers Unique Cybersecurity Risks in Today's Tech Landscape. Learn More

Trustwave SpiderLabs Uncovers Unique Cybersecurity Risks in Today's Tech Landscape. Learn More

Services
Capture
Managed Detection & Response

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

twi-managed-portal-color
Co-Managed SOC (SIEM)

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

twi-briefcase-color-svg
Advisory & Diagnostics

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

tw-laptop-data
Penetration Testing

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

twi-database-color-svg
Database Security

Prevent unauthorized access and exceed compliance requirements.

twi-email-color-svg
Email Security

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

tw-officer
Digital Forensics & Incident Response

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

tw-network
Firewall & Technology Management

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

Solutions
BY TOPIC
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
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
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:

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.

Latest SpiderLabs Blogs

Zero Trust Essentials

This is Part 5 in my ongoing project to cover 30 cybersecurity topics in 30 weekly blog posts. The full series can be found here.

Read More

Why We Should Probably Stop Visually Verifying Checksums

Hello there! Thanks for stopping by. Let me get straight into it and start things off with what a checksum is to be inclusive of all audiences here, from Wikipedia [1]:

Read More

Agent Tesla's New Ride: The Rise of a Novel Loader

Malware loaders, critical for deploying malware, enable threat actors to deliver and execute malicious payloads, facilitating criminal activities like data theft and ransomware. Utilizing advanced...

Read More