Interpretation-enabled Software Reuse Detection Based on a Multi-Level Birthmark Model

Xi Xu, Qinghua Zheng, Zheng Yan, Ming Fan, Ang Jia, Ting Liu

TL;DR

This paper introduces ISRD, a novel approach for detecting software reuse in binary code. It uses a multi-level "birthmark" model (function, basic block, instruction) to capture program semantics, making detection results interpretable. ISRD also employs an "intent search based on anchor recognition" strategy to efficiently pinpoint reused code, achieving high accuracy and resilience to compilation variations.

What Problem Does This Paper Address?

Software reuse, especially partial reuse, is a double-edged sword. While it accelerates development, it also poses significant legal and security risks if not properly managed. Detecting this reuse is challenging, particularly when only binary code is available (as source code is often inaccessible). Existing binary code reuse detection methods suffer from several limitations:

  • Poor Interpretability: They often provide only a similarity score, making it difficult to understand why a piece of code is flagged as reused. This lack of evidence hinders trust and debugging.
  • Poor Accuracy: Many methods struggle with variations introduced by different compilers, optimization levels, or even minor code changes (obfuscation), leading to false positives or negatives.
  • Poor Efficiency: Brute-force comparison of all function pairs is computationally prohibitive for large software projects.

ISRD aims to overcome these limitations by providing an interpretable, accurate, and efficient solution for detecting partial software reuse in binary code.

Methods

ISRD employs a two-stage process: Birthmark Generation and Reuse Detection.

1. Birthmark Generation: This stage creates a unique "birthmark" for each program, capturing its semantics at multiple levels:

  • Function Level: A Function Call Graph (FCG) is constructed to represent the overall program structure and function interdependencies.
  • Basic Block Level: Instead of relying on raw basic blocks, ISRD extracts "Minimum Branch Paths" (MBPs). These are partial execution paths between branching nodes, making them more resilient to structural changes like block splitting or merging.
  • Instruction Level: To combat obfuscation from different compilation processes, instructions are normalized. This involves extracting "key instructions" that carry core semantics, lifting low-level assembly to high-level operations, and removing operands that are prone to change.

2. Reuse Detection: This stage efficiently identifies reused code using an "intent search based on anchor recognition" strategy:

  • Anchor Recognition: This initial step quickly identifies potential matches by looking for "anchor" function pairs. Anchors are identified through two methods: strict instruction matching (identical instruction sequences) and identical library call invocations.
  • Intent Search: Once anchors are found, ISRD explores their "neighbors" (functions connected in the FCG) to discover more potentially matched function pairs. This guided search significantly reduces the number of comparisons needed.

Finally, similarity scores are calculated at the instruction, basic block, and function levels, and then aggregated to determine the overall program similarity. The multi-level birthmark allows for interpretable results, showing matches at each granularity.

Datasets

The paper uses two datasets for evaluation:

  • Dataset I: A newly constructed dataset containing 24 real-world software projects with 74 manually labeled partial reuse instances. This dataset was compiled using GCC with default optimization (O2).
  • Dataset II: A widely-used benchmark dataset derived from the Coreutils utilities. This dataset was compiled using multiple compilers (GCC, Clang) and various optimization levels (O0-O3) to test resilience to cross-compilation variations.

Key Insights and Ideas

  • Multi-Level Birthmark for Interpretability: The core idea is that combining semantic information from function calls, execution paths (MBPs), and normalized instructions provides a richer, more interpretable representation of a program's identity. This allows users to see where and how code is reused.
  • MBPs as Robust Basic Block Representations: Moving beyond raw basic blocks to MBPs offers resilience against common binary obfuscation techniques like block splitting/merging, which are problematic for traditional CFG-based methods.
  • Anchor-Guided Search for Efficiency: The "intent search based on anchor recognition" is a clever way to avoid exhaustive pairwise comparisons. By first identifying strong initial matches (anchors) and then intelligently exploring their vicinity, ISRD drastically speeds up the detection process.
  • Normalization for Cross-Compilation Resilience: The instruction normalization process (key instruction extraction, lifting, operand removal) is crucial for making the detection robust against variations introduced by different compilers and optimization settings.

Key Results

ISRD demonstrates strong performance across various metrics:

  • Effectiveness: Achieves high precision (97.2%) and recall (94.8%) on Dataset I.
  • Efficiency: Significantly reduces the number of function pairs requiring comparison, by up to 97.9% on average, making it practical for large-scale analysis.
  • Interpretability: Case studies show that ISRD can visually demonstrate reuse at function, basic block, and instruction levels, providing clear evidence.
  • Resilience: Shows strong resilience to cross-compiler versions (avg. 96.0% precision, 99.3% recall), cross-optimization levels (avg. 91.1% precision, 95.7% recall for GCC/Clang), and cross-compiler vendors (avg. 94.2% precision).
  • Comparison: Outperforms baseline approaches like BinDiff, BinGo, and aDiff in recall by an average of 27.0% on a challenging cross-compiler/optimization dataset.

Limitations and Future Work

  • Function Inlining: A significant limitation is that ISRD treats function semantics independently. It doesn't integrate callee semantics into caller semantics, which can be an issue when compilers inline functions. The authors suggest incorporating techniques that inline relevant libraries and developer-defined functions.
  • Library Function Recognition: The current method for recognizing library function anchors is limited by OS dependency and the inability to identify functionally similar but differently named library calls (e.g., memcpy vs. memmove). Future work could leverage techniques like Word2Vec to learn similarities between cross-OS library calls.
  • Dataset Size: The manually labeled Dataset I, while valuable, is relatively small (74 partial reuses). Future work plans to collect more real-world partial reuse samples to further evaluate and optimize ISRD.

Summary updated

BibTeX
@inproceedings{xu2021interpretation,
  author = {Xi Xu and Qinghua Zheng and Zheng Yan and Ming Fan and Ang Jia and Ting Liu},
  title = {{Interpretation-enabled Software Reuse Detection Based on a Multi-Level Birthmark Model}},
  booktitle = {ICSE},
  year = {2021},
  doi = {10.1109/icse43902.2021.00084},
}
Figure