Abstract
Binary Code Similarity Detection (BCSD) is a critical component of cybersecurity, used for vulnerability discovery and malware analysis. While modern learning-based (LB-BCSD) models are effective at identifying code across different compiler optimizations, they often struggle with the "implementation gap"—where the same functionality is written using different coding styles or algorithms. This paper introduces FuncFooler, a gradient-guided adversarial attack tool that generates functional code variants. By incorporating these structurally diverse but semantically equivalent variants into the training process, we demonstrate an accuracy improvement of 5% to 7% in state-of-the-art detectors and a significant boost in model robustness.
Introduction
The effectiveness of LB-BCSD models is frequently hampered by structural diversity in code that performs the same logical function. Research indicates that model accuracy can drop by approximately 13% when encountering different implementations of the same algorithm. Traditional adversarial methods, such as appending non-functional "junk bytes," fail to address the underlying structural nuances that mislead these models. To bridge this gap, we propose a method to create structurally diverse but semantically equivalent code variants for adversarial training.
Methodology: The FuncFooler Framework
FuncFooler is designed to perturb binary code while maintaining its original functionality. The process follows a gradient-guided approach to ensure that modifications are impactful to the model's decision-making process.
The workflow consists of several key stages:
- Node Identification: The system identifies "dominator nodes" within the program's control flow graph (CFG). These nodes are essential as they are guaranteed to execute, ensuring that any perturbation applied to them will be processed by the model.
- Importance Computation: Using the model's gradient information, FuncFooler identifies which nodes most significantly influence the model's output.
- Perturbation Selection and Execution: Specific strategies are applied to the most influential nodes to alter their appearance without changing their logic.
- Adversarial Training: The resulting variants are integrated into the training set, teaching the model to recognize functional equivalence despite structural changes.
Semantic-Preserving Perturbation Strategies
FuncFooler employs a variety of techniques to modify control flow, data flow, and intra-node structures to create functional variants.
Key strategies include:
- Control Flow Transformations: This includes hiding edges by converting direct jumps into indirect ones via pointer tables, cloning code blocks to create redundant paths, and fabricating fake loops that never execute.
- Data Flow Obfuscation: "Constant expansion" replaces simple assignments (e.g.,
y = 8) with complex, mathematically equivalent operations that appear different to the model but yield the same result. - Intra-Node Transformations: This technique hides function calls behind pointer tables or expands them into new sub-functions to disrupt the model's perception of the program's hierarchy.
Experimental Evaluation
The study evaluated FuncFooler against prominent models including Asm2Vec, SAFE, and JTrans using three primary datasets: BinaryCorp-3M for initial tuning, a Diversity Set of 400 manually implemented programs from LeetCode and GitHub, and a Real-World Set comprising popular open-source projects like Curl, SQLite, and OpenSSL.
Key Results
- Accuracy Improvement: Fine-tuning the state-of-the-art JTrans model with FuncFooler-generated variants resulted in a 5% to 7% accuracy increase across real-world datasets.
- Robustness Gains: Retrained models demonstrated a 22% improvement in robustness. While original models were easily deceived by adversarial attacks, the enhanced models maintained high performance levels.
- Addressing the Implementation Gap: The results confirm that while the "compiler gap" (same code, different flags) is largely addressed by modern models, the "implementation gap" remains a significant challenge that adversarial training can help mitigate.
Conclusion and Future Work
FuncFooler demonstrates that targeted, semantic-preserving perturbations are highly effective for improving the robustness of LB-BCSD models. However, the challenge of "algorithmic diversity"—automatically transforming one algorithm into a logically distinct but functionally identical one (e.g., Bubble Sort to Quick Sort)—remains a significant hurdle. Future research will focus on generating logically distinct variants and expanding these techniques to more complex transformer-based binary analysis models.
Summary updated