[Paper Review] Finding Semantically-Equivalent Binary Code By Synthesizing Adaptors
This paper presents a technique to automatically discover semantically equivalent binary functions by synthesizing adaptors—glue code that bridges interface differences between functions. Using concrete execution and binary symbolic execution, the method efficiently identifies replaceable function pairs in real-world binaries, demonstrating practical applications in security hardening, performance optimization, and deobfuscation, with large-scale evaluation on over 13,000 Linux C library functions confirming the prevalence of adaptably equivalent code.
Independently developed codebases typically contain many segments of code that perform the same or closely related operations (semantic clones). Finding functionally equivalent segments enables applications like replacing a segment by a more efficient or more secure alternative. Such related segments often have different interfaces, so some glue code (an adaptor) is needed to replace one with the other. We present an algorithm that searches for replaceable code segments at the function level by attempting to synthesize an adaptor between them from some family of adaptors; it terminates if it finds no possible adaptor. We implement our technique using (1) concrete adaptor enumeration based on Intel's Pin framework and (2) binary symbolic execution, and explore the relation between size of adaptor search space and total search time. We present examples of applying adaptor synthesis for improving security and efficiency of binary functions, deobfuscating binary functions, and switching between binary implementations of RC4. For large-scale evaluation, we run adaptor synthesis on more than 13,000 function pairs from the Linux C library. Our results confirm that several instances of adaptably equivalent binary functions exist in real-world code, and suggest that these functions can be used to construct cleaner, less buggy, more efficient programs.
Motivation & Objective
- To identify semantically equivalent binary functions that differ only in interface, enabling code replacement for optimization or security hardening.
- To address the challenge of replacing functions with different interfaces by automatically synthesizing adaptors that bridge them.
- To evaluate the feasibility and efficiency of adaptor synthesis in real-world binary codebases, particularly in large-scale systems like the Linux C library.
- To explore the trade-off between adaptor search space size and total search time in binary function equivalence detection.
Proposed method
- The method employs concrete adaptor enumeration using Intel's Pin framework to explore potential interface transformations between binary functions.
- It combines binary symbolic execution to explore control-flow and data-flow paths in binary functions during adaptor synthesis.
- The algorithm searches within a predefined family of adaptors, terminating when no valid adaptor is found, ensuring completeness within the search space.
- The approach supports both functional equivalence checking and practical code replacement by generating correct glue code.
- It models interface mismatches as parameter and return type transformations, enabling systematic exploration of adaptor candidates.
- The framework is evaluated on a large corpus of 13,000 function pairs from the Linux C library to assess scalability and effectiveness.
Experimental results
Research questions
- RQ1Can adaptors be automatically synthesized to bridge interface differences between semantically equivalent binary functions?
- RQ2How does the size of the adaptor search space affect the total time required to find a valid adaptor?
- RQ3What is the prevalence of adaptably equivalent binary functions in real-world codebases like the Linux C library?
- RQ4To what extent can adaptor synthesis improve binary security, performance, and deobfuscation?
- RQ5How effective is the combination of concrete execution and binary symbolic execution in discovering function-level semantic clones?
Key findings
- Over 13,000 function pairs from the Linux C library were analyzed, revealing that several instances of adaptably equivalent binary functions exist in real-world code.
- The method successfully synthesized adaptors for multiple function pairs, enabling replacement of less efficient or less secure implementations with better alternatives.
- The size of the adaptor search space strongly correlates with search time, indicating that search space pruning is critical for scalability.
- Adaptor synthesis enabled practical improvements in binary security and performance, including deobfuscation of obfuscated functions.
- The technique demonstrated feasibility in switching between different binary implementations of RC4, confirming its utility in real-world binary transformation.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.