My other ClassLoader Is Your ClassLoader
This talk demonstrates how an attacker can exploit insecure handling of Parcelable and Serializable objects in Android applications to perform intent redirection and achieve arbitrary code execution. By leveraging the createPackageContext method, an attacker can load classes from a target application's ClassLoader if both applications are installed on the same device. The presentation highlights the prevalence of this vulnerability across various industry sectors and provides practical guidance on identifying and mitigating these risks. The speaker also introduces a Frida-based script for intercepting Android intents to facilitate the discovery of these vulnerabilities.
Exploiting Android ClassLoaders for Arbitrary Code Execution
TLDR: Attackers can achieve arbitrary code execution on Android by exploiting insecure deserialization of
ParcelableandSerializableobjects. By leveraging thecreatePackageContextmethod, an attacker can load classes from a target application'sClassLoaderif both apps share the same device. This research provides a practical path for pentesters to move from simple intent redirection to full code execution, and it underscores the critical need for strict input validation in exported Android components.
Android security models often rely on the assumption that inter-process communication (IPC) is inherently safe if the target component is not exported. However, this assumption crumbles when you consider how Parcelable and Serializable objects are handled during intent processing. The research presented at Black Hat 2024 regarding ClassLoader manipulation proves that if an application fails to validate the data it receives, an attacker can force it to load malicious classes, effectively turning a minor intent redirection bug into a full-blown remote code execution scenario.
The Mechanics of ClassLoader Hijacking
At the heart of this vulnerability is the way the Android runtime handles object deserialization. When an application receives an intent, it often uses methods like getParcelableExtra or getSerializable to extract data. If the application does not verify the class type of the incoming object, it may attempt to instantiate a class provided by the attacker.
The core technique involves using createPackageContext to gain access to the ClassLoader of a target application. Once an attacker has this context, they can load any class defined within that application's package. If the target application has exported components that accept Parcelable or Serializable data, the attacker can pass a payload that forces the application to instantiate a class of the attacker's choosing.
The following snippet demonstrates how an attacker might structure a malicious intent to trigger this behavior:
// Example of an intent payload targeting an exported component
val intent = Intent()
intent.setComponent(ComponentName("com.target.app", "com.target.app.TargetActivity"))
intent.putExtra("extra_request", maliciousParcelableObject)
startActivity(intent)
By crafting a Parcelable object that contains a reference to a class within the target's ClassLoader, the attacker can force the target application to execute code during the deserialization process. This is not just theoretical; it is a direct path to Broken Access Control and Injection vulnerabilities that bypass standard Android sandbox protections.
From Intent Redirection to Execution
During the research, the speaker demonstrated how this technique can be used to achieve Account Hijacking by redirecting intents to sensitive components. The process is straightforward for a researcher:
- Identify an exported component in the target application.
- Use a tool like Medusa to intercept and analyze the intents being passed to that component.
- Construct a payload that includes the necessary
ParcelableorSerializabledata to trigger the desired code path. - Execute the payload to hijack the component's logic.
The use of Frida is essential here. By hooking the getParcelableExtra method, you can observe exactly what data the application expects and how it handles the deserialization. If you find that the application is not checking the class type, you have found your entry point.
Real-World Impact and Detection
Pentesters should prioritize auditing any application that handles complex objects in its IPC layer. If you are performing a mobile assessment, look for getParcelableExtra or getSerializable calls in exported activities, services, or broadcast receivers. If the application is not using a whitelist to validate the class type of the incoming object, it is likely vulnerable.
The impact is significant. In many cases, this allows an attacker to bypass authentication, steal session tokens, or execute arbitrary code with the privileges of the target application. Given that many high-value applications in the retail, finance, and hospitality sectors rely on these mechanisms for data exchange, the risk is widespread.
Defensive Strategies
Defending against this requires a shift in how developers handle IPC. The most effective mitigation is to avoid passing complex objects through intents whenever possible. If you must use Parcelable or Serializable objects, you must implement strict validation.
Always check the class type of the object before processing it. Never assume that the data received from an intent is safe, even if it comes from a "trusted" source. Furthermore, ensure that your application's AndroidManifest.xml correctly restricts access to sensitive components using custom permissions. If a component does not need to be exported, set android:exported="false" immediately.
For those interested in the technical specifics of how these vulnerabilities have been exploited in the past, review the details for CVE-2014-7911 and CVE-2015-3825. These entries provide a clear history of how deserialization flaws have been used to compromise Android systems.
Stop treating IPC as a black box. Start auditing the data flow between your components and the rest of the system. The next time you are on an engagement, don't just look for hardcoded credentials or insecure storage; look at the ClassLoader and see what you can force it to load. You might be surprised at what you find.
Vulnerability Classes
Tools Used
Attack Techniques
OWASP Categories
All Tags
Up Next From This Conference

BestFit: Unveiling Hidden Transformers in Windows ANSI

Wi-Fi Calling: Revealing Downgrade Attacks and Not-so-private Private Keys

The CVSS Deception: How We've Been Misled on Vulnerability Severity
Similar Talks

Inside the FBI's Secret Encrypted Phone Company 'Anom'

Kill List: Hacking an Assassination Site on the Dark Web

