Empirical Study of Code Large Language Models for Binary Security Patch Detection

Qingyuan Li, Binchang Li, Cuiyun Gao, Shuzheng Gao, Zongjie LiarXiv 2025 · DOI

Introduction

Security Patch Detection (SPD) is a vital component of software security, identifying whether specific code changes address vulnerabilities. While effective for open-source software, SPD remains a significant challenge for closed-source or proprietary software where only binary files are available. The compilation process obscures human-readable semantics, and compiler optimizations further complicate structural analysis. This study investigates the potential of modern Large Language Models (LLMs) to overcome these hurdles in the binary domain.

Methodology

The researchers conducted a systematic evaluation of 19 open-source code LLMs and two proprietary models. The experimental framework was divided into three primary phases: prompting exploration, fine-tuning via Low-Rank Adaptation (LoRA), and source-code-augmented training.

Overview of the experimental framework for binary security patch detection, including dataset construction and experimentation phases.

The study compared two primary binary representations: low-level Assembly instructions and high-level Pseudo-code generated by a decompiler. To further enhance performance, the authors introduced a data augmentation strategy that incorporates source code into the training set, helping models learn the logical mapping between high-level fixes and their binary counterparts.

Dataset Construction

To facilitate this research, a large-scale binary SPD dataset was constructed from five major open-source projects: Linux, FFmpeg, Git, PHP, and Libav. The resulting dataset contains 19,448 labeled samples, including 8,311 security patches. To ensure robustness against real-world variations, each sample was compiled using five different optimization levels (O0, O1, O2, O3, and Os).

The Role of Pseudo-code as a Semantic Bridge

A core finding of this research is the superiority of pseudo-code over assembly for LLM-based patch detection. As shown in Figure 1, pseudo-code retains structural markers and a C-like syntax that closely mirrors the original source code, whereas assembly instructions are significantly more abstracted.

Comparison of security patches at the source code, pseudo-code, and assembly levels, highlighting the semantic gap.

Embedding analysis using t-SNE and "code naturalness" metrics confirmed that pseudo-code is semantically closer to the natural language of programming that LLMs are pre-trained on. In contrast, assembly code lacks the logical blocks (e.g., if/else) that facilitate LLM reasoning, leading to what the authors term the "alien" assembly problem.

Key Results

The experimental results demonstrate that fine-tuning is essential; "vanilla" prompting, even with Chain-of-Thought techniques, proved insufficient for the complexities of binary SPD.

  • Performance Gains: Fine-tuning on pseudo-code yielded an average increase of 0.173 in accuracy and 0.239 in F1 score compared to assembly-based models.
  • Top Performer: The LLM4Decompile-9B-v2 model, when trained on source-augmented pseudo-code, achieved a peak accuracy of 93.3%.
  • Efficiency: Smaller models (e.g., Qwen2.5-Coder-0.5B) outperformed significantly larger foundation models like GPT-3.5 when specifically fine-tuned for this task.
  • Optimization Robustness: Models trained on pseudo-code maintained consistent performance across different compiler optimization levels, whereas assembly-based models showed high sensitivity to structural changes caused by optimizations like -O3.

Limitations and Future Directions

While promising, the approach depends on high-quality decompilation (e.g., IDA Pro). Future research should explore the impact of open-source decompilers and focus on "vulnerability-specific" pre-training to improve detection of complex bugs like race conditions. Additionally, scaling fine-tuning to models beyond 13B parameters may unlock further reasoning capabilities for intricate security vulnerabilities.

Conclusion

This study provides the first comprehensive look at LLMs for binary SPD, highlighting that pseudo-code acts as a critical bridge between low-level binary data and high-level semantic understanding. By leveraging fine-tuned, smaller models on decompiled code, researchers can achieve high-accuracy security patch detection in closed-source environments.

Summary updated

BibTeX
@misc{li2025empirical,
  author = {Qingyuan Li and Binchang Li and Cuiyun Gao and Shuzheng Gao and Zongjie Li},
  title = {{Empirical Study of Code Large Language Models for Binary Security Patch Detection}},
  year = {2025},
  eprint = {2509.06052},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2509.06052},
}
Figure