Improving Java Deserialization Gadget Chain Mining via Overriding-Guided Object Generation

Sicong Cao, Xiaobing Sun, Xiaoxue Wu, Lili Bo, Bin Li, Rongxin Wu, Wei Liu, Biao He, Yu Ouyang, Jiajia Li

TL;DR

This paper introduces GCMiner, a novel approach to automatically discover Java deserialization vulnerabilities. By analyzing dynamic program features like method overriding and employing an "overriding-guided" object generation strategy, GCMiner significantly outperforms existing tools, finding 56 previously undiscovered gadget chains.

What Problem Does This Paper Address?

Java's deserialization mechanism, while convenient for data transmission, is a significant security risk. Attackers can exploit vulnerabilities by chaining together existing code snippets (gadgets) to form a "gadget chain." This chain allows them to inject malicious objects into an application, potentially leading to remote code execution (RCE). Existing tools for finding these gadget chains struggle because they often fail to account for dynamic Java features like runtime polymorphism, leading to missed vulnerabilities (false negatives) or incorrect findings (false positives). Furthermore, generating valid "injection objects" to test these chains is challenging, often causing fuzzing tools to get stuck.

Methods

GCMiner tackles this problem in three main stages:

  1. Graph Construction: It builds a "Deserialization-Aware Call Graph" (DA-CG). This graph goes beyond standard call graphs by incorporating method overriding relationships, crucial for understanding how Java's dynamic features are exploited. It uses static analysis and Class Hierarchy Analysis (CHA) to capture both explicit and implicit method calls.
  2. Chain Identification: Using the DA-CG, GCMiner employs graph traversal with custom Cypher queries to identify "suspicious" gadget chains. It uses a curated list of 11 magic methods (entry points) and 25 security-sensitive call sites (sinks) derived from their empirical study.
  3. Chain Verification: This is where GCMiner introduces its key innovation: an "overriding-guided object generation" approach. Instead of generic fuzzing, it uses the identified overriding relationships to guide the creation of injection objects. This ensures the generated objects are more likely to follow the intended execution path of the gadget chain and reach the security-sensitive sink. The generated objects are then fed into a coverage-guided fuzzer (JQF) for dynamic execution and verification.

Datasets

The authors created a benchmark dataset consisting of 86 publicly known exploitable gadget chains. This benchmark was compiled from the popular ysoserial repository and 18 other Java applications. They specifically selected applications that support deserialization and have reported vulnerabilities, ensuring the chains are relevant and verifiable.

Key Insights and Ideas

  • Runtime Polymorphism is Key: The empirical study revealed that a vast majority (87.2%) of Java deserialization gadgets are exploited by abusing runtime polymorphism, specifically by reusing serializable overridden methods. This highlights the inadequacy of static analysis that overlooks these dynamic behaviors.
  • Dynamic Binding is Crucial for Construction: Constructing exploitable gadget chains heavily relies on dynamic binding (at least once) to modify injection object properties and trigger overridden methods. This is how attackers guide the malicious data flow.
  • Overriding-Guided Generation is Effective: Simply generating injection objects isn't enough; they need to be semantically valid and follow the gadget chain's logic. GCMiner's approach of using overriding relations to guide object generation significantly improves the ability to create valid, sink-reachable injection objects, overcoming limitations of previous fuzzing techniques.

Key Results

GCMiner significantly outperforms existing state-of-the-art tools:

  • It identified 61 out of 86 known gadget chains, achieving a recall of 70.9% with no false positives in their evaluation.
  • GCMiner discovered 56 unique gadget chains that were missed by baseline approaches like Gadget Inspector and Serhybrid.
  • Compared to Gadget Inspector, GCMiner showed a recall of 70.9% versus 5.8%, with a much lower false positive rate.
  • Against Serhybrid, GCMiner generated more valid injection objects (10 vs. 2) for a smaller set of known chains, demonstrating better coverage despite Serhybrid's higher precision on a subset.
  • Ablation studies confirmed the importance of both including more magic methods/sinks and, crucially, incorporating method overriding information for effective gadget chain mining.

Limitations and Future Work

  • External Validity: The authors acknowledge that their findings are specific to Java and may not directly apply to other programming languages. They also note that while their knowledge base of sources and sinks is configurable, the effectiveness relies on having a comprehensive set.
  • Internal Validity: They addressed potential biases by manually reproducing vulnerabilities and comparing with Serhybrid under controlled conditions.
  • Future Work: The authors plan to extend GCMiner to industrial scenarios for large-scale case studies and investigate automatic exploit generation techniques for vulnerability reproduction and confirmation. They also suggest exploring the applicability to other programming languages.

Summary updated

Abstract

Java (de)serialization is prone to causing security-critical vulnerabilities that attackers can invoke existing methods (gadgets) on the application's classpath to construct a gadget chain to perform malicious behaviors. Several techniques have been proposed to statically identify suspicious gadget chains and dynamically generate injection objects for fuzzing. However, due to their incomplete support for dynamic program features (e.g., Java runtime polymorphism) and ineffective injection object generation for fuzzing, the existing techniques are still far from satisfactory. In this paper, we first performed an empirical study to investigate the characteristics of Java deserialization vulnerabilities based on our manually collected 86 publicly known gadget chains. The empirical results show that 1) Java deserialization gadgets are usually exploited by abusing runtime polymorphism, which enables attackers to reuse serializable overridden methods; and 2) attackers usually invoke exploitable overridden methods (gadgets) via dynamic binding to generate injection objects for gadget chain construction. Based on our empirical findings, we propose a novel gadget chain mining approach, GCMiner, which captures both explicit and implicit method calls to identify more gadget chains, and adopts an overriding-guided object generation approach to generate valid injection objects for fuzzing. The evaluation results show that GCMiner significantly outperforms the state-of-the-art techniques, and discovers 56 unique gadget chains that cannot be identified by the baseline approaches.
BibTeX
@misc{cao2023improving,
  author = {Sicong Cao and Xiaobing Sun and Xiaoxue Wu and Lili Bo and Bin Li and Rongxin Wu and Wei Liu and Biao He and Yu Ouyang and Jiajia Li},
  title = {{Improving Java Deserialization Gadget Chain Mining via Overriding-Guided Object Generation}},
  year = {2023},
  eprint = {2303.07593},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2303.07593},
}
Figure