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, Songtao Wang, Shengli Pan, Xiaofeng Tao

TL;DR

MALSIGHT is a novel binary malware summarization framework designed to automatically translate stripped, convoluted decompiled pseudocode into clear, human-readable behavioral descriptions. By combining iterative function call graph traversal, hybrid static/dynamic annotations, and a lightweight 0.77B parameter model (MalT5), MALSIGHT effectively bridges the semantic gap in reverse engineering and outperforms models nearly 20 times its size.

What Problem Does This Paper Address?

When security analysts analyze malware without access to its source code, they rely on decompilers like IDA Pro or Ghidra to turn binary executables into C-like pseudocode. However, malware authors frequently "strip" binaries of symbolic information, removing meaningful variable and function names.

The resulting pseudocode is semantically impoverished—replacing clear identifiers with opaque labels like sub_404018—and structurally convoluted with deeply nested control flows. Existing Large Language Models (LLMs) struggle to summarize these binaries because there is a severe shortage of high-quality, human-annotated malware pseudocode datasets. Furthermore, traditional natural language metrics (like BLEU and ROUGE) fail to accurately evaluate code summaries, often giving high scores to completely incorrect descriptions that happen to share common keywords.

Methods

MALSIGHT addresses these challenges through a multi-step, iterative framework:

  1. Function List Extraction: Instead of analyzing functions in isolation, MALSIGHT extracts the binary's Function Call Graph (FCG). It uses a custom algorithm called REsort (integrating Tarjan's, Dijkstra's, and Depth-First Search algorithms) to order functions from the inside out (callees before callers).
  2. Annotation Generation: To compensate for stripped semantics, MALSIGHT generates two types of annotations:
  3. Static Annotations: A CodeBERT-based sequence labeling model identifies critical OS APIs and strings. MALSIGHT then queries GitHub Code Search to retrieve relevant open-source context and uses an LLM to generate natural language descriptions.
  4. Dynamic Annotations: As the framework processes the function list, the summary of a child function (callee) is automatically passed upward as an annotation to its parent function (caller), mimicking human reverse-engineering workflows.
  5. Two-Phase Transfer Learning (MalT5): The authors fine-tune CodeT5+ to create MalT5 (0.77B parameters) using a two-phase approach. Phase 1 trains the model on malware source code to capture malicious intent and semantics. Phase 2 trains it on benign pseudocode to master the structural nuances of decompiled code.
  6. BLEURT-sum Evaluation: The authors introduce a new evaluation metric by fine-tuning BLEURT on a custom dataset of code summaries, creating a metric highly sensitive to actual semantic and structural quality rather than simple word overlap.
Fig. 2. Workflow of MALSIGHT. The workflow takes binary malware as input and, after going through graph traversal, annotation generation, and model summarization, iteratively produces function-level code summaries based on the function call hierarchy.

Datasets

The authors introduced several novel datasets to train and evaluate the different components of MALSIGHT:

  • MalS: 89,609 malware source code functions extracted from 2,289 malicious GitHub repositories, with summaries generated by an LLM and manually refined by five human experts.
  • MalP: A evaluation dataset consisting of 500 pseudocode functions from 20 randomly selected malware repositories.
  • BenignC: 96,835 benign pseudocode functions (processed from the existing Capybara dataset) enriched with static annotations.
  • CSL: 95,000 pseudocode functions used to train the static annotation sequence-labeling model.
  • EvaS: 127,510 positive and negative summary pairs used to train the BLEURT-sum evaluation model.

Key Insights and Ideas

  • Semantic + Structural Transfer: Since large-scale, labeled malicious pseudocode datasets do not exist, the authors realized they could teach an LLM malware semantics via source code (MalS) and decompiled structures via benign pseudocode (BenignC).
  • Context Flows Inward to Outward: A parent function's purpose is often entirely dependent on the sub-functions it calls. Passing summaries from callees to callers as dynamic annotations provides the LLM with the structural context necessary to prevent "hallucinations."
  • The Flaw of Word Overlap: Traditional metrics like BLEU and ROUGE are easily fooled by structural templates. A candidate sentence can receive a high similarity score simply by containing generic words like "function" or "return," even if the core behavior described is entirely wrong.

Key Results

  • Superior Performance with Fewer Parameters: On completely stripped malware pseudocode (MalP), the 0.77B parameter MalT5 achieved a BLEURT-sum score of 62.14, outperforming much larger models including Code Llama-7B (56.00) and WizardCoder-15B (53.43).
  • Crucial Role of Annotations: Ablation studies showed that removing the annotation module caused a 12% performance drop on all-stripped binaries, proving that the hybrid annotations effectively counteract the effects of code stripping.
  • Metric Accuracy: BLEURT-sum achieved an F1-score exceeding 0.9999 on the positive/negative summary classification task, vastly outperforming METEOR (0.9811) and BLEU (0.85).

Limitations and Future Work

  • The Long-Function Challenge: MALSIGHT’s performance dropped by roughly 30% when applied to real-world malware samples compared to the curated test set. The authors noted that 15.8% of real-world malware functions exceed 1,000 tokens, which introduces noise and strains the model's context window. They propose using a multi-agent approach to summarize code fragments before aggregating them into function-level summaries.
  • Lack of Global Threat Intelligence: Because the framework operates strictly on the decompiled binary, it can miss broader context—such as identifying whether a specific external server or domain contacted by the malware is known to be malicious.
  • Future Directions: The authors plan to scale up the model's parameter size and incorporate labeled data from manual dynamic debugging sessions to further improve accuracy.

Summary updated

BibTeX
@article{lu2024malsight,
  author = {Haolang Lu and Hongrui Peng and Guoshun Nan and Jiaoyang Cui and Cheng Wang and Weifei Jin and Songtao Wang and Shengli Pan and Xiaofeng Tao},
  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