MALSIGHT: Exploring Malicious Source Code and Benign Pseudocode for Iterative Binary Malware Summarization

Haolang Lu, Hongrui Peng, Guoshun Nan, Jiaoyang Cui, Cheng Wang, Weifei Jin

TL;DR

This paper introduces MALSIGHT, a novel framework for automatically generating human-readable summaries of binary malware. By leveraging both malicious source code and benign pseudocode, MALSIGHT iteratively refines summaries to overcome challenges like stripped semantics and complex code structures, achieving state-of-the-art performance with a surprisingly small model.

What Problem Does This Paper Address?

Understanding binary malware is crucial for cybersecurity, but automatically generating human-readable descriptions (summaries) of their behavior is difficult. Existing methods, even those using Large Language Models (LLMs), struggle with several issues:

  • Obscure Pseudocode: Decompilers like IDA Pro and Ghidra produce pseudocode that often lacks meaningful variable and function names (e.g., sub_404018 instead of initLevel). This pseudocode can also be overly verbose and complex, with deep nesting and entangled logic.
  • Lack of Malware-Specific Datasets: There's a scarcity of high-quality datasets specifically for training models to summarize malware. Building such datasets is challenging due to the need for expert human annotation.
  • Underexplored Function Relationships: The intricate calling relationships between functions within a binary are vital for understanding overall behavior but are often not fully utilized in summarization.

These limitations lead to summaries that are hard to use, inaccurate, or incomplete, hindering malware analysis efforts.

Methods

MALSIGHT tackles these problems with a multi-pronged approach:

  • Iterative Summarization with Function Call Graphs (FCGs): Instead of processing functions in isolation, MALSIGHT first extracts the FCG from a binary. It then generates a "reverse-ordered function list" based on this graph, processing functions from outer calls to inner ones. This allows for a more holistic understanding of how functions interact.
  • MalT5: A Lightweight LLM for Malware Summarization: The core of MALSIGHT is MalT5, a novel LLM fine-tuned for this task. It's trained in two phases: first on malicious source code (MalS) to learn malware-specific behaviors, and then on benign pseudocode to adapt to the structure and semantics of decompiled code. This transfer learning approach helps bridge the gap between source code understanding and pseudocode summarization.
  • Static and Dynamic Annotations: To combat the loss of semantic information due to stripping (where names and other identifiers are removed), MALSIGHT employs both static and dynamic annotations. Static annotations leverage API calls and preserved strings, while dynamic annotations use the summaries of called functions to enrich the context of the calling function.
  • BLEURT-sum: A Novel Evaluation Metric: Recognizing the limitations of traditional metrics like BLEU and ROUGE for code summarization, the authors propose BLEURT-sum. This metric is designed to be more sensitive to the quality of pseudocode summaries, combining aspects of word overlap and semantic embeddings.

Datasets

  • MalS: A large-scale dataset of nearly 90,000 malware source functions with human-verified summaries. This is a novel contribution to the field.
  • MalP: A smaller dataset of 500 malware functions in pseudocode format, used for testing.
  • BenignC: A dataset derived from the Capybara dataset (used by BinT5), which consists of benign pseudocode summaries. This dataset is used for the second phase of MalT5's fine-tuning.
  • CSL: A dataset for training the static annotation module, consisting of labeled pseudocode tokens.
  • EvaS: A dataset used for fine-tuning the BLEURT-sum evaluation metric.

Key Insights and Ideas

  • Leveraging Benign Code for Malware: The insight that training on benign pseudocode can help models understand the structure of decompiled code, which can then be applied to the semantics learned from malware source code, is crucial. This allows for effective summarization even without a large corpus of malware pseudocode summaries.
  • Iterative Refinement is Key: Processing functions based on their call hierarchy and iteratively feeding summaries back into the process allows MALSIGHT to build a more coherent and accurate understanding of the malware's overall functionality.
  • Annotations Bridge the Semantic Gap: The combination of static and dynamic annotations is a clever way to inject missing semantic information lost during binary stripping, significantly improving the model's ability to understand and summarize complex code.
  • Small Models Can Be Powerful: The fact that MalT5, with only 0.77B parameters, achieves performance comparable to much larger models like Code-Llama highlights the effectiveness of their fine-tuning strategy and architectural choices.

Key Results

  • MALSIGHT achieves state-of-the-art performance on malware summarization tasks, outperforming existing methods and large general-purpose LLMs.
  • The proposed MalT5 model, despite its small size (0.77B parameters), delivers comparable performance to much larger models like Code-Llama.
  • The BLEURT-sum evaluation metric shows significantly better performance in distinguishing between good and bad summaries compared to traditional metrics like BLEU, ROUGE, and METEOR.
  • Ablation studies show that both the annotation module and the two-phase training process are critical for MALSIGHT's effectiveness. Removing the annotation module, for instance, leads to a significant performance drop.
  • Real-world experiments with human evaluators indicate that MALSIGHT's summaries are generally usable and correlate well with human judgment.

Limitations and Future Work

  • Longer Functions: The paper notes that MALSIGHT's performance can be weaker on very long functions, potentially due to model parameter size and input length limitations. The authors suggest exploring larger models or code fragment-level summarization for such cases.
  • Maliciousness Detection: While MALSIGHT summarizes functionality, it doesn't explicitly identify why a server is malicious. This is attributed to a lack of background information for the model.
  • Assembly Language Summarization: The paper discusses the challenges of directly summarizing assembly code due to its structural differences from high-level languages and the potential for compiler-induced data shifts. They opt to treat all code as pseudocode for consistency.
  • Future Directions: The authors suggest improving the model's ability to generate concise summaries for longer code sequences, applying MALSIGHT to more complex downstream tasks, and exploring code fragment-level summarization. They also mention the potential of integrating manual dynamic debugging for further enhancement.

Summary updated

BibTeX
@article{lu2024malsight,
  author = {Haolang Lu and Hongrui Peng and Guoshun Nan and Jiaoyang Cui and Cheng Wang and Weifei Jin},
  title = {{MALSIGHT: Exploring Malicious Source Code and Benign Pseudocode for Iterative Binary Malware Summarization}},
  journal = {IEEE Trans. Inf. Forensics Secur.},
  year = {2024},
  url = {https://openreview.net/forum?id=4KM4SbxpYZ},
}
Figure