Abstract
Third-party libraries (TPLs) are fundamental to modern software development but introduce significant security and legal risks. Detecting TPLs in native binaries is challenging due to compiler optimizations, stripped symbols, and library fusion. We present LibDB, a novel framework that combines traditional feature matching with deep-learning-based function embeddings and a graph-based filtering mechanism to achieve high-accuracy TPL detection and version identification.
Introduction
Software developers rarely write everything from scratch; they rely heavily on Third-Party Libraries (TPLs). However, these libraries can harbor security vulnerabilities or legal landmines such as license violations. While detecting TPLs in source code or Java bytecode is relatively straightforward, doing so in native binaries (compiled C/C++ code) is significantly more difficult.
When code is compiled, human-readable variable and function names are often "stripped" to save space. Furthermore, multiple libraries are often "fused" together into one executable, making it hard to distinguish boundaries. Existing tools usually rely on "basic features" like string literals, but these are easily removed by compilers or developers, leading to low recall and precision. LibDB addresses these issues by focusing on function logic and structural relationships.
Methods
LibDB tackles the detection problem using a sophisticated two-channel pipeline designed for both speed and robustness.
- The Basic Feature Channel: This uses traditional methods, looking for string literals and exported function names. While fast, it is fragile against stripped binaries.
- The Function Vector Channel: This is the core innovation. LibDB uses a Siamese neural network architecture (specifically using Structure2vec) to convert the content of every function into a low-dimensional embedding. Similar functions end up near each other in this vector space, even if they were compiled for different architectures (e.g., ARM vs. x86) or with different optimization levels.
- FCG Filter (Function Call Graph): To prevent false positives, LibDB analyzes how functions call each other. It builds a "mini-FCG" using matched functions as anchor nodes. If the calling relationships in the target binary match the library's structure, the detection is confirmed.
- Version Identification: Once a library is detected, LibDB ranks potential versions by summing similarity scores, allowing it to pinpoint the specific version used.
Datasets and Evaluation
The authors evaluated LibDB using three distinct datasets:
- TPLBinary Dataset: A ground-truth dataset of 24 Android applications containing 112 binaries, specifically designed to test "fused" binaries.
- Cross-5C Dataset: A training set of 13 projects compiled under 120 different combinations of OS, Architecture, Compiler, and Optimization levels.
- FedoraLib Database: A massive, real-world scale database containing ~1,000 libraries and 18.6 million functions.
LibDB achieved an F1 score of 0.70 on the TPLBinary dataset, vastly outperforming state-of-the-art tools like B2SFinder (0.28) and LibDX (0.46). It demonstrated high robustness even when 75% of string features were removed and maintained efficient retrieval speeds, searching 18.6 million functions in just 1.1 seconds.
Key Insights and Conclusion
LibDB proves that function logic is a much more robust fingerprint than string literals. The framework formalizes the "5C" challenge (Cross-OS, Architecture, Compiler, Compiler Version, and Optimization) and shows that optimization levels are the biggest hurdle for matching. By combining neural embeddings with structural graph filtering, LibDB can distinguish between adjacent library versions and handle the complexities of fused, stripped binaries.
Future work will focus on addressing advanced binary obfuscation techniques and reducing false positives caused by common standard library functions.
Summary updated