WorksComputer Science
DERED: Enhancing Third-Party Library Detection in Binaries via Deceptive Reuse Mitigation
Abstract
This paper introduces the concept of deceptive reuse a misleading reuse relationship between recipient software that share common TPL code and proposes a novel approach, DERED, to enhance TPL detection by distinguishing between real reuse and deceptive reuse.
Introduction
With the rapid expansion of the open-source ecosystem, Third-Party Library (TPLs) have become indispensable components of modern software engineering. Their extensive software development, supported by mature integration infrastructures such as GitHub [1], SourceForge [2], and package managers like Conan [3] and VCPKG [4]. According to Synopsys [5], 97% of software projects incorporate at least one TPL, underscoring their central role in modern development. However, this widespread reuse also introduces considerable security challenges. Empirical studies have shown that ubiquitous libraries such as BusyBox and OpenSSL are embedded in thousands of softwares. For instance, BusyBox was identified in over 40% of analyzed software samples, with the vulnerability CVE-2018-1000517 compromising thousands of devices [6]. Similarly, OpenSSL appeared in more than 1,300 software from vendors such as TP-Link and D-Link, where the Heartbleed vulnerability (CVE-2014-0160) was detected in 380
instances [7]. These findings indicate that pervasive TPL reuse can expose systems to severe vulnerabilities, highlighting the urgent need for effective TPL detection to enhance software security.
TPL detection can be categorized into source-oriented and binary-oriented methods. As our work targets software binaries, where source code is often unavailable, we focus on the binary-oriented category, where methods are further divided into syntax-based and semantic-based approaches. syntax-based methods—such as LibDX [8], B2SFinder [9], and OSSPolice [10]—leverage low-level syntactic features (e.g., strings, constants, and integers) to enable static analysis, but their robustness degrades when facing cross-architecture differences or diverse compiler optimizations. In contrast, semantic-based approaches—such
ORCID(s): 1 as MODX [11], ISRD [12], and LibDB [13]—improve resilience by capturing function-level semantic features through deep neural networks. Incorporating structural context, LibAM [14] further enhances detection accuracy by aligning matched code areas according to structural patterns in Function Call Graphs (FCGs). Despite diverse feature representations, existing TPL detection methods generally follow a unified workflow (Figure 1), in which reuse relationships are identified via function or area matching of the binaries.

Figure 1. Workflow of the Existing TPL Detection Framework. The framework takes the binary pair as input, performs function or area matching to identify homologous code, and determines the presence of TPL reuse between the binaries.
Existing TPL detection methods often neglect the directionality of code reuse, thereby conflating code matching with code reuse and ultimately leading to false-positive vulnerability reports, as illustrated in Fig. 2. In practice, real code reuse is defined as the unidirectional transfer of code from a TPL—acting as the provider of functional code—to a recipient code that incorporates the reused code. In contrast, numerous cases have shown that two recipient code may independently incorporate the same functionality from a common TPL, thereby creating a bidirectional relationship between them, which is formally defined in this study as deceptive code reuse. This type of reuse may falsely imply vulnerability propagation across unrelated projects, leading to spurious alerts in vulnerability analysis. Although LibDI [15] advances the field by defining complex reuse scenarios, its methodology is limited by reliance on symbol information such as function names. A critical shortcoming is that it overlooks reuse directionality, thereby rendering LibDI unable to accurately distinguish between deceptive and real reuse. Consequently, establishing a mechanism to differentiate between real and deceptive reuse within TPL detection represents an urgent research imperative.
To address these limitations, we propose DERED, a three-stage TPL detection framework with the capability of deceptive reuse mitigation. The first two stages, Function Matching and Area Alignment, are designed to identify homologous code areas between binaries, while the third stage, Reuse Discrimination, aims to determine the type of reuse between these code areas. Acting as the preparatory phase, the Function Matching module applies Markov matrix encoding combined with MobileNet [16] to identify homologous functions across binaries, while the Area Alignment module constructs Attributed Function Call Graphs (AFCGs) and employs a Graph Convolutional Network (GCN) to refine the alignment of code areas. The Reuse Discrimination stage forms the core of DERED; it takes potential homologous code areas as input and models the donor–recipient relationships between them through two topology-sensitive features, thereby effectively distinguishing between real and deceptive reuse. This design enables DERED to distinguish real reuse from deceptive reuse, thereby ensuring precise TPL detection and reducing false-positive vulnerability reports caused by deceptive reuse.
We curated a dataset comprising deceptive reuse cases and used it to systematically evaluate DERED against several state-of-the-art methods—including ISRD [12], LibDB [13], LibAM [14] and LibDI [15]—in the tasks of reuse discrimination and TPL detection. Experimental results demonstrate that DERED is highly effective in reuse discrimination, achieving an F1 score of 96.9%. Furthermore, it attains an F1 score of 97.7% in TPL detection, where it outperforms the best-performing baseline by 9.2%. Moreover, DERED demonstrates robust performance across different architectures and compiler optimization levels, achieving average F1 scores of 92.9% and 92.0%, respectively. Finally, a real-world case study demonstrates that DERED outperforms the commercial tool BinaryAI [17] in mitigating deceptive reuse and enables more effective TPL and vulnerability detection. We summarize our main contributions below:
We formally define deceptive reuse based on directionality to distinguish it from real reuse, illustrating with real-world examples its impact on false-positive vulnerability reports.
We design algorithms to capture donor–recipient relationships between code areas and develop DERED, a progressive framework for TPL detection that effectively mitigates deceptive reuse.
DERED achieves effective cross-architecture and cross-compilation optimization-level TPL detection, effectively mitigating deceptive reuse and outperforming the commercial tool BinaryAI.
Preliminaries
TPL Detection Framework
TPL detection frameworks typically identify reuse by analyzing binary pairs. As illustrated in Figure 1, existing approaches generally utilize code matching at the function or area granularity to detect homologous code, which forms the basis of the detection process. To facilitate the subsequent discussion, we begin by defining key terminology.
Binary pair, denoted as , consists of two binaries. The target binary is extracted from a software package and serves as the object of TPL detection. In contrast, the candidate binary is compiled from the TPL source code and serves as the reference for TPL detection.
Homologous code is classified based on code granularity into homologous functions and homologous areas. The former denotes a pair of functions from that originate from the same source, whereas the latter denotes a pair of code areas—each consisting of adjacent functions connected in the FCG—that derive from the same source.
In the TPL detection process, these frameworks identify homologous code between through function or area matching. The matched homologous code serves as an indicator of code reuse, and TPL reuse between binaries is determined by evaluating whether the number of such matches exceeds a predefined threshold.
Exposure of deceptive reuse
Existing TPL detection frameworks equate code matching with code reuse, overlooking the distinction between matching—a bidirectional relationship—and reuse—a unidirectional relationship.By extracting topology-sensitive features from and modeling donor-recipient relationships between code areas based on their attributes, we can effectively distinguish between real and deceptive reuse.
Reuse Discrimination and TPL Detection: Reuse discrimination specifically distinguishes real from deceptive reuse within local code regions, whereas TPL detection determines whether a valid real reuse relationship exists at the binary level between and .
Donor and Recipient Areas: Code areas within a are classified as either donor or recipient based on their functional roles in the reuse chain, thereby facilitating reuse discrimination through the analysis of donor-recipient relationships. A Donor area provides reusable functionality to other binaries, as exemplified by bzip2 (red box in Fig. 2). Conversely, a Recipient area integrates code from a donor, as seen with minizip (blue box in Fig. 2).
Real and Deceptive Reuse: Code reuse is classified by transfer direction. Real reuse occurs when a recipient code area directly incorporates donor code area, indicated by the unidirectional arrow from bzip2 to minizip in Fig. 2. Conversely, deceptive reuse arises between two recipients code area sharing a common donor, represented by the bidirectional arrow between minizip and lzbench in Fig. 2.
Detriment of deceptive reuse
The TPL-based vulnerability detection pipeline consists of three stages. First, it identifies TPL reuse to establish the relationship between and . Second, it retrieves known vulnerability information corresponding to the identified . Third, it propagates the vulnerability association to based on the inferred reuse relationship. Critically, the validity of vulnerability reporting relies on the accuracy of the initial detection phase. Consequently, this paper focuses on TPL detection. We contend that failing to differentiate deceptive reuse from real reuse inevitably leads to high false-positive rates in downstream vulnerability detection.
As illustrated in Fig. 2, we denote minizip as and bzip2—which contains the vulnerable function BZ2_Vul—as . The unidirectional arrow represents a valid vulnerability association, indicating the correct propagation of vulnerability information. Consider the scenario where a bidirectional matching relationship exists between minizip and lzbench, as both components exhibit high similarity despite the absence of a valid unidirectional reuse relationship. Existing TPL detection methods, which predominantly rely on syntactic or semantic feature matching, overlook the inherent directionality of reuse detection, failing to effectively distinguish between real and deceptive reuse. Consequently, these tools incorrectly infer a reuse relationship, leading to erroneous vulnerability reports. We provide empirical evidence of this phenomenon through a detailed case study in Section 5.
In large open-source ecosystems, widely adopted software is often integrated into thousands of downstream projects, leading to a rapid proliferation of deceptive reuse relationships. These misleading associations substantially increase the rate of false-positive vulnerability reports, especially when relying on automated approaches such as TPL reuse detection. Notably, mitigating such false positives through manual verification is resource-intensive, delays security response, and erodes trust in the detection systems.
Method
Overview
DeRED takes as input the binary pair (, ) and processes it through three dedicated modules—Function Matching, Area Alignment, and Reuse Discrimination—as illustrated in Figure 3, enabling effective TPL detection. In the Function Matching module, DeRED efficiently matches homologous function pairs between and , establishing the foundation for subsequent analysis. In the Area Alignment module, these paired functions are linked to delineate potential reused code areas, which are then aligned to determine homologous areas. Binary pairs without any such areas are defined as exhibiting no reuse. In the Reuse Discrimination module, each aligned area is rigorously classified as either real reuse or deceptive reuse. A binary pair is ultimately labeled as real reuse if it contains more than three verified instances of real code reuse; otherwise, it is categorized as deceptive reuse.

Figure 3. Workflow of the Three-Stage Binary Reuse Detection System DERED. The system comprises three stages: (1) Function Matching, which identifies homologous function pairs between target and candidate binaries; (2) Area Alignment, which establishes correspondences among these functions to delineate reused code areas; and (3) Reuse Discrimination, which categorizes each aligned area as real reuse, deceptive reuse, or no reuse.
Overall, DeRED employs a three-stage mechanism: it first matches homologous functions, then aligns the corresponding homologous areas, and finally assigns one of three labels—no reuse, deceptive reuse, or real reuse—to each aligned area. Ultimately, it determines the final TPL reuse relationship based on these discrimination labels.
Function Matching
This module matches homologous functions between and . To overcome the challenges of structural variations caused by compiler settings and the computational overhead of processing thousands of functions, this module incorporates code normalization, Markov matrix generation, and function similarity analysis. This approach ensures robust yet rapid matching, establishing an efficient foundation for subsequent analysis within DeRED.
Code Normalization This step normalizes assembly code to reduce compiler-introduced noise—such as shifted address offsets, instruction variants (e.g., “ADD” vs. “ADDS”), and cross-architecture divergences (e.g., “INC” vs. “ADD”). First, we extract the opcode sequence of function as:
ordered by offset. Next, each opcode is mapped into one of the seven semantic categories as listed in Table 1, thereby producing a normalized code sequence of descriptors as:
| Descriptor | Description |
| Arith () | Integer or floating-point computation |
| Xfer () | Register or memory data movement |
| Cmp () | Value comparison and flag setting |
| Logic () | Bitwise logical manipulation |
| Shift () | Bit-level shift or rotate |
| Jmp () | Direct jump without condition |
| Bcc () | Branch on condition evaluation |
Table 1. Opcode Semantic Mapping Table
where is the descriptor for . Table 1 lists each category and its description, enabling systematic normalization—for example, “ADD”, “ADDS”, and “INC” are all mapped to the arithmetic operator category, denoted as .
Markov Matrix Generation The normalized code sequence is used to construct a Markov matrix that encodes the key instruction transition patterns, thereby enabling efficient capture of function semantics. Specifically, a transition count matrix is constructed by iterating over adjacent instruction pairs in the normalized sequence . Each entry captures the frequency of transitions from semantic descriptor to , formally defined as:
where is the length of , is the indicator function, and is the set of semantic descriptors. By row-normalizing , we derive the Markov matrix , where each entry is defined as:
The Markov matrix captures two properties: structural compactness and semantic abstraction. Structural compactness transforms variable-length sequences into fixed-dimensional vector representations, permitting end-to-end analysis by neural networks. Semantic abstraction models normalized transition probabilities, thereby smoothing cross-architecture differences among homologous functions.
Function Similarity Calculation To efficiently encode function-level Markov representations, we employ a MobileNetV2 [16] backbone, which strikes an effective balance between representational capacity and computational cost.
The input matrix pair is processed by a dual-branch MobileNetV2 backbone within a Siamese architecture, enabling the model to learn consistent representations through symmetric embedding pathways. Each branch incorporates hierarchical depthwise separable convolutions with skip connections, allowing the network to capture hierarchical dependencies within the transition distribution. This compact design supports efficient modeling of the Markov semantic structures. This compact and shared-parameter design supports efficient modeling of Markov transition distributions. Adopting this Markov representation offers distinct advantages over alternative function matching approaches. Specifically, this representation mitigates structural noise [18] and models execution flow as spatial textures [19], thereby enabling the CNN backbone to extract topological features robust to compilation variations. Second, regarding computational efficiency, our matrix-based formulation circumvents the bottlenecks of alternative architectures. Unlike GNN-based methods [20] limited by iterative message-passing or Transformer-based methods [21] constrained by quadratic self-attention, the Markov matrix leverages optimized matrix operations in conjunction with MobileNet to achieve superior efficiency.
We train the model to learn function embeddings by maximizing the similarity of homologous pairs while minimizing that of non-homologous ones. A function pair is then identified as homologous if the similarity score between their embeddings exceeds a predefined threshold . All identified pairs are subsequently forwarded to the Area Alignment module for further analysis. If no matches are detected, the binaries are classified as unrelated in terms of code reuse.
Area Alignment
This module aligns homologous areas between and . To overcome the unreliability of traditional topology-based matching caused by optimization-induced structural variations, this module employs AFCG and a Siamese GCN architecture. By fusing stable semantic descriptors with neighborhood-aware graph convolutions, this approach effectively smooths out structural noise. This ensures resilient area alignment, establishing a precise foundation for subsequent analysis within DERED.
Code Area Derivation This step derives an extended code area for each matched function by recursively traversing its reachable callees in the FCG to extract the FCG subgraph. The design is motivated by the observation [14] that code reuse patterns tend to cluster within localized call hierarchies centered on matched functions.
By expanding the call neighborhood of each matched function, the method captures areas with a high likelihood of reuse and reliably preserves essential topological dependencies, thereby improving the overall effectiveness of area alignment. For each matched function pair , the procedure produces a corresponding pair of neighborhood subgraphs, denoted as , which serve as the reliable foundation for subsequent graph-based analysis.
Attributed Graph Generation This step converts each neighborhood subgraph into an AFCG by representing function nodes as semantic embeddings derived from their corresponding Markov matrices. The design is grounded in the practical reality that each is typically aligned against a large number of , and that the performance of purely topology-based matching tends to deteriorate as the candidate set scales up.
By encoding instruction-level behavioral patterns as semantic vectors and embedding them within the topology of the FCG, this step captures both local operational semantics and inter-function structural dependencies, enabling robust and distinctive area representations. For each neighborhood subgraph pair , this step generates a corresponding pair of AFCGs, denoted as , which are subsequently used as input for similarity computation.
Area Similarity Calculation This step encodes the AFCGs of code areas from both binaries and computes their similarity using a Siamese GCN architecture. Specifically, it takes AFCG pairs as input and processes them with dual-channel GCNs. The symmetric structure enables joint representation learning of both input graphs.
Each channel of the network applies a stack of three GCN layers to extract both semantic and structural features from the input graph pairs. In general, a GCN layer updates the representation of each node by aggregating information from its local neighborhood, thereby capturing the graph’s topology and node attributes. Formally, in the -th GCN layer, the representation of node , denoted as , is computed based on the representations of its adjacent nodes in the -th layer. This update is governed by the following rule:
where is a normalization constant that accounts for the degrees of the nodes and , is the learnable weight matrix, is the bias vector in the -th layer, and denotes a non-linear activation function. Through repeated topology-aware aggregation and semantic transformation, node embeddings progressively capture structural patterns and semantic information.
We train a homologous area alignment model to learn area-level embeddings that maximize similarity for homologous areas and minimize it for non-homologous ones. Based on homologous function pairs identified by the function matching module, we construct AFCG pairs as alignment inputs. An area pair is labeled as aligned if their embedding similarity exceeds a predefined threshold . All aligned area pairs between and are then forwarded to the Reuse Discrimination module for further analysis; if no aligned areas are detected, the binaries are classified as unrelated with respect to reuse.
Reuse Discrimination
This module differentiates donor areas from recipient areas by analyzing the topological differences between homologous areas and designing two algorithms to extract topology-sensitive features. Building upon these features, it further employs advanced ensemble learning techniques to construct a model of the relationships between homologous area pairs, thereby enabling the effective discrimination between real reuse and deceptive reuse.
As shown in Figure 4, donor areas encapsulate core functionalities within the , exhibiting stronger centrality and export-linked characteristics. In contrast, recipient areas contribute auxiliary logic to the , displaying simpler structures with fewer such connections. Building on this observation, we perform an in-depth analysis of these differences and introduce two topologically-sensitive features: a centrality feature, which evaluates the structural prominence of a code area within the binary based on its topological connectivity and functional impact; and an export-affinity feature, which measures the strength of its association with the binary’s exported functions. In the following sections, we will detail the algorithms used to extract these two features and explain how they can be applied to facilitate reuse discrimination and TPL detection.

Figure 4. Topological Differences Between Donor and Recipient Areas. Donor areas in their respective binaries exhibit higher centrality and stronger connectivity to exported functions, whereas Recipient areas present simpler topological structures with substantially fewer interconnections.
Centrality Score Calculation
Existing work applies graph-based centrality measures to assess node importance in dependency graphs [22]. Extending this approach to binary analysis, we employ the PageRank algorithm to compute centrality scores for aligned area pairs and introduce interaction weights to reduce the effect of non-interactive centrality, leading to more effective evaluation.
We begin with the conventional PageRank algorithm, which estimates the relative importance of each function within the binary’s FCG through an iterative process. This algorithm provides a probabilistic assessment of a function’s centrality within its local neighborhood. For each function in a neighborhood subgraph (as defined in § 3.3), its influence at iteration is computed as:
where is the total number of functions in the code area, is the damping factor, denotes the set of functions that invoke , and represents the number of outgoing calls from function . While the PageRank score reflects the global structural prominence of functions in the binary, it does not fully capture the contextual interactions between a function within the area and external functions. To address this limitation, we introduce an interaction weight for each function , quantifying its external connectivity relative to its overall interactions. This weight is defined as:
where and denote the sets of intra-area and inter-area function call edges. Finally, the customized centrality score of function is computed by weighting its PageRank score with . Accordingly, the overall centrality score of an area is given by the average weighted importance of all its constituent functions:
where is the number of functions in area . For each area pair , we compute their respective centrality features and , which are subsequently used as input to the reuse discrimination model.
Export-Affinity Score Calculation
Existing work identifies relationships between code areas by directly counting the number of exported functions between two areas, which lacks robustness [15]. Extending this approach to achieve a deeper understanding of their interconnections, we extract transition paths from exported functions to associated areas within the binary, compute cumulative transition probabilities along all such paths, and define the export-affinity score as the average Cumulative Transition Probability (CTP).
We begin with a reverse reachability analysis that identifies all valid execution paths from each exported function to the area . A valid transition path is defined as a sequence of function calls:
where ,
where , and for all preceding nodes , . This constraint guarantees that each path originates strictly from outside the target area and enters only at the terminal function. We aggregate all such paths from to into a set , which serves as the foundation for the subsequent structural affinity estimation. Next, we quantify the structural reachability of the area from each exported function by computing the CTP for every path in . Given the absence of dynamic profiling data, we adopt a uniform branching assumption. By distributing probability mass uniformly across outgoing edges, this assumption induces a structural decay effect that inherently penalizes paths with high fan-out. This design ensures that the affinity score measures structural tightness rather than execution likelihood; consequently, direct, quasi-deterministic calls contribute significantly more than connections mediated by complex, multi-branch structures. We mathematically operationalize this logic as a probabilistic chain. For a given path , its CTP is formally defined as the product of edge-level transition probabilities along the path:
where denotes the set of immediate callees of function . This formulation assumes equal probability for all branches from a given function node in the function call graph. The total CTP for with respect to area is computed by summing over all valid paths:
which provides a probabilistic measure of how strongly interacts with through all feasible call paths. Finally, we aggregate the CTP scores of all exported functions toward area to compute the average CTP, and assess the overall export-affinity of the area:
where denotes the number of exported functions in the binary. The score quantifies the interaction intensity between the exported interface and the code area, as determined by the call graph topology. For each area pair , we derive the export-affinity features and , which are used as inputs to the reuse discrimination model to identify code reuse patterns. It should be noted that if , then is defined to be zero, ensuring the mathematical consistency of the formulation and preventing undefined behavior in cases where no exported functions are present in the binary.
Area Classification This step integrates the centrality and export-affinity scores of code areas in both the and , enabling effective discrimination between real and deceptive code reuse. For each code area, the following four topologically-sensitive features are extracted:
: Centrality Score of in
: Export-affinity Score of in
: Centrality Score of in
: Export-affinity Score of in
These features jointly capture the internal importance of an area—reflected by centrality—and its external interaction potential—quantified by export-affinity—both essential for reuse analysis. To enable reliable classification based on these features, we adopt the gradient boosting framework LightGBM [59], which efficiently handles complex interactions, scales better than traditional machine learning techniques, and requires significantly less computational power compared to deep learning methods. The reuse discrimination model can be formalized as follows:
where represents the reuse type classification label, with 1 indicating real reuse between homologous areas, and 0 indicating deceptive reuse. All homologous area pairs exhibiting real reuse between and are subsequently used for final TPL detection. If more than three homologous area with real reuse are identified, the binaries are classified as exhibiting real reuse; otherwise, they are classified as exhibiting deceptive reuse.
Experiments
In this section, we present a comprehensive evaluation of the proposed DeRED by comparing its effectiveness with a range of baselines across diverse tasks. The experiments are designed to address the following research questions:
RQ1: How effectively does DeRED mitigate deceptive reuse, and how does this improve the effectiveness of TPL detection?
RQ2: How do topologically-sensitive (i.e., Centrality Feature and Export-Affinity Feature) features improve the effectiveness of TPL detection in DeRED?
RQ3: How do function matching and area alignment enhance TPL detection effectiveness of DeRED?
RQ4: How well does DeRED maintain the robustness of TPL detection across diverse architectures and compiler optimization levels?
Experiment Settings & Metrics
The experimental system is built on Ubuntu 22.04, with hardware including an Intel Xeon 128-core 3.0 GHz processor (with hyper-threading support), 1 TB of memory, and dual NVIDIA V100 32 GB GPUs, providing ample resources for algorithm execution and comparison. Notably, due to its lightweight nature, DeRED can also run effectively on systems without GPU support. For binary disassembly, we use the industry-standard decompiler IDA Pro 9.1 for reverse engineering and file analysis, whose robust feature set meets the evaluation requirements. The core system is implemented in Python 3.8, leveraging Python’s extensive library ecosystem while ensuring engineering convenience. Our framework trains three distinct models: MobileNetv2 for function matching, a GCN for area alignment, and LightGBM for reuse discrimination. Regarding training strategies, the deep learning models (MobileNetv2 and GCN) were optimized using the Adam optimizer with a weight decay of and an initial learning rate of 0.001. We configured the batch size to 128 for MobileNetv2 and 256 for the GCN. Both models underwent training for a maximum of 100 epochs, employing Early Stopping (patience=10) and a dropout rate of 0.5 to prevent overfitting. Conversely, the LightGBM classifier was configured with 100 estimators, a learning rate of 0.1, and 31 leaves. All datasets were randomly partitioned into training, validation, and testing sets with a ratio of 8:1:1.
To determine the optimal decision boundaries, we employed an empirical calibration strategy based on the training partitions of the D-Func and D-Area datasets. We analyzed the probability density functions of cosine similarities for positive and negative samples within these training sets to identify intersection points that maximize class separation. This process yielded thresholds of and , respectively. To verify the generalization capability of these empirically derived values, we visualized the distribution of a representative subset of 500 pairs randomly sampled from the held-out validation sets (unseen during threshold selection). This subset size was selected specifically to ensure visual clarity and avoid overplotting, allowing for a distinct observation of the distribution trends. As illustrated in Figure 5, the selected thresholds align with the natural demarcation between homologous and non-homologous samples in the validation data, confirming their robustness without overfitting to the training distribution.

Figure 5. Figure 5: Cosine Similarity Distributions for Function and Area Pairs. Red dashed lines mark empirical thresholds of 0.65 and 0.74, effectively separating positive (orange dots) and negative (gray crosses) samples. This distinct demarcation validates the robustness of the thresholds in identifying homologous code.
To evaluate DeRED, we use standard metrics such as Precision, Recall, F1 Score , and the Area Under the Receiver Operating Characteristic Curve (AUC-ROC). These metrics are applied across tasks such as function matching, area alignment, reuse discrimination, and TPL detection. Precision measures the proportion of correctly predicted positive instances among all predicted positives, reflecting the accuracy of positive predictions. Recall measures the proportion of actual positive instances that are correctly identified, capturing the completeness of detection. The F1 Score is the harmonic mean of Precision and Recall, providing a balanced evaluation that accounts for both false positives and false negatives. Furthermore, the ROC curve illustrates the trade-off between the True Positive Rate (TPR) and the False Positive Rate (FPR), with the AUC quantifying the model’s overall capability to distinguish between classes across various thresholds.
Dataset
To comprehensively evaluate the effectiveness and robustness of DeRED across various TPL reuse scenarios, including deceptive cases, we have curated three datasets: D-Func, D-Area, and D-TPL.
D-Func: For training and evaluation of the function matching model in DeRED, we utilize a benchmark dataset introduced in [23], which has been widely adopted in prior research. This dataset encompasses 7 representative projects, resulting in 24 distinct libraries compiled across three architectures (ARM, x86, x64) and four optimization levels (O0, O1, O2, O3). In total, the dataset comprises 2,689 binary files and 13.8 million functions, thereby offering diverse and realistic scenarios for model development.
D-Area: For the training and evaluation of the area alignment model in DeRED, we employ a dataset derived from LibAM [14], a well-established and widely-recognized dataset in the field of TPL detection. This dataset includes 289 binary files from 24 popular projects, spanning three architectures and four optimization levels. The dataset contains a total of 758,880 homologous areas. LibAM’s widespread adoption in benchmarking stems from its diverse and representative binary collection, ensuring a rigorous evaluation of the proposed model.
D-TPL: For the training and evaluation of the reuse discrimination and TPL detection model in DeRED, we first crawled and analyzed the dependency metadata of 1,864 projects from the Conan repository—which encompasses inter-TPL reuse relationships such as minizip reusing zlib and bzip2—and constructed a dictionary to capture their reuse relationships, formatted as {'minizip': ['zlib', 'bzip2']}. Informed by this dictionary, we curated a set of 83 representative projects for compilation, specifically targeting those involved in more than three reuse relationships, acting as either a donor or a recipient. This selection criterion ensures that the dataset captures complex and diverse reuse patterns prevalent in real-world software ecosystems. Finally, using the Conan client in a Linux environment, we compiled the selected projects, generating 572 corresponding binaries, as a single project typically yields multiple binary artifacts. To facilitate a comprehensive evaluation of DeRED’s performance in TPL detection, reuse discrimination, and realistic scenario adaptation, we further constructed three dataset subsets based on the aforementioned binaries:
D-TPL-1: To evaluate DeRED in the TPL detection task, we identified real reuse samples directly from explicit dependency lineages in the Conan repository [3] and constructed deceptive reuse samples by pairing projects that share overlapping function names but lack dependency connections. To ensure label reliability, three inspectors independently conducted a comprehensive manual review of the entire candidate set. Disagreements were resolved via voting, ultimately yielding 300 pairs of verified genuine reuse and 288 pairs of deceptive reuse.
D-TPL-2: To evaluate DERED in the TPL detection task, we identified real reuse samples via direct function name matching. For deceptive reuse, we employed a two-phase pipeline: (1) Candidate Generation, identifying potential pairs by matching function names and structural features across unrelated projects; and (2) Hybrid Verification, utilizing DeepSeek-V2 [24] with chain-of-thought prompting to analyze semantic divergence. The prompting strategy directs the model to evaluate reuse directionality and authenticity by examining package naming conventions, copyright declarations, and directory hierarchies. The final filtered dataset comprises 30,000 genuine and 30,000 deceptive reuse pairs.
D-TPL-3: cross-architecture and cross-optimization TPL detection tasks, we utilized the binaries compiled under three architectures (x86, x64, and ARM) and four optimization levels (O0, O1, O2, and O3). Following the same generation pipeline and validation criteria as D-TPL-1, we extended the scope to include these diverse compilation settings. Based on the established reuse relationships, we randomly selected 10,000 binary pairs exhibiting real reuse and 10,000 pairs exhibiting deceptive reuse under cross-compilation settings.
Baseline
To comprehensively evaluate the effectiveness of DERED across function matching, area alignment, reuse detection, and TPL detection, Table 2 systematically summarizes the key technical differences across these three stages.
| Method | Function Matching | Area Alignment Mechanism | Reuse Discrimination |
| ISRD [12] | Graph-based (Gemini) [20]: Structure2Vec embedding recursively aggregating block attributes over ACFG. code-based (Jtrans) [21]: Jump-aware BERT encoding control flow dependencies. | : Matched function ratio > 50%. | No reuse discrimination mechanism; simple code matching is directly regarded as code reuse. |
| LibDB [13] | : Connected subgraph size . | ||
| LibAM [14] | / : Structural Similarity encoded via Siamese GNN and Alignment Length Similarity of connected areas. | ||
| LibDI [15] | Text-Based Disc. | ||
| DERED | : Markov CNN. | : GCN on AFCG structures. | Topology-Based Disc. |
Table 2. Comparison of Key Features between DERED and Baseline Methods.
First, regarding function matching, DERED employs a custom Markov matrix approach combined with a lightweight CNN, as detailed in § 3.2. In contrast, to ensure a fair comparison, we standardized the matching step for all baselines using Gemini [20] and JTrans [21], representing state-of-the-art graph-based and code-based embedding approaches, respectively. Subsequently, DERED and the baselines perform area alignment based on these matched functions. Specifically, DERED conducts alignment using GCNs on AFCG structures (§ 3.3), whereas the baseline methods adopt the following distinct mechanisms:
ISRD [12]: Adopts a ratio-based criterion, confirming area alignment when more than 50% of the functions in an area are matched based on similarity.
LibDB [13]: Enforces topological constraints, requiring at least three functions form a connected subgraph within the area’s FCG to establish alignment.
LibAM [14]: Determines alignment by grouping matched functions into connected components and evaluating them using a hybrid metric that combines structural similarity with alignment length similarity.
LibDI [15]: Inherits the alignment strategy of LibAM but extends it by incorporating an additional reuse discrimination mechanism, as detailed below.
Finally, regarding reuse discrimination, only DERED and LibDI perform this specific verification stage. While DERED leverages topology-sensitive features of function areas (§ 3.4), LibDI performs reuse discrimination by analyzing string constants and exported function names.
Answering to RQ1
To address RQ1, we design two interrelated experiments focusing on reuse discrimination and TPL detection.
The first experiment (Reuse Discrim) aims to prove that DERED can effectively mitigate deceptive reuse. The second experiment (TPL Detect) aims to prove that DERED can enhance TPL detection effectiveness by mitigating deceptive reuse. In both experiments, performance is measured with three standard metrics—precision, recall, and F1 score—and DERED is evaluated against four representative baselines: ISRD, LibDB, LibAM, and LibDI.
Reuse Discrim evaluates the effectiveness of each method in reuse discrimination at the code area level, processing area pairs labeled as real or deceptive reuse from the D-TPL-2 dataset. As demonstrate in Table 3, DERED achieves a precision of 96.2%, a recall of 97.8%, and an F1 score of 96.9%, indicating a clear improvement in precision and a substantial reduction in false positives compared to baselines. However, DERED still exhibits a small number of false positives caused by ambiguous donor-recipient relationships, particularly in minute code fragments where topological distinctiveness is low. Among the baselines, LibDI performs the best, with a precision of 82.1%, a recall of 88.4%, and an F1 score of 85.1%. LibAM follows with 72.7% precision, 86.1% recall, and 78.8% F1 score, while LibDB shows moderate performance and ISRD exhibits the weakest overall performance. Compared to LibDI, DERED shows absolute improvements of 14.1% in precision, 9.4% in recall, and 11.8% in F1 score, highlighting its enhanced effectiveness in mitigating deceptive reuse.
| Exp. | Method | Precision | Recall | F1 |
| Reuse Discrim (Area) | ISRD [12] | 16.5% | 74.9% | 27.0% |
| LibDB [13] | 46.3% | 79.6% | 58.5% | |
| LibAM [14] | 72.7% | 86.1% | 78.8% | |
| LibDI [15] | 82.1% | 88.4% | 85.1% | |
| DeRed | 96.2% | 97.8% | 96.9% | |
| TPL Detect (Binary) | ISRD [12] | 19.4% | 70.3% | 30.4% |
| LibDB [13] | 44.1% | 81.6% | 57.2% | |
| LibAM [14] | 76.8% | 91.2% | 83.4% | |
| LibDI [15] | 84.6% | 92.8% | 88.5% | |
| DeRed | 97.2% | 98.3% | 97.7% |
Table 3. Comparative Evaluation of DERED and Baselines for Reuse Discrimination and TPL Detection (RQ1).
TPL Detect evaluates the effectiveness of each method in TPL detection at the binary level, processing binary pairs labeled as real or deceptive reuse from the D-TPL-1 dataset. As demonstrate in Table 3, DERED achieves a precision of 97.2%, a recall of 98.3%, and an F1 score of 97.7%, indicating that the mitigation of deceptive reuse enables DERED to identify more reliable reuse areas and thereby improve overall detection effectiveness. Among the baselines, LibDI performs the best, with a precision of 84.6%, a recall of 92.8%, and an F1 score of 88.5%. LibAM follows with 76.8% precision, 91.2% recall, and 83.4% F1 score, while LibDB shows moderate performance and ISRD exhibits the weakest overall performance. Compared with LibDI, DERED improves precision by 12.6%, recall by 5.5%, and F1 score by 9.2%, confirming that the mitigation of deceptive reuse contributes to reducing false positives and improving effectiveness in TPL detection. To evaluate robustness beyond point metrics, Figure 6 presents the ROC curves for DERED, LibDI, and LibAM. DERED achieves a dominant performance with an AUC of 0.989, surpassing LibDI and LibAM. Geometrically, the DERED curve converges closely to the ideal coordinate, indicating high sensitivity with minimal error. Furthermore, the zoomed-in inset highlights that DERED maintains a rapid ascent in TPR even at extremely low FPR thresholds. This trajectory confirms DERED effectively suppresses false alarms, offering a superior sensitivity-specificity trade-off compared to baselines.

Figure 6. ROC Curves Evaluating TPL Detection Effectiveness. DERED (red, AUC=0.989) outperforms LibDI (green, 0.960) and LibAM (blue, 0.915). The zoomed-in inset highlights DERED’s rapid ascent at low FPR thresholds.
In summary, DERED outperforms all baseline methods across the three evaluation metrics in both the Reuse Discrim and TPL Detect experiments, with especially pronounced improvements in precision. These results confirm that the reuse discrimination module integrated into DERED, which leverages topologically sensitive features to model the direction of code area reuse, effectively mitigates deceptive reuse, thereby providing more effective TPL detection. In contrast, ISRD and LibDB, which rely on function-level code matching for TPL detection, fail to capture complex reuse relationships. Consequently, their overall performance across all metrics remains relatively low. LibAM and LibDI both adopt area alignment strategies, which enable more accurate code matching compared to ISRD and LibDB, but they still fail to effectively mitigate deceptive reuse. Specifically, LibAM lacks a reuse discrimination mechanism, leading to more false positives and lower precision compared to LibDI. LibDI performs reuse discrimination through string and exported function features, which lack sufficient robustness, leading to an overall performance that remains inferior to that of DERED.
Answering to RQ1
DERED leverages a reuse discrimination module to effectively mitigate deceptive reuse, thereby enabling more reliable TPL detection.
Answering to RQ2
To address Research Question 2 (RQ2), we propose four variants of DERED: No-Topo, Central-Only, Export-Only, and Full-Model. These variants are designed to facilitate ablation experiments on DERED. In No-Topo, topological sensitive features are excluded from both reuse discrimination and TPL detection; in Central-Only, only centrality features are incorporated; in Export-Only, only export-affinity features are considered; and in Full-Model, the complete implementation of DERED is employed. All variants are evaluated under the same experimental setup as in RQ1.
As demonstrate in Table 4, DERED exhibits substantial performance variation under different variants of DERED. Using the No-Topo configuration, the model achieves only
| Exp. | Variant | Precision | Recall | F1 |
| Reuse Discrim. (Area) | No-Topo | 75.8% | 87.1% | 81.1% |
| Reuse Discrim. (Area) | Central-Only | 87.5% | 93.7% | 90.5% |
| Reuse Discrim. (Area) | Export-Only | 83.1% | 92.4% | 87.3% |
| Reuse Discrim. (Area) | Full-Model | 96.2% | 97.8% | 96.9% |
| TPL Detect. (Binary) | No-Topo | 80.7% | 91.9% | 85.9% |
| TPL Detect. (Binary) | Central-Only | 89.5% | 95.3% | 92.3% |
| TPL Detect. (Binary) | Export-Only | 85.1% | 94.1% | 89.3% |
| TPL Detect. (Binary) | Full-Model | 97.2% | 98.3% | 97.7% |
Table 4. Comparative Evaluation of Different Variants of DERED for Reuse Discrimination and TPL Detection (RQ2).
75.8% precision, 87.1% recall, and an 81.1% F1 score in reuse discrimination, and 80.7% precision, 91.9% recall, and an 85.9% F1 score in TPL detection. When the Central-Only configuration is applied, the results improve considerably, reaching 87.5% precision, 93.7% recall, and a 90.5% F1 score in reuse discrimination, alongside 89.5% precision, 95.3% recall, and a 92.3% F1 score in TPL detection. In contrast, the Export-Only configuration yields slightly weaker outcomes compared with Central-Only, achieving 83.1% precision, 92.4% recall, and an 87.3% F1 score in reuse discrimination, and 85.1% precision, 94.1% recall, and an 89.3% F1 score in TPL detection. Most notably, the Full-Model achieves significantly better results—96.2% precision, 97.8% recall, and a 96.9% F1 score in reuse discrimination, and 97.2% precision, 98.3% recall, and a 97.7% F1 score in TPL detection—representing absolute improvements of 11.8%, 8.4%, and 5.4% in F1 score over the No-Topo, Export-Only, and Central-Only variants, respectively, marking the indispensability of integrating topological features for both effective reuse discrimination and reliable TPL detection.
In summary, DERED demonstrates that the inferior effectiveness of individual feature arises from their limited ability to capture the nuanced patterns of reuse type. Specifically, Centrality-based features focus on the global structure, effectively identifying the significance of code areas within the entire binary; however, they may fail to account for the dependency relationships within local interactions. On the other hand, Export-based features emphasize the interactions between code areas and externally exported functions by analyzing local paths, yet they are insufficient in capturing the intricate dependencies within the global structure. The integration of Centrality and Export-Affinity features effectively captures both global and local characteristics, thus mitigating the limitations of individual features and offering a more holistic understanding of reuse patterns.
Answering to RQ2
DERED integrates topology-sensitive features, providing a comprehensive understanding of reuse patterns, enabling effective TPL detection.
Answering to RQ3
To address RQ3, we performed a cross-methodological evaluation of DERED using the D-Func and D-Area datasets. For the Func Match task, we employed Gemini [20] and JTrans [21] as representative baselines for graph-based and code-based paradigms, respectively. For Area Align, we benchmarked against ISRD [12], LibDB [13], and LibAM [14]. Crucially, in addition to the accuracy metrics utilized in previous RQs, this study evaluates computational overhead, specifically the execution time required for analyzing individual functions and areas.
For Func Match, the results in Table 5 show that while baselines like JTrans and Gemini yield F1 scores of 96.3% and 94.5% respectively, DERED maintains a competitive accuracy of 92.6%. In terms of efficiency, DERED requires only 0.011 ms per function, representing a speedup of approximately 67 times over JTrans (benchmarked with a batch size of 128). Analytically, these figures highlight a strategic trade-off: despite a marginal 3.7% difference in F1 score compared to JTrans, DERED achieves orders-of-magnitude improvements in speed. This efficiency stems from our Markov-based formulation, which avoids the computationally expensive feature extraction inherent in complex graph-based or code-based baselines.
| Exp. | Method | Prec. | Rec. | F1 | Time |
| Func Match | Gemini [20] | 95.2% | 93.8% | 94.5% | 0.183 ms |
| Func Match | JTrans [21] | 96.7% | 95.8% | 96.3% | 0.736 ms |
| Func Match | 93.5% | 91.7% | 92.6% | 0.011 ms | |
| Area Align | ISRD [12] | 38.6% | 67.3% | 49.1% | 0.023 ms |
| Area Align | LibDB [13] | 71.5% | 85.3% | 77.8% | 0.054 ms |
| Area Align | LibAM [14] | 95.8% | 93.1% | 94.4% | 0.169 ms |
| Area Align | 95.2% | 96.3% | 95.8% | 0.144 ms |
Table 5. Comparative Evaluation of DERED and Baselines for Function Matching and Area Alignment (RQ3)
For Area Align, the results in Table 5 show that DERED achieves a superior F1-score of 95.8%. Notably, compared to the leading baseline LibAM, DERED improves accuracy by 1.4% while reducing inference time by approximately 14.8%. In contrast, while baselines such as ISRD and LibDB exhibit high efficiency, they yield suboptimal F1 scores. These results demonstrate that DERED effectively overcomes the accuracy-latency trade-off: unlike methods with limited representation capabilities (ISRD/LibDB), our Siamese-based
GCN architecture efficiently captures hybrid code and structural semantic features, outperforming LibAM in both precision and speed.
In summary, considering both function matching and area alignment, DERED improves efficiency while ensuring performance, making it the optimal method currently available. For function matching, DERED employs a Markov graph combined with a lightweight MobileNet, providing a significant efficiency advantage over traditional graph-based methods. In the area alignment phase, it utilizes an AFCG in conjunction with a Siamese-based GCN architecture, which not only ensures effectiveness but also offers higher efficiency compared to LibAM.
Answering to RQ3
The Function Matching and Area Alignment modules of DERED achieve a balanced trade-off between efficiency and performance, providing a solid foundation for reuse discrimination and TPL detection.
Answering to RQ4
To address RQ4, we conducted a comprehensive evaluation of the TPL detection effectiveness of DERED using the realistic scenarios subset D-TPL-3 of the D-TPL dataset. The evaluation employed the F1 score as the metric and was carried out across four distinct settings: (1) NATIVE, where the target and candidate binaries share the same architecture and optimization level; (2) CROSS_ARCH, where the binaries differ in architecture but share the same optimization level; (3) CROSS_OPTI, where the binaries share the same architecture but differ in optimization levels; and (4) CROSS_BOTH, where the binaries differ in both architecture and optimization levels.
As shown in Figure 7, the F1 scores for individual binary pairs are visualized using a solid line, while the overall average performance is highlighted by colored background regions. The results indicate that DERED maintains strong TPL detection effectiveness in the majority of compilation scenarios. In the NATIVE setting, where binaries share the same architecture and optimization level, DERED achieves the highest F1 score of 97.7%, indicating its optimal performance under ideal consistency. In the CROSS_ARCH setting, where binaries differ in architecture, the F1 score decreases to an average of 92.9%. In the CROSS_OPTI setting, where the architecture remains consistent but optimization levels vary, the average F1 score is 92.0%. Finally, in the CROSS_BOTH setting, which involves simultaneous changes in both architecture and optimization, DERED yields an average F1 score of 78.1%. This performance degradation is primarily attributed to significant code divergence resulting from the compounding effects of architectural heterogeneity and optimization disparities. These findings demonstrate that DERED maintains robust performance across the CROSS_ARCH, CROSS_OPTI, and CROSS_BOTH scenarios. In all scenarios, it retains a reasonable level of detection capability.

Figure 7. Evaluation of DERED’s effectiveness across four compilation scenarios: NATIVE, CROSS_ARCH, CROSS_OPTI, and CROSS_BOTH. The markers connected by the solid line represent the F1 Scores for individual binary pairs, whereas the colored background regions denote the overall average performance for each scenario.
In summary, DERED demonstrates strong robustness in cross-architecture and cross-optimization TPL detection scenarios, which is attributed to the specialized design of its core modules. The function matching module captures functional behavior patterns by constructing a Markov matrix from normalized opcode sequences, reducing reliance on specific instruction sets or optimization strategies. The area alignment module leverages the AFCG to model function call relationships and attribute features, alleviating inconsistencies caused by architectural variations and compiler optimizations. Finally, the reuse discrimination module detects code reuse through topologically sensitive features that remain stable across compilation scenarios, further strengthening the robustness of TPL detection.
Answering to RQ4
Through the specialized design of its three core modules, DERED exhibits strong robustness in TPL detection across diverse architectures and optimization levels, consistently maintaining high effectiveness even when both factors vary simultaneously.
Case Study
To empirically validate the practical efficacy of DERED, we conducted a comparative case study against BinaryAI [17], a representative commercial software composition analysis tool. While BinaryAI serves as a critical industry baseline, its inclusion in our large-scale quantitative evaluation was precluded by its closed-source nature, which enforces strict daily query quotas and anti-automation mechanisms. Consequently, we utilize this targeted case study as a representative qualitative evaluation. This approach allows for a rigorous manual verification of DERED against industry standards, bypassing the limitations of batch-processing commercial APIs. In this experiment, lzbench was designated as the , while bzip2-1.0.6 (CVE-2019-12900) and minizip-4.0.2 (CVE-2023-48107) served as the . As
@page 12/16 starts_mid=0 ends_mid=1 illustrated in Fig. 2, lzbench exhibits real code reuse from bzip2, confirming the presence of logic related to CVE-2019-12900. In contrast, the reuse associated with minizip is deceptive, meaning the vulnerable code for CVE-2023-48107 is physically absent from lzbench. Experimental results confirmed that BinaryAI effectively detected real reuse between lzbench and bzip2, but failed to filter deceptive reuse between lzbench and minizip, incorrectly flagging CVE-2023-48107 in lzbench. This false positive arises because BinaryAI conflates code matching with code reuse and lacks the capability to identify deceptive reuse, which leads to the propagation of erroneous vulnerability reports.
As shown in Figure 8, we conducted a detailed comparison of code reuse detection using BinaryAI and DERED on five specific code areas. The figure presents matching scores for each tool across real and deceptive code reuse scenarios. In real reuse scenarios, both tools demonstrate effective detection, with BinaryAI scoring between 0.92 and 0.99 and DERED scoring between 0.85 and 0.94, indicating reliable identification of real reuse. However, a significant divergence is observed in deceptive scenarios. DERED effectively distinguishes deceptive reuse by analyzing donor-recipient relationships, resulting in appropriately low matching scores of 0.08–0.15. Conversely, BinaryAI fails to differentiate deceptive cases and erroneously assigns high similarity scores ranging from 0.91 to 0.98. Based on the experimental results, we clarified the mechanism of erroneous vulnerability propagation caused by deceptive reuse. Specifically, the code match between lzbench and minizip stems solely from the fact that both TPLs reuse bzip2. DERED correctly identifies this indirect relationship and avoids establishing a non-existent link. In contrast, BinaryAI misidentifies this shared code as lzbench directly reusing minizip. Consequently, BinaryAI erroneously reports that lzbench contains CVE-2023-48107—a vulnerability specific to minizip. Manual verification confirmed that the vulnerable code corresponding to CVE-2023-48107 is physically absent from lzbench. Although such false positives could theoretically be eliminated through manual analysis, the prohibitive cost of intervention highlights the critical need for DERED’s automated detection capabilities.

Figure 8. Reuse Detection Performance of BinaryAI and DERED across five representative code areas. BinaryAI-RR and DERED-RR denote (real) reuse detection result between bzip2 and lzbench, while BinaryAI-DR and DERED-DR display (deceptive) reuse detection result between lzbench and minizip.
Leveraging the real reuse identified by DERED, we further detected vulnerabilities in lzbench. Specifically, DERED located the vulnerable function from bzip2 within lzbench. CVE-2019-12900 affects bzip2 up to version 1.0.6 and was remediated in version 1.0.7. Since TPL detection typically lacks version-level granularity, we employed string analysis to confirm that the target binary corresponds to lzbench 2.0.1. In contrast, relying on BinaryAI would have incurred significant verification overhead due to false positives. To investigate the details of vulnerability propagation, we subsequently compared the source code of decompress.c between bzip2 1.0.6 and 1.0.7. This analysis revealed that version 1.0.6—integrated within lzbench 2.0.1—omits a critical upper-bound check on the variable , as shown below:
#define BZ_G_SIZE 50
#define BZ_MAX_SELECTORS (2 + (9000000 / BZ_G_SIZE))
UChar selectorMtf[BZ_MAX_SELECTORS];
...
GET_BITS(BZ_X_SELECTOR_1, nGroups, 3);
if (nGroups < 2 || nGroups > 6) RETURN(BZ_DATA_ERROR);
GET_BITS(BZ_X_SELECTOR_2, nSelectors, 15);
if (nSelectors < 1) RETURN(BZ_DATA_ERROR); // bzip2 1.0.6
if (nSelectors < 1) RETURN(BZ_DATA_ERROR); // lzbench 2.0.1
for (i = 0; i < nSelectors; i++) {
...
s->selectorMtf[i] = j; // out-of-bounds write
}
The absence of this check permits out-of-bounds writes to the array, constituting the root cause of CVE-2019-12900. Consequently, our analysis confirms that lzbench, by incorporating the vulnerable bzip2 code, inherits this flaw and is susceptible to exploitation. Ultimately, this case study demonstrates that DERED not only minimizes false positives by filtering out deceptive reuse but also enables the accurate identification of inherited vulnerabilities, thereby validating its efficacy in realistic scenarios.
Related Work
Binary Code Similarity Calculation
Binary similarity calculation plays a crucial role in software reuse detection [8, 12, 13, 14], malware analysis [25, 26, 27, 28], vulnerability discovery [29, 30, 31, 32, 33, 34, 35, 36, 37, 38], and patch detection [39, 40, 41, 42, 43, 44], and generally struggles to achieve an optimal balance between accuracy and computational efficiency. Text hash–based approaches such as Gitz [46] and VIVA [47] are computationally efficient but fragile in the presence of complex binary compilation settings, leading to accuracy loss. In contrast, symbolic execution techniques such as BinSim [25] and Bingo [48] enhance precision but are prone to path explosion, thereby incurring prohibitive computational overhead. Recently proposed deep learning methods [49, 50, 51] demonstrate strong representational capacity but demand extensive training data and substantial computing resources, constraining their practical efficiency. Specifically, code embedding-based solutions [21, 52] learn token- and context-level code representations for tasks such as code completion and defect prediction. In contrast, graph-based techniques using GNNs [53, 54] capture structural semantics by modeling programs as abstract syntax trees or control/data-flow graphs. Despite distinct modeling paradigms, both approaches suffer from notable efficiency issues, including high computational and memory overhead, slow training and inference, and limited scalability to large real-world codebases or incremental updates.
In this work, DeRED employs a lightweight Markov matrix encoding scheme in conjunction with a graph convolutional network to identify homologous functions, which significantly improves computational efficiency. In addition, DeRED incorporates an novel area alignment strategy based on AFCGs to accurately locate homologous areas, thereby providing robust and reliable support for its subsequent reuse discrimination module. Ultimately, these synergistic designs allow DeRED to balance efficiency and performance, ensuring more reliable TPL detection.
TPL Detection: TPLs are widely used in modern software development, but insecure TPLs can introduce vulnerabilities, making accurate reuse detection essential. Existing TPL detection approaches can be broadly categorized into binary-to-source methods, which attempt to match binaries with their source code, and binary-to-binary methods, which directly compare binaries without relying on source availability. Research on binary-to-source TPL detection, such as BinaryAI [17] and TPLite [22], employs transformer-based matching and graph-assisted function-level origin detection, respectively. However, their reliance on binary-to-source mapping makes them impractical when source code is unavailable—a common scenario in software binary with proprietary and closed-source components—thus limiting their applicability in real-world TPL detection. Recent methods for binary-to-binary detection such as BAT [58], OSSPolice [10], and B2SFinder [9] use constant-based fingerprints, which are fragile when such constants are absent. Other techniques like ISRD [12] and LibDB [13] rely on function similarity but suffer under compilation variance. To improve precision, ISRD uses similarity thresholds and LibDB utilizes FCG constraints, yet both incur high false positive/negative rates due to reliance on isolated matches. LibAM [14] improves accuracy by identifying reuse areas within the FCG, though its rigid alignment reduces recall.
However, existing TPL detection methods often overlook the directionality of code reuse between code areas, hindering the effective distinction between real and deceptive reuse and leading to false positives in vulnerability assessments. While LibDI [15] has explored complex reuse relationships in TPL, its proposed solution, which relies on function names, strings, and exported functions, suffers from robustness issues. In this work, we systematically analyze real and deceptive reuse cases, examine the topological differences between their corresponding code areas, and exploit these differences for accurate reuse discrimination.
Conclusion
In this study, we present DeRED, a multi-stage framework that simultaneously supports reuse discrimination and TPL detection. Unlike existing methods that often suffer from high false positive rates, DeRED redefines code reuse analysis by focusing on topological relationships within binaries—specifically, the centrality and connectivity of functions with respect to exported interfaces.
DeRED operates in three stages: it first identifies homologous functions using a lightweight Markov matrix encoding combined with a CNN; it then constructs AFCGs and applies a GCN to align homologous areas; finally, it quantifies topological differences between aligned areas to distinguish real from deceptive reuse, thereby enhancing TPL detection performance by reducing false positives.
To validate its effectiveness, we curated a dataset comprising deceptive reuse cases and conducted comprehensive comparisons against state-of-the-art techniques including LibAM, LibDB, and ISRD. Experimental results show that DeRED achieves a reuse discrimination F1 score of 96.9%, substantially reducing false positives and achieving a TPL detection F1 score of 97.7%—outperforming the best prior method by 9.2%. Moreover, DeRED maintains strong generalization capabilities across different architectures and compiler optimizations, with average F1 scores of 92.9% and 92.0%, respectively. Furthermore, comparisons with the commercial code analysis tool BinaryAI demonstrate that DeRED, by mitigating deceptive reuse, enables superior TPL detection and thereby enhances vulnerability detection.
Limitations and Future Work
While DeRED demonstrates robustness against heavily stripped binaries by leveraging intrinsic topological invariants rather than volatile string constants or symbol tables, we acknowledge specific boundaries in our current implementation. First, the tool exhibits a minor rate of false positives arising from topological ambiguities in donor-recipient relationships, particularly involving minute code fragments or generic utility functions with low topological distinctiveness. A representative instance of this ambiguity occurs between the donor zlib and its recipients, minizip and lzbench. The extensive invocation of generic zlib utilities within minizip artificially inflates centrality scores and creates an export-affinity that rivals the original library. Consequently, the model may misidentify the recipient minizip as the primary donor for lzbench, confounding a deceptive reuse relationship with a real one. Although such high-affinity pairings constitute a marginal fraction of our results (less than 2% in our evaluation), they represent a precision bottleneck in handling generic libraries. Second, DeRED relies on the structural stability of the binary. Consequently, its detection accuracy faces challenges when analyzing binaries subjected to aggressive transformations, such as Link-Time Optimization (LTO) or heavy obfuscation. Specifically, LTO introduces cross-module inlining that fundamentally alters function boundaries, while obfuscation techniques deliberately distort execution logic. These mutations disrupt the locality assumptions essential to DeRED, necessitating specialized handling beyond standard structural analysis.
Driven by these identified limitations, our future research will focus on two strategic directions to enhance the tool’s fidelity and applicability. To mitigate the topological ambiguities observed in generic utility functions, we aim to integrate Large Language Models (LLMs) into our detection pipeline. By leveraging the semantic understanding and cross-domain reasoning capabilities of LLMs, we plan to complement topological features with semantic analysis, thereby enabling DeRED to distinguish between real reuse and structural coincidences in complex, low-distinctiveness scenarios. Simultaneously, to address the challenges posed by LTO and obfuscation, we plan to develop specialized preprocessing layers focused on de-obfuscation and structural normalization. This involves exploring hybrid signatures that persist despite aggressive inlining. To support the rigorous validation of these improvements, we will also automate the currently manual verification process of TPL reuse relationships. This automation will facilitate the generation of large-scale datasets, allowing for comprehensive stress-testing of DeRED against increasingly complex and obfuscated targets.
References
References
- [1]GitHub, 2025. GitHub: Where the world builds software. Available at: https://github.com/ [Accessed: 13 October 2025].
- [2]SourceForge, 2025. SourceForge: The open-source software development platform. Available at: https://sourceforge.net/ [Accessed: 13 October 2025].
- [3]Conan, 2025. Conan: C and C++ package manager. Available at: https://conan.io/ [Accessed: 13 October 2025].
- [4]VCPKG, 2025. VCPKG: A C++ package manager for Windows, Linux, and macOS. Available at: https://vcpkg.io/ [Accessed: 13 October 2025].
- [5]Synopsys, 2025. Synopsys: Electronic Design Automation (EDA) Software and Services. Available at: https://www.synopsys.com/ [Accessed: 13 October 2025].
- [6]Chen, YongLe, et al. "AutoFirm: Automatically Identifying Reused Libraries inside IoT Firmware at Large-Scale." arXiv preprint arXiv:2406.12947 (2024).arxiv.org/abs/2406.12947
- [7]Zhao, Binbin, et al. "A large-scale empirical analysis of the vulnerabilities introduced by third-party components in IoT firmware." Proceedings of the 31st ACM SIGSOFT International Symposium on Software Testing and Analysis. 2022.DOI
- [8]Tang W, Lou P, Fu J, et al. Libdx: A cross-platform and accurate system to detect third-party libraries in binary code[C]//2020 IEEE 27th International Conference on Software Analysis, Evolution and Reengineering (SANER). IEEE, 2020: 104-115.
- [9]Yuan Z, Feng M, Li F, et al. B2sfinder: Detecting open-source software reuse in cots software[C]//2019 34th IEEE/ACM International Conference on Automated Software Engineering (ASE). IEEE, 2019: 1038-1049.DOI
- [10]Duan, Ruian, et al. "Identifying open-source license violation and 1-day security risk at large scale." Proceedings of the 2017 ACM SIGSAC Conference on computer and communications security. 2017.DOI
- [11]Yang C, Xu Z, Chen H, et al. ModX: binary level partially imported third-party library detection via program modularization and semantic matching[C]//Proceedings of the 44th International Conference on Software Engineering. 2022: 1393-1405.DOI
- [12]Xu X, Zheng Q, Yan Z, et al. Interpretation-enabled software reuse detection based on a multi-level birthmark model[C]//2021 IEEE/ACM 43rd International Conference on Software Engineering (ICSE). IEEE, 2021: 873-884.arxiv.org/abs/2103.10126
- [13]Tang W, Wang Y, Zhang H, et al. Libdb: An effective and efficient framework for detecting third-party libraries in binaries[C]//Proceedings of the 19th International Conference on Mining Software Repositories. 2022: 423-434.DOI
- [14]Li S, Wang Y, Dong C, et al. Libam: An area matching framework for detecting third-party libraries in binaries[J]. ACM Transactions on Software Engineering and Methodology, 2023, 33(2): 1-35.arxiv.org/abs/2305.04026
- [15]Li, Siyuan, et al. "Libdi: A direction identification framework for detecting complex reuse relationships in binaries." MILCOM 2023-2023 IEEE Military Communications Conference (MILCOM). IEEE, 2023.DOI
- [16]Sandler, Mark, et al. "Mobilenetv2: Inverted residuals and linear bottlenecks." Proceedings of the IEEE conference on computer vision and pattern recognition. 2018.arxiv.org/abs/1801.04381
- [17]BinaryAI, 2025. BinaryAI: A multi-modal software supply chain security analysis platform. Available at: https://www.binaryai.cn/single-file [Accessed: 30 December 2025].
- [18]DUAN, Yue, XueziXiang LI, and Jinghan WANG. "Wang; and YIN, Heng. Deepbindiff: Learning program-wide code representations for binary diffing.(2020)." Proceedings of the Network and Distributed System Security Symposium, California, USA. 2020.DOI
- [19]Yan, Jiaqi, Guanhua Yan, and Dong Jin. "Classifying malware represented as control flow graphs using deep graph convolutional neural network." 2019 49th annual IEEE/IFIP international conference on dependable systems and networks (DSN). IEEE, 2019.DOI
- [20]Xu, Xiaojian, et al. "Neural network-based graph embedding for cross-platform binary code similarity detection." Proceedings of the 2017 ACM SIGSAC conference on computer and communications security. 2017.DOI
- [21]Wang, Hao, et al. "Jtrans: Jump-aware transformer for binary code similarity detection." Proceedings of the 31st ACM SIGSOFT International Symposium on Software Testing and Analysis. 2022.DOI
- [22]Jiang, Ling, et al. "Third-party library dependency for large-scale SCA in the C/C++ ecosystem: How far are we?." Proceedings of the 32nd ACM SIGSOFT International Symposium on Software Testing and Analysis. 2023.DOI
- [23]Marcelli, Andrea, et al. "How machine learning is solving the binary function similarity problem." 31st USENIX Security Symposium (USENIX Security 22). 2022.
- [24]DeepSeek-AI, 2024. DeepSeek-V2: A Strong, Economical, and Efficient Mixture-of-Experts Language Model. Available at: https://github.com/deepseek-ai/DeepSeek-V2 [Accessed: 13 October 2025].arxiv.org/abs/2405.04434
- [25]Ming J, Xu D, Jiang Y, et al. "BinSim: Trace-based semantic binary diffing via system call sliced segment equivalence checking." 26th USENIX Security Symposium (USENIX Security 17). 2017.
- [26]Aghakhani, Hojjat, et al. "When malware is packin’ heat; limits of machine learning classifiers based on static analysis features." Network and Distributed System Security Symposium. Internet Society, 2020.DOI
- [27]Yong Wong, Muiyin, et al. "An inside look into the practice of malware analysis." Proceedings of the 2021 ACM SIGSAC conference on computer and communications security. 2021.
- [28]Cheng, Binlin, et al. "Towards paving the way for large-scale windows malware analysis: Generic binary unpacking with orders-of-magnitude performance boost." Proceedings of the 2018 ACM SIGSAC Conference on Computer and Communications Security. 2018.DOI
- [29]Feng, Qian, et al. "Extracting conditional formulas for cross-platform bug search." Proceedings of the 2017 ACM on Asia conference on computer and communications security. 2017.DOI
- [30]Pewny, Jannik, et al. "Cross-architecture bug search in binary executables." 2015 IEEE Symposium on Security and Privacy. IEEE, 2015.
- [31]Xiao, Haoyu, et al. "Accurate and Efficient Recurring Vulnerability Detection for IoT Firmware." Proceedings of the 2024 on ACM SIGSAC Conference on Computer and Communications Security. 2024.DOI
- [32]Zhou, Anshunkang, et al. "ARCTURUS: Full Coverage Binary Similarity Analysis with Reachability-guided Emulation." ACM Transactions on Software Engineering and Methodology 33.4 (2024): 1-31.DOI
- [33]Li, Siyuan, et al. "TransferFuzz: Fuzzing with Historical Trace for Verifying Propagated Vulnerability Code." arXiv preprint arXiv:2411.18347 (2024).arxiv.org/abs/2411.18347
- [34]Arasteh, Sima, et al. "BinHunter: A Fine-Grained Graph Representation for Localizing Vulnerabilities in Binary Executables." 2024 Annual Computer Security Applications Conference (ACSAC). IEEE, 2024.
- [35]Cova, Marco, et al. "Static detection of vulnerabilities in x86 executables." 2006 22nd Annual Computer Security Applications Conference (ACSAC’06). IEEE, 2006.DOI
- [36]Sparks, Sherri, et al. "Automated vulnerability analysis: Leveraging control flow for evolutionary input crafting." Twenty-Third Annual Computer Security Applications Conference (ACSAC 2007). IEEE, 2007.
- [37]Viega, John, et al. "ITS4: A static vulnerability scanner for C and C++ code." Proceedings 16th Annual Computer Security Applications Conference (ACSAC’00). IEEE, 2000.
- [38]Shimmi, Samia, et al. "Software Vulnerability Detection Using LLM: Does Additional Information Help?" 2024 Annual Computer Security Applications Conference Workshops (ACSAC Workshops). IEEE, 2024.DOI
- [39]Zhang, Hang, and Zhiyun Qian. "Precise and accurate patch presence test for binaries." 27th USENIX Security Symposium (USENIX Security 18). 2018.
- [40]Jiang, Zheyuе, et al. "Pdiff: Semantic-based patch presence testing for downstream kernels." Proceedings of the 2020 ACM SIGSAC Conference on Computer and Communications Security. 2020.DOI
- [41]Xu, Yifei, et al. "Patch based vulnerability matching for binary programs." Proceedings of the 29th ACM SIGSOFT International Symposium on Software Testing and Analysis. 2020.DOI
- [42]Wang, Shu, et al. "Graphpsd: Graph-based security patch detection with enriched code semantics." 2023 IEEE Symposium on Security and Privacy (SP). IEEE, 2023.DOI
- [43]Wang, Xinda, et al. "Patchrnn: A deep learning-based system for security patch identification." MILCOM 2021-2021 IEEE Military Communications Conference (MILCOM). IEEE, 2021.DOI
- [44]Yang, Shouguo, et al. "Towards practical binary code similarity detection: Vulnerability verification via patch semantic analysis." ACM Transactions on Software Engineering and Methodology 32.6 (2023): 1-29.DOI
- [46]David, Yaniv, Nimrod Partush, and Eran Yahav. "Similarity of binaries through re-optimization." Proceedings of the 38th ACM SIGPLAN conference on programming language design and implementation. 2017.
- [47]Xiao, Yang, et al. "Viva: Binary level vulnerability identification via partial signature." 2021 IEEE International Conference on Software Analysis, Evolution and Reengineering (SANER). IEEE, 2021.DOI
- [48]Chandramohan, Mahinthan, et al. "Bingo: Cross-architecture cross-os binary search." Proceedings of the 2016 24th ACM SIGSOFT international symposium on foundations of software engineering. 2016.DOI
- [49]Jiang, Jianguo, et al. "Similarity of binaries across optimization levels and obfuscation." Computer Security–ESORICS 2020: 25th European Symposium on Research in Computer Security, ESORICS 2020, Guildford, UK, September 14–18, 2020, Proceedings, Part I 25. Springer International Publishing, 2020.DOI
- [50]Ben-Nun, Tal, Alice Shoshana Jakubovits, and Torsten Hoefler. "Neural code comprehension: A learnable representation of code semantics." Advances in neural information processing systems 31 (2018).
- [51]Xu, Xiaojun, et al. "Neural network-based graph embedding for cross-platform binary code similarity detection." Proceedings of the 2017 ACM SIGSAC conference on computer and communications security. 2017.DOI
- [52]Zhu, Wenyu, et al. "ktrans: Knowledge-aware transformer for binary code embedding." arXiv preprint arXiv:2308.12659 (2023).arxiv.org/abs/2308.12659
- [53]Yu, Zeping, et al. "Order matters: Semantic-aware neural networks for binary code similarity detection." Proceedings of the AAAI conference on artificial intelligence. Vol. 34. No. 01. 2020.DOI
- [54]Yu, Zeping, et al. "Codecmr: Cross-modal retrieval for function-level binary source code matching." Advances in Neural Information Processing Systems 33 (2020): 3872-3883.
- [58]Hemel, Armijn, et al. "Finding software license violations through binary code clone detection." Proceedings of the 8th Working Conference on Mining Software Repositories. 2011.
- [59]Ke, Guolin, et al. "Lightgbm: A highly efficient gradient boosting decision tree." Advances in neural information processing systems 30 (2017).