diff --git "a/2NAyT4oBgHgl3EQfovg1/content/tmp_files/2301.00511v1.pdf.txt" "b/2NAyT4oBgHgl3EQfovg1/content/tmp_files/2301.00511v1.pdf.txt" new file mode 100644--- /dev/null +++ "b/2NAyT4oBgHgl3EQfovg1/content/tmp_files/2301.00511v1.pdf.txt" @@ -0,0 +1,2985 @@ +Asteria-Pro: Enhancing Deep-Learning Based Binary Code Similarity Detection +by Incorporating Domain Knowledge +SHOUGUO YANG, CHAOPENG DONG∗, YANG XIAO†, YIRAN CHENG, ZHIQIANG SHI‡, ZHI +LI, and LIMIN SUN, Institute of Information Engineering, Chinese Academy of Sciences, China and School of +Cyber Security, University of Chinese Academy of Sciences, China +The widespread code reuse allows vulnerabilities to proliferate among a vast variety of firmware. There is an urgent need to detect +these vulnerable code effectively and efficiently. By measuring code similarities, AI-based binary code similarity detection is applied to +detecting vulnerable code at scale. Existing studies have proposed various function features to capture the commonality for similarity +detection. Nevertheless, the significant code syntactic variability induced by the diversity of IoT hardware architectures diminishes the +accuracy of binary code similarity detection. In our earlier study and the tool Asteria, we adopt a Tree-LSTM network to summarize +function semantics as function commonality and the evaluation result indicates an advanced performance. However, it still has utility +concerns due to excessive time costs and inadequate precision while searching for large-scale firmware bugs. +To this end, we propose a novel deep learning enhancement architecture by incorporating domain knowledge-based pre-filtration +and re-ranking modules, and we develop a prototype based on Asteria called Asteria-Pro. Pre-filtration module seeks to eliminates +dissimilar functions to boost subsequent deep learning model calculations, while re-ranking module aims to raises the rankings of +vulnerable functions among candidates generated by deep learning model. Our evaluation indicates that pre-filtration module cuts +the calculation time by 96.9% and re-ranking improves MRR and Recall by 23.71% and 36.4%. By incorporating the pre-filtration and +re-ranking modules, Asteria-Pro outperforms existing state-of-the-art approaches in bug search task, by a significant large margin. +We conduct a large-scale real-world firmware bug search and Asteria-Pro manages to detect 1,482 vulnerable functions with a high +precision 91.65%. +ACM Reference Format: +Shouguo Yang, Chaopeng Dong, Yang Xiao, YIRAN CHENG, Zhiqiang Shi, Zhi Li, and Limin Sun. 2023. Asteria-Pro: Enhancing +Deep-Learning Based Binary Code Similarity Detection by Incorporating Domain Knowledge. 1, 1 (January 2023), 32 pages. https: +//doi.org/10.1145/nnnnnnn.nnnnnnn +1 +INTRODUCTION +Code reuse is very popular in IoT firmware to facilitate its development [62]. Unfortunately, code reuse also introduces +the vulnerabilities concealed in original code to numerous firmware [21]. The security and privacy of our lives +are seriously threatened by the widespread use of these firmware [63]. Even though the vulnerabilities have been +∗ First Author and Second Author contribute equally to this work. +† Corresponding author. +‡ Corresponding author. +Authors’ address: Shouguo Yang, yangshouguo@iie.ac.cn; Chaopeng Dong, dongchaopeng@iie.ac.cn; Yang Xiao, xiaoyang@iie.ac.cn; YIRAN CHENG, +chengyiran@iie.ac.cn; Zhiqiang Shi, shizhiqiang@iie.ac.cn; Zhi Li, lizhi@iie.ac.cn; Limin Sun, sunlimin@iie.ac.cn, Institute of Information Engineering, +Chinese Academy of Sciences, Beijing, China and School of Cyber Security, University of Chinese Academy of Sciences, Beijing, China. +Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not +made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components +of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to +redistribute to lists, requires prior specific permission and/or a fee. Request permissions from permissions@acm.org. +© 2023 Association for Computing Machinery. +Manuscript submitted to ACM +Manuscript submitted to ACM +1 +arXiv:2301.00511v1 [cs.SE] 2 Jan 2023 + +2 +Shouguo Yang, Chaopeng Dong, and Yang Xiao, et al. +publicly disclosed, there are a large number of firmware that still contain them due to delayed code upgrades or code +compatibility issues [17]. Such recurring vulnerabilities, often known as N-day vulnerabilities, cannot be identified by +symbol information such as function name because such symbol information is typically stripped during the firmware +compilation. Besides, the source code of firmware is not available since IoT vendor only provides binary version of +firmware. +To this end, binary code similarity detection (BCSD) is applied to quickly finding homologous vulnerabilities in a large +amount of firmware [22]. The BCSD technique focuses on determining the similarity between two binary code pieces. +As to the vulnerability search, the BCSD focuses on finding other homologous vulnerable functions given a known +vulnerability function. In addition to the vulnerability search, BCSD has been widely used for other security applications +such as code plagiarism detection [15, 47, 56], malware detection [41, 42], and patch analysis [27, 33, 61]. Despite many +existing research efforts, the diversity of IoT hardware architectures and software platforms poses challenges to BCSD +for IoT firmware. There are many different instruction set architectures (ISA) such as ARM, PowerPC, X64, and X86 for +IoT firmware. The instructions are different and the rules, such as the calling convention and the stack layout, also +differ across different ISAs [54]. It is non-trivial to find homologous vulnerable functions across platforms. +BCSD methods can be generally classified into two categories: i) dynamic analysis-based methods and ii) static +analysis-based methods. The methods based on dynamic analysis capture the runtime behavior as function semantic +features by running target functions, where the function features can be I/O pairs of function [54] or system calls during +the program execution [28], etc. They are not scalable for large-scale firmware analysis since running firmware requires +specific devices and emulating firmware is also difficult [19, 34, 70]. The methods based on static analysis mainly +extract function features from assembly code. An intuitive way is to calculate the edit distance between assembly code +sequences [23]. They cannot be directly applied in cross-architecture since instructions are different across architectures. +Architecture-independent statistical features of functions are proposed for the similarity detection [30]. These features +are less affected across architectures such as the number of function calls, strings, and constants. Furthermore, the +control flow graph (CFG) at the assembly code level is utilized by conducting a graph isomorphism comparison for +improving the similarity detection [30, 32]. Based on statistical features and CFG, Gemini [64] leverages the graph +embedding network to encode functions to vectors for similarity detection. With the application of deep learning +models in programming language analysis, various methods have recently appeared to employ such models to encode +binary functions in different forms and calculate function similarity based on function encoding [45, 49, 53, 60]. Static +analysis-based methods are faster and more scalable for large-scale firmware analysis but often produce false positives +due to the lack of semantic information. Since homologous vulnerable functions in different architectures usually share +the same semantics, it is desirable that a cross-architecture BCSD can capture the function semantic information in a +scalable manner. +In our previous work Asteria [68], we first utilize Tree-LSTM network to encode the AST in an effort to fit its semantic +representation. In particular, Tree-LSTM is trained using a siamese [37] architecture to understand the semantic +representation by feeding homologous and non-homologous function pairs into Tree-LSTM network. As a result, +the Tree-LSTM network learns function semantic representations to distinguish homologous and non-homologous +functions. To further improve the accuracy, we also use the call graph to calibrate the AST similarity. Specifically, +we count callee functions of target functions in call graph to measure the function call difference. Final function +similarity is determined by calibrating AST similarity with the function call difference. In our previous evaluation, +Asteria outperforms the available state-of-the-art methods, Gemini and Diaphora in terms of accuracy. The evaluation +results demonstrate the superiority of function semantic extraction by encoding AST with Tree-LSTM model for BCSD. +Manuscript submitted to ACM + +Asteria-Pro +3 +However, encoding AST incurs a clear temporal cost in Asteria. According to our earlier research [68], the entire AST +encoding process takes about one second. When Asteria is applied to vulnerability detection, where, given a vulnerable +function, there are massive functions to do a similarity calculation, the time cost is unacceptable. As the majority +of candidate functions are non-homologous, there is space for Asteria’s efficiency to be enhanced. In other words, +non-homologous candidate functions differ from vulnerable functions in some characteristics that we can exploit to +skip most non-homologous functions more efficiently. In addition, vulnerability detection-like evaluation is absent +from the majority of efforts [53, 64, 65], including our prior study Asteria. It is necessary to evaluate the performance of +Asteria on the vulnerability search task. Moreover, according to the result in the real world vulnerability detection [68], +Asteria suffers from high false positives, which affects its effectiveness in reality. +There are two main challenges that hinder Asteria from being practical for large-scale vulnerability detection: +• Challenge 1 (C1). It’s challenging to filter out the majority of non-homologous functions before encoding ASTs, +while retaining the homologous ones, to speed up the vulnerability-detection process. +• Challenge 2 (C2). It’s challenging to distinguish similar but non-homologous functions. Despite Asteria’s high +precision on homologous and non-homologous classification, it still yields false positives when distinguishing +functions with similar ASTs. +We design Asteria-Pro by introducing domain knowledge with two answers A1 and A2 to overcome these two +challenges. Our fundamental concept is that introducing inter-functional domain knowledge will helps Asteria-Pro +achieve greater precision combined the intra-functional semantic knowledge deep learning model learned. Asteria- +Pro consists of three module: 1) domain knowledge-based (DK-based) pre-filtration, 2) deep learning-based (DL-based) +similarity detection, and 3) DK-based re-ranking, among them DL-based similarity detection is basically based on Asteria. +Domain knowledge is fully exploited for different purpose in DK-based pre-filtration and re-ranking. In pre-filtration +module, Asteria-Pro aims to skip as many as possible non-homologous function by comparing lightweight robust +features (A1). Meanwhile, the filtration is required to retain all homologous functions. To this end, we conduct a +preliminary study into the filtering efficacy of several lightweight function features. According findings of the study, we +propose a novel algorithm that successfully employ three distinct function features in the filter. In re-ranking module, +Asteria-Pro confirms the homology of functions by comparing call relationships (A2), based on the assumption that +functions designed for distinct purposes have different call relationships. +Our evaluation indicates that Asteria-Pro significantly outperforms existing state-of-the-art methods in terms of +both accuracy and efficiency. Compared with Asteria, Asteria-Pro successfully cuts the detection time of Asteria- +ProAsteria by 96.90% by incorporating DK-based pre-filtration module,. By incorporating DK-based re-ranking, +Asteria-Pro manages to enhance the MRR and Recall@Top-1 by 23.71% and 36.4%, to 90.8% and 89.6%, respectively. +Asteria-Pro identifies 1,482 vulnerable functions with a high precision of 91.65% by conducting a large-scale real- +world firmware vulnerability detection utilizing 90 CVEs. Moreover, the detection results of CVE-2017-13001 demonstrate +that Asteria-Pro has an advanced capacity to detect inlined vulnerable code. +Our contributions are summarized as follows: +• We conduct a preliminary study to demonstrate the effectiveness of various simple function features in identifying +non-homologous functions. +• To the best of our knowledge, it is the first work to propose incorporating domain knowledge before and after +deep learning models for vulnerability detection optimization. We implement the domain knowledge-based +pre-filtration and re-ranking algorithms, and equip them on our previous work. +Manuscript submitted to ACM + +4 +Shouguo Yang, Chaopeng Dong, and Yang Xiao, et al. +• The evaluation indicates the pre-filtration significantly reduces the detection time and re-ranking improves the +detection precision by a fairly amount. The Asteria-Pro outperforms existing state-of-the-art methods in +terms of both accuracy and efficiency. In evaluation 8.5, we find that the performance of distinct BCSD method +may vary widely in different usage scenarios. +• We demonstrate the utility of Asteria-Pro by conduct a large-scale real-world firmware vulnerability detection. +Asteria-Pro manages to find 1,482 vulnerable functions with a high precision of 91.65%. We analyze the +vulnerability distribution in widely-used software of various IoT vendors to illustrates inspiring findings. +2 +BACKGROUND +We first briefly describe the AST structure adopted in this work, followed by demonstration of the AST holding more +stable structure than CFG across architectures. Then we introduce the Tree-LSTM model utilized in AST encoding. +Finally, the broad problem definition for the application of BCSD to bug search is given. +2.1 +Abstract Syntax Tree +Table 1. Statements and Expressions in ASTs. We count the statements and expressions for nodes in ASTs after the decompilation by +IDA Pro and list the common statements and expressions. This table can be extended if new statements or expressions are introduced. +Node Type +Label +Note +Statement +if +1 +if statement +block +2 +instructions executed sequentially +for +3 +for loop statement +while +4 +while loop statement +switch +5 +switch statement +return +6 +return statement +goto +7 +unconditional jump +continue +8 +continue statement in a loop +break +9 +break statement in a loop +Expression +asgs +10∼17 +assignments, including assignment, assignment after or, xor, and, add, sub, mul, +div +cmps +18∼23 +comparisons including equal, not equal, greater than, less than, greater than or +equal to, and less than or equal to. +ariths +24∼34 +arithmetic operations including or, xor, addition, subtraction, multiplication, +division, not, post-increase, post-decrease, pre-increase, and pre-decrease +other +34∼43 +others including indexing, variable, number, function call, string, asm, and so +on. +block +if +le +block +block +var num +asg +asg +var num var var +return +call +num +void +histsizesetfn(UNUSED(p), long v) +{ + if (v< 1) +histsiz = 1; + else + histsiz = v; + resizehistents(); +} +block +if +le +block +block +var num +asg +asg +var num var var +return +call +num +ROOT +2 +7 +35 +36 +1 +12 +2 +35 +35 +7 +35 +21 +35 +35 +6 +20 +35 +35 +AST Converting +Fig. 1. Source code of function histsizesetfn and the corresponding decompiled AST of x86 architecture. +Manuscript submitted to ACM + +Asteria-Pro +5 +2.1.1 +AST Description. An AST is a tree representation of the abstract syntactic structure of code in the compilation +and decompilation process. Different subtrees in an AST correspond to different code scopes in the source code. Figure +1 shows a decompiled AST corresponding to the source code of function histsizesetfn in zsh v5.6.2 in the left. +The zsh is a popular shell software designed for interactive use, and the function histsizesetfn sets the value of +a parameter. The lines connecting the source code and AST in Figure 1 show that a node in the AST corresponds +to an expression or a statement in the source code. A variable or a constant value is represented by a leaf node in +AST. We group nodes in an AST into two categories: i) statement nodes and ii) expression nodes according to their +functionalities shown in Table 1. Statement nodes control the function execution flow while expression nodes perform +various calculations. Statement nodes include if, for, while, return, break and so on. Expression nodes include common +arithmetic operations and bit operations. +block +if +le +block +block +var num +asg +asg +var num var var +return +call +num +void +histsizesetfn(UNUSED(p), long v) +{ + if (v< 1) +histsiz = 1; + else + histsiz = v; + resizehistents(); +} +block +if +gt +block +block +var num +asg +asg +var var var num +return +call +num +(a) AST for x86 platform +(b) AST for ARM platform +sub +esp, 0ch +mov +eax, [esp+0ch+arg_4] +test +eax, eax +jle +short loc_809F187 +mov +ds:histsiz, eax +loc_809F187: +mov +ds:histsiz, 1 +jmp +short loc_809F17E +loc_809F17E: +call +resizehistents +add +esp, 0ch +retn +LDR +R3, =histsiz +CMP +R1, #0 +MOVLER2, #1 +STRGT R1, [R3] +STRLE R2, [R3] +B +resizehistents +sub +esp, 0ch +mov +eax, [esp+0ch+arg_4] +test +eax, eax +jle +short loc_809F187 +mov +ds:histsiz, eax +loc_809F187: +mov +ds:histsiz, 1 +jmp +short loc_809F17E +loc_809F17E: +call +resizehistents +add +esp, 0ch +retn +LDR +R3, =histsiz +CMP +R1, #0 +MOVLER2, #1 +STRGT R1, [R3] +STRLE R2, [R3] +B +resizehistents +(c) CFG for x86 platform +(d) CFG for ARM platform +Fig. 2. ASTs and CFGs of the function histsizesetfn under different architectures. +2.1.2 +AST Structure Superiority. Both CFG and AST are structural representations of a function. The CFG of a function +contains the jump relationships between basic blocks that contain straight-line code sequences [38]. Though CFG has +been used for similarity measurement in BCSD [30], David et al. [23] demonstrated that CFG structures are greatly +affected by different architectures. We find AST shows better architectural stability across architectures compared with +CFG since the AST is generated from the machine independent intermediate representations which are disassembled +from assemble instructions during the decompilation process [20]. Figure 2 shows the changes of ASTs and CFGs in +x86 and ARM architectures, respectively. For the CFGs from x86 to ARM, we observe that the number of basic blocks +changes from 4 to 1, and the number of assembly instructions has changed a lot. However, the ASTs, based on higher +level intermediate representation, slightly change from x86 to ARM, where the changes are highlighted with blue +boxes. Besides, AST preserves the semantics of functionality and is thus an ideal structure for cross-platform similarity +detection. +2.2 +Tree-LSTM Model +In natural language processing, Recursive Neural Networks (RNN) are widely applied and perform better than Convo- +lutional Neural Networks [69]. RNNs take sequences of arbitrary lengths as inputs considering that a sentence can +Manuscript submitted to ACM + +6 +Shouguo Yang, Chaopeng Dong, and Yang Xiao, et al. +consist of any number of words. However, standard RNNs are not capable of handling long-term dependencies due to +the gradient vanishing and gradient exploding problems. As one of the variants of RNN, Long Short-Term Memory +(LSTM) [39] has been proposed to solve such problems. LSTM introduces a gate mechanism including the input, forget, +and output gates. The gates control the information transfer to avoid the gradient vanishing and exploding (calculation +details in Section § 6.1). Nevertheless, LSTM can only process sequence input but not structured input. Tree-LSTM is +proposed to process tree-structured inputs [58]. The calculation by Tree-LSTM model is from the bottom up. For each +non-leaf node in the tree, all information from child nodes is gathered and used for the calculation of the current node. +In sentiment classification and semantic relatedness tasks, Tree-LSTM performs better than a plain LSTM structure +network. There are two types of Tree-LSTM proposed in the work [59]: Child-Sum Tree-LSTM and Binary Tree-LSTM. +Researchers have shown that Binary Tree-LSTM performs better than Child-Sum Tree-LSTM [59]. Since the Child-Sum +Tree-LSTM does not take into account the order of child nodes, while the order of statements in AST reflects the +function semantics, we use the Binary Tree-LSTM for our AST encoding. +3 +PRELIMINARY STUDY +This study aims to assess and uncover accessible function features that are effective at identifying non-homologous +functions to guide our pre-filtration construction. To evaluate the features, we prepare the code base and incorporate a +number of metrics (§ 3.1). To uncover appropriate features, we evaluate and compare popular conventional features +found in existing remarkable works (§ 3.2). +3.1 +Evaluation Benchmark +3.1.1 +Dataset. To derive robust features, we compile a large collection of binaries from 184 open source software +(OSS), including widely used OpenSSL, FFmpeg, Binutils, etc. Since our tool aims to conduct similarity detection across +different architectures, we compile these OSS to 4 distinct architectures, X86, X64, ARM, and PowerPC. In addition, +we align the default compilation settings during compilation with real-world usage. After compilation, numerous test +binaries with "test" or "buildtest" as a prefix or suffix are generated to test the software’s functionality. These test +binaries are removed from the collection because 1) their functions are simple and comprise only a few lines of code. 2) +do not participate in the real execution of software function. After removal, the binary collection retains 1,130 binaries, +or 226 for each architecture. +We construct a large dataset containing pairs of homologous and non-homologous functions. To this end, function +names are retained by software after its compilation. In order to construct homologous function pairs, we utilize binary +functions with the same function name in the same software. Otherwise, they form non-homologous functions. For +instance, if function 𝐹 is present in the source code, compilation will generate 4 versions of binary functions for distinct +instruction set architectures: 𝐹𝑥86, 𝐹𝑥64, 𝐹𝑎𝑟𝑚, and 𝐹𝑝𝑝𝑐, respectively. These variants of functions are homologous +functions for one another. We extract 132,274 unique binary functions each architecture, for a grand total of 529,096 +binary functions. We select at random 40,111 functions from each architecture, totaling 160,444 functions. Among +these, we randomly select 1000 functions as source functions and use them to perform filtering operations on all +functions. In specifically, source functions are used to evaluate the capability of the target feature to filter away +non-homologous functions while preserving homologous ones from the 40,111 functions that have been selected. We +prepare the homologous function pairs and groups for feature evaluations. Specifically, we utilize the source function +name 𝐹 together with the library name 𝐵, since function names in different binaries might be duplicated but having +different functionalities, to combine into a function identifier 𝐹𝐵. After compilation, we will get different homologous +Manuscript submitted to ACM + +Asteria-Pro +7 +binary functions 𝐹𝐵 +𝑋86, 𝐹𝐵 +𝑋64, 𝐹𝐵 +𝐴𝑅𝑀, and 𝐹𝐵 +𝑃𝑃𝐶 for different architectures, X86, X64, ARM, and PowerPC. These four +binary versions of function form a homologous function groups. We pick a random version of function to combine with +other 3 versions of functions to form 3 homologous function pairs. We calculate different metrics for function pairs and +groups respectively. +3.1.2 +Metrics. True positive rate (TPR) and false positive rate (FPR) are utilized to evaluate the filtering capability of +various features. TPR demonstrates the feature’s capacity to retain homologous functions, while FPR demonstrates its +capacity to exclude non-homologous functions. In the subsequent filtering phase, our goal is to identify features that +can filter out non-homologous functions as effectively as possible (low FPR) while maintaining all homologous functions +(very high TPR). +We employ 𝑛 source functions to evaluate the filtering capability of diverse features. For each source function 𝐹𝐵 +𝑋 , we +construct a candidate function pool of 𝑀 randomly selected binary functions, containing three homologous functions +of 𝐹𝐵 +𝑋 . Consequently, source function 𝐹𝐵 +𝑋 is used to form 3 homologous pairs and 𝑀 × 4 − 4 non-homologous pairs. The +function pair scores are calculated based on distinct feature and scores below a threshold value 𝑇 are omitted. In the +remaining function pairs, the homologous function pair is regarded as a true positive 𝑇𝑃 while the non-homologous +function pair is regarded as a false positive 𝐹𝑃. The following equations illustrate how we calculate these three metrics +for various features: +𝑇𝑃𝑅 = +�𝑛 +𝑖=1𝑇𝑃𝑝 +𝑖 +3 × 𝑛 +(1) +𝐹𝑃𝑅 = +�𝑛 +𝑖=1 𝐹𝑃𝑖 +𝑛 × (𝑀 × 4 − 4) +(2) +(3) +3.2 +Candidate Features Evaluation +We intend to identify the most efficient and effective filter features by evaluating features proposed in existing studies. +On the basis of the evaluation results, we utilize and improve the candidate features for the filter needs. +3.2.1 +Feature Selection. We collect basic features from prior research [30, 64, 65, 68] and divide them into two categories: +CFG-family feature and AST-family feature. CFG-family features include 5 types of numeric features: the number of +instructions, arithmetic instructions, call instructions, logical instructions, transfer instructions, and 2 constant features: +string constants and numeric constants [30]. Since AST must be prepared for model encoding calculation (§ 6), we +therefore summarize three syntactic characteristics as AST-family characteristics. +• No. AST Nodes. The number of AST nodes. +• AST node Cluster. The number of different node types in AST. For example, in Figure 1, the AST node Cluster is +denoted as [𝑏𝑙𝑜𝑐𝑘 : 3,𝑖𝑓 : 1,𝑟𝑒𝑡𝑢𝑟𝑛 : 1,𝑐𝑎𝑙𝑙 : 1,𝑛𝑢𝑚 : 3,𝑏𝑙𝑜𝑐𝑘 : 2,𝑎𝑠𝑔 : 2, 𝑣𝑎𝑟 : 4,𝑙𝑒 : 1] +• AST Fuzzy Hash. We first generate node sequence by traversing the AST preorder. Then we apply the fuzzy hash +algorithm [44] to generate the fuzzy hash of AST. +3.2.2 +Feature Similarity in Filtration. The format of features divides them into two types with distinct similarity +calculations: value type and sequence type. Value type features consist of No. Instruction, No. Arithmetic, No. Logic, +No. Callee, and No. AST nodes. Sequence type features consist of Numeric Constant, String Constant, AST Node Cluster, +and AST Seq Hash. For value type features, we use the relative difference ratio (𝑅𝐷𝑅) as shown below for similarity +Manuscript submitted to ACM + +8 +Shouguo Yang, Chaopeng Dong, and Yang Xiao, et al. +calculation: +𝑅𝐷𝑅(𝑉1,𝑉2) = 1 − 𝑎𝑏𝑠(𝑉1 − 𝑉2) +𝑚𝑎𝑥(𝑉1,𝑉2) +(4) +where 𝑉1,𝑉2 are feature values. For each sequence-type feature, we first sort the feature’s items and then concatenate +them into a single sequence. Then, we employ the common sequence ratio (CSR) based on the longest common sequence +(LCS) as follows: +𝐶𝑆𝑅(𝑆1,𝑆2) = 2 × 𝐿𝐶𝑆(𝑆1,𝑆2) +𝑙𝑒𝑛(𝑆1) + 𝑙𝑒𝑛(𝑆2) +(5) +where 𝑆1,𝑆2 are feature sequences, and function 𝐿𝐶𝑆(·, ·) returns the length of the longest common sequence between +𝑆1,𝑆2. The above two equations are used for similarity calculation of various features. +0.0 +0.2 +0.4 +0.6 +0.8 +1.0 +FPR +0.0 +0.2 +0.4 +0.6 +0.8 +1.0 +TPR +AST Node Cluster(auc=0.978) +No. AST Nodes(auc=0.956) +No. callee(auc=0.944) +Numeric Constant(auc=0.940) +AST Seq Fuzzy Hash(auc=0.932) +No. Instructions(auc=0.862) +String Constant(auc=0.773) +No. Logic(auc=0.687) +No. Arithmetic(auc=0.521) +0.0 +0.2 +0.4 +0.6 +0.8 +1.0 +Similarity Threshold +0.0 +0.2 +0.4 +0.6 +0.8 +1.0 +F-score +No. callee +AST Node Cluster +AST Seq Fuzzy Hash +No. AST Nodes +Numeric Constant +No. Instructions +String Constant +No. Logic +No. Arithmetic +0 +50 +100 +150 +200 +250 +300 +350 +No. Callee +No. AST Nodes +AST Node Cluster +AST Seq Fuzzy Hash +No. Instructions +No. Arithmetic +No. Logic +String Constant +Numeric Constant +Time/10−7s +Fig. 3. ROC Curves for Traditional Features. +Fig. 4. 𝐹𝑠𝑐𝑜𝑟𝑒 of Traditional Features. +Fig. 5. Time Costs of Similarity Calculation +for Different Features. +3.2.3 +Evaluation Results. In the evaluation, the values for 𝑛 and 𝑀 in § 3.1.2 are set to 1000 and 20, 000, respectively. As +depicted in Figure 3, TPRs and FPRs calculated for each feature under various thresholds are presented as a receiver +operating characteristic (ROC) [71] curve. Additionally, We compute the area under ROC curve (AUC), which reflects +the feature’s ability to distinguish between homologous and non-homologous functions. The AUC values of the features +extracted from AST (i.e., No. AST Nodes, AST Node Cluster, and AST Seq Fuzzy Hash) are high, as presented in the image. +However, when the TPR is high, they generate a big FPR. Figure 5 depicts the time costs associated with similarity +calculations for various features. Clearly, sequence type features require more time than value type features. Nonetheless, +their time consumption falls within an acceptable range of magnitudes. At least 105 exact calculations can be completed +every second. +We observe in Figure 3 that at high TPR (0.996), the No. Callee feature produces relatively lower FPR (0.111). Recalling +the objective of the filtering phase, we aim to select features with a low FPR at a very high TPR. Features with high +AUC do not necessarily meet the our objective. For example, the feature AST Node Cluster has a higher FPR (0.47) than +feature No. Callee (FPR = 0.111) under the same TPR (0.996), even feature AST Node Cluster has higher AUC (0.978) than +feature No. Callee (AUC = 0.944). In this regard, we propose a new metric 𝐹𝑠𝑐𝑜𝑟𝑒, which indicating high TPR and FPR. +𝐹𝑠𝑐𝑜𝑟𝑒 = +1 +1 +𝑇𝑃𝑅 + 𝐹𝑃𝑅 +(6) +For each feature, we calculate the 𝐹𝑠𝑐𝑜𝑟𝑒 and plot the 𝐹𝑠𝑐𝑜𝑟𝑒 curves in Figure 4. The Figure 4 plots 𝐹𝑠𝑐𝑜𝑟𝑒 curves of +various features at various similarity thresholds. We can see that the No. callee has the best 𝐹𝑠𝑐𝑜𝑟𝑒 (0.90) at threshold +Manuscript submitted to ACM + +Asteria-Pro +9 +0.94. In this case, we summary the development challenges of No. callee and the improvement in § 5 by conducting +manually analysis. +Prefiltration +Feature Extraction +Filtering +AST +Extraction +Target +Function +Candidate +Functions +Target +Function +Remainder +Functions +Candidate +Homologous +Functions +Similarity Calculation +TreeLSTM Encoding +Siamese Calculation +Homology +Confirmation +Re-ranking +Input + DK-based Prefiltration +§ + DL-based Similarity Calculation +§ +Homologous +Functions + DK-based Re-ranking +§ +Output +Fig. 6. Workflow of Asteria-Pro. DK stands for Domain Knowledge. DL stands for Deep Learning. +4 +METHODOLOGY OVERVIEW +Asteria-Pro consists of three primary modules, DK-based Prefiltration, DL-based Similarity Calculation, and +DK-based Re-ranking as shown in Figure 6, where DK stands for Domain Knowledge, and DL stands short for Deep +Learning. DK-based prefiltration module utilizes syntactic features to filter out dissimilar functions from candidate +functions in a lightweight and efficient manner (see § 5). DL-based similarity calculation module encodes ASTs into +representation vectors using the Tree-LSTM model, and determines similarity score between target function and +remainder functions using a Siamese network (see § 6). DK-based re-ranking module reorders candidate homologous +functions in the above module using lightweight structural features (i.e., function call relationship). Asteria-Pro can +ultimately detect homologous functions across architectures efficiently and effectively. +5 +DK-BASED PREFILTRATION +At this stage, Asteria-Pro intends to incorporate an efficient and effective filter. Callee functions, which are useful in +eliminating non-homologous functions demonstrated in preliminary study, are applied extensively for this purpose. We +present a variant of the callee function as well as a novel algorithm for constructing the filter. +5.1 +Callee Exploitation Challenges +Note that the No. of callee only counts the number of callee functions but omits crucial information such as function +names. Observing that a portion of callee function names are retained after binary stripping suggests that callee +relationship has potential for additional exploration. To fully exploit the callee relationship, we manually analyze the +incorrect detection cases of No. of callee evaluations in § 3.2 and summarize the challenges to properly exploiting it: +• Exploitation Challenge 1 (EC1). Removed or decorated callee function name. For safety and size reasons, the +binary usually is stripped after compilation. The call functions whose names are removed after strip from symbol +table, can not provide assistance in a straightforward manner. In addition, there are several ways to decorate +function names by compiler [9]. The function name will differ from its original name in the source code after +decoration. +• Exploitation Challenge 2 (EC2). There is no callee functions in some functions (i.e., leaf node in call graph). +• Exploitation Challenge 3 (EC3). Function calls in binary target functions might not always be consistent with +source code. Function calls may be added or deleted due to compiler optimization. The reasons for the function call +change are function inline, intrinsic function replacement, instruction replacement for optimization, that behave +differently in different architectures. We describe this challenge in detail in Function Call Optimization. +Manuscript submitted to ACM + +10 +Shouguo Yang, Chaopeng Dong, and Yang Xiao, et al. +To overcome exploitation challenges, we design a new feature genealogist derived from callee relationship. The +novel algorithm UpRelation is proposed to exploit the new feature. +5.2 +Filter Feature Design +Our new feature intends to extract comprehensive information from the call relationship of software binary, including +the symbol information. Such call relationship can be presented by call graph. The call graph 𝐶𝐺 can be defined by giving +all functions as nodes and the call relationships between functions as edges:𝐶𝐺 = (V, E), where V = {𝑣|𝑣 is a function} +denotes the node collection and E = {(𝑢, 𝑣)|𝑢 calls 𝑣} denotes the edge collection. For edge (𝑢, 𝑣) ∈ 𝐸, we say that +function 𝑣 is a callee function of function ����. The genealogist is a function list containing partial callee functions of the +target function. Considering EC1, we can not utilize all symbol information of callee functions, since callee functions +might be in removable symbol table (i.e., static symbol table), and the function name will removed. Fortunately, to +link against dynamic libraries, function names in the dynamic symbol table 𝐷𝑆𝑇 (i.e., import and export table) will +be preserved [36]. For example, if target function calls external function ‘strcpy’, the callee function name ‘strcpy’ +remains in import table rather than removed after binary strip. We define genealogist 𝐺𝐿 of target function 𝑓 as: +𝐺𝐿𝑓 = {𝑣|𝑣 ∈ V, (𝑓 , 𝑣) ∈ E, 𝑣 ∈ 𝐷𝑆𝑇 }. +For cases where a function calls the same function multiple times, we keep multiple identical function names. +5.3 +Filtration algorithm +To support our new feature, we propose a feature similarity algorithm, called UpRelation. The algorithm utilizes +context information in the call graph to overcome challenge EC2, EC3. Specifically, the algorithm utilizes parent nodes +of leaf nodes in call graph to match leaf nodes to address the EC2. In the algorithm, we adopt a drill down strategy, that +combines three feature 𝐺𝐿, No. Callee, and String Constants according to their information content, considering the +fairly robust performance of No. Callee and String Constants in preliminary evaluation. The No. Callee of function 𝑓 is +denoted by 𝐶𝑎𝑙𝑙𝑒𝑒𝑓 and the String Constant set of function 𝑓 is denoted by 𝑆𝑡𝑟𝐶𝑜𝑛𝑠𝑓 . +Given a vulnerable function 𝑓𝑣, Algorithm 1 aims to omit the most of non-homologous functions, with retaining +vulnerable candidate function to a list (𝑉 𝐹𝐿) from target function list 𝑇𝐹𝐿. Code from line 2 to line 6 performs filtering +when feature genealogist 𝐺𝐿𝑓 𝑣 of 𝑓𝑣 is not empty. Specifically, the algorithm calculates the 𝐶𝑆𝑅 between 𝐺𝐿𝑓 𝑣 and +𝐺𝐿𝑓 of all candidate functions in line 4. Then it filters out functions whose 𝐶𝑆𝑅 is less than a threshold 𝑇𝐺𝐿. Similarly, +when callee number 𝐶𝑎𝑙𝑙𝑒𝑒𝑓 𝑣 of 𝑓 𝑣 is not 0, it filters out functions by calculating 𝑅𝐷𝑅 score from line 7 to line 11. +Line 12 to 19 makes up the most crucial portion of the algorithm, which matches the leaf functions to address EC2. +All caller functions of 𝑓 𝑣 are first visited in this section of the algorithm at line 14. It employs 𝑈𝑝𝑅𝑒𝑙𝑎𝑡𝑖𝑜𝑛 to discover +all functions that are similar to caller function, 𝑓 𝑝. For each similar function 𝑓 𝑝′, the algorithm regards all its callee +functions as vulnerable candidate functions at line 16. We find the same leaf functions by locating the same caller +functions because the caller functions of the same leaf functions are also the same. However, this introduces some +extraneous (leaf) functions, that share the same caller function but are not the same as the leaf function. We utilize +string similarity at line 22, to remove extraneous functions. After filtering by callees and strings, the algorithm finally +gets the expected vulnerable candidate function list 𝑉 𝐹𝐿. +6 +DL-BASED SIMILARITY CALCULATION +This module calculates the similarity between two function ASTs by encoding them into vectors and applying the +Siamese architecture to calculate similarity between encoded vectors. Figure 7 depicts the calculation flow. +Manuscript submitted to ACM + +Asteria-Pro +11 +Algorithm 1: UpRelation +Input: Vulnerable Function 𝑓 𝑣, Target Function List 𝑇𝐹𝐿, Thresholds 𝑇𝐺𝐿,𝑇𝑐𝑎𝑙𝑙𝑒𝑒,𝑇𝑠𝑡𝑟𝑖𝑛𝑔 +Output: Vulnerable Candidate Function List 𝑉 𝐹𝐿 +1 𝑉 𝐹𝐿 ← 𝑇𝐹𝐿; +2 if 𝐺𝐿𝑓 𝑣 is not null then +3 +for 𝑓 ∈ 𝑇𝐹𝐿 do +4 +𝑠 = CSR(𝐺𝐿𝑓 𝑣, 𝐺𝐿𝑓 ); +5 +if 𝑠 < 𝑇𝐺𝐿 then 𝑉 𝐹𝐿.pop(𝑓 ); +6 +end +7 else if 𝐶𝑎𝑙𝑙𝑒𝑒𝑓 𝑣 > 0 then +8 +for 𝑓 ∈ 𝑇𝐹𝐿 do +9 +𝑠 = RDR(𝐶𝑎𝑙𝑙𝑒𝑒𝑓 𝑣, 𝐶𝑎𝑙𝑙𝑒𝑒𝑓 ); +10 +if 𝑠 < 𝑇𝑐𝑎𝑙𝑙𝑒𝑒 then 𝑉 𝐹𝐿.pop(𝑓 ); +11 +end +12 else +13 +𝐹𝐿′ = ∅; +14 +for 𝑓 𝑝 ∈ GetCallers(fv) do +15 +for 𝑓 𝑝′ ∈ 𝑈𝑝𝑅𝑒𝑙𝑎𝑡𝑖𝑜𝑛(𝑓 𝑝,𝑉 𝐹𝐿) do +16 +𝐹𝐿′.add(GetCallees(𝑓 𝑝′)); +17 +end +18 +end +19 +𝑉 𝐹𝐿 = 𝐹𝐿′; +20 if 𝑆𝑡𝑟𝐶𝑜𝑛𝑠𝑓 𝑣 is not null then +21 +for 𝑓 ∈ 𝑉 𝐹𝐿 do +22 +𝑠 = CSR(𝑆𝑡𝑟𝐶𝑜𝑛𝑠𝑓 𝑣, 𝑆𝑡𝑟𝐶𝑜𝑛𝑠𝑓 ); +23 +if 𝑠 < 𝑇𝑠𝑡𝑟𝑖𝑛𝑔 then 𝑉 𝐹𝐿.pop(𝑓 ); +24 +end +25 else +26 +return +27 end +28 𝑉 𝐹𝐿; +𝑻𝒓𝒆𝒆-𝑳𝑺𝑻𝑴 +𝑻𝒓𝒆𝒆-𝑳𝑺𝑻𝑴 +𝒄𝒂𝒕 +𝒔𝒐𝒇𝒕𝒎𝒂𝒙 +AST Similarity +| − | +𝒗𝒂𝒍𝒖���𝟏 +𝒗𝒂𝒍𝒖𝒆𝟐 +𝑒! +𝑒" +𝑒# +𝑐&' +𝑐&( +ℎ&' +ℎ&( +𝑐& +ℎ& +𝒉𝒓𝒐𝒐𝒕 +Encoding Vector +Similarity Calculation +AST Encoding +Node Encoding +ℎ!" +ℎ!# +𝑐!" +𝑐!# +𝑒! +u! +𝑖! +𝑐! +ℎ! +𝑜! +𝑒! +𝑓+, +𝑓+- +U" U# +X +X +∑ +X ++ ++ ++ ++ ++ +𝜎 +𝜎 +𝜎 +𝑡𝑎𝑛ℎ +𝑡𝑎𝑛ℎ +𝜎 +𝜎 +Siamese Network +⨀ +Fig. 7. The Siamese Architecture and Tree-LSTM Encoding. +Manuscript submitted to ACM + +12 +Shouguo Yang, Chaopeng Dong, and Yang Xiao, et al. +6.1 +Tree-LSTM Encoding +Given an AST, Tree-LSTM model encodes it into a representation vector. Tree-LSTM model is firstly proposed to encode +the tree representation of a sentence and summarize the semantic information in natural language processing. Tree- +LSTM model can preserve every property of the plain LSTM gating mechanisms while processing tree-structured inputs. +The main difference between the plain LSTM and the Tree-LSTM is the way to deal with the outputs of predecessors. +The plain LSTM utilizes the output of only one predecessor in the sequence input. We utilize Tree-LSTM to integrate +the outputs of all child nodes in the AST for calculation of the current node. To facilitate the depiction of the Tree-LSTM +encoding, we assume that node 𝑣𝑘 has two child nodes 𝑣𝑙 and 𝑣𝑟 . The Tree-LSTM encoding of node 𝑣𝑘 takes three types +of inputs: node embedding 𝑒𝑘 of 𝑣𝑘, hidden states ℎ𝑘𝑙 and ℎ𝑘𝑟 , and cell states 𝑐𝑘𝑙 and 𝑐𝑘𝑟 as illustrated in Figure 7. The +node embedding 𝑒𝑘 is generated by using the pre-trained model CodeT5 to embed the node 𝑣𝑘 to a high-dimensional +representation vector. ℎ𝑘𝑙, ℎ𝑘𝑟 , 𝑐𝑘𝑙, and 𝑐𝑘𝑟 are outputs from the encoding of child nodes. During the node encoding in +Tree-LSTM, there are three gates and three states which are important in the calculation. The three gates are calculated +for filtering information to avoid gradient explosion and gradient vanishing [58]. They are input, output, and forget +gates. There are two forget gates 𝑓𝑘𝑙 and 𝑓𝑘𝑟, filtering the cell states from the left child node and right child node +separately. As shown in Node Encoding in Figure 7, the forget gates are calculated by combining ℎ𝑘𝑙, ℎ𝑘𝑟, and 𝑒𝑘. +Similar to the forget gates, the input gate, and the output gate are also calculated by combining ℎ𝑘𝑙, ℎ𝑘𝑟, and 𝑒𝑘. The +details of the three types of gates are as follows: +𝑓𝑘𝑙 = 𝜎(𝑊 𝑓 𝑒𝑘 + (𝑈 𝑓 +𝑙𝑙 ℎ𝑘𝑙 + 𝑈 𝑓 +𝑙𝑟ℎ𝑘𝑟) + 𝑏𝑓 ) +(7) +𝑓𝑘𝑟 = 𝜎(𝑊 𝑓 𝑒𝑘 + (𝑈 𝑓 +𝑟𝑙ℎ𝑘𝑙 + 𝑈 𝑓 +𝑟𝑟ℎ𝑘𝑟) + 𝑏𝑓 ) +(8) +𝑖𝑘 = 𝜎(𝑊 𝑖𝑒𝑘 + (𝑈 𝑖 +𝑙 ℎ𝑘𝑙 + 𝑈 𝑖 +𝑟ℎ𝑘𝑟) + 𝑏𝑖) +(9) +𝑜𝑘 = 𝜎(𝑊 𝑜𝑒𝑘 + (𝑈 𝑜 +𝑙 ℎ𝑘𝑙 + 𝑈 𝑜 +𝑟 ℎ𝑘𝑟) + 𝑏𝑜) +(10) +where 𝑖𝑘 and 𝑜𝑘 denote the input gate and the output gate respectively, and the symbol 𝜎 denotes the sigmoid activation +function. The weight matrix𝑊 ,𝑈 , and bias 𝑏 are different corresponding to different gates. After the gates are calculated, +there are three states 𝑢𝑘, 𝑐𝑘, and ℎ𝑘 in Tree-LSTM to store the intermediate encodings calculated based on inputs ℎ𝑘𝑙, +ℎ𝑘𝑟, and 𝑒𝑘. The cached state 𝑢𝑘 combines the information from the node embedding 𝑒𝑘 and the hidden states ℎ𝑘𝑙 +and ℎ𝑘𝑟 (Equation 11). And note that 𝑢𝑘 utilizes tanh as the activation function rather than 𝑠𝑖𝑔𝑚𝑜𝑖𝑑 for holding more +information from the inputs. The cell state 𝑐𝑘 combines the information from the cached state 𝑢𝑘 and the cell states 𝑐𝑘𝑙 +and 𝑐𝑘𝑟 filtered by forget gates (Equation 12). The hidden state ℎ𝑘 is calculated by combining the information from cell +state 𝑐𝑘 and the output gate 𝑜𝑘 (Equation 13). The three states are computed as follows: +𝑢𝑘 = 𝑡𝑎𝑛ℎ(𝑊 𝑢𝑒𝑘 + (𝑈𝑢 +𝑙 ℎ𝑘𝑙 + 𝑈𝑢 +𝑟 ℎ𝑘𝑟) + 𝑏𝑢) +(11) +𝑐𝑘 = 𝑖𝑘 ⊙ 𝑢𝑘 + (𝑐𝑘𝑙 ⊙ 𝑓𝑘𝑙 + 𝑐𝑘𝑟 ⊙ 𝑓𝑘𝑟) +(12) +ℎ𝑘 = 𝑜𝑘 ⊙ 𝑡𝑎𝑛ℎ(𝑐𝑘) +(13) +where the ⊙ means Hadamard product [40]. After the hidden state and input state are calculated, the encoding of the +current node 𝑣𝑘 is finished. The states 𝑐𝑘 and ℎ𝑘 will then be used for the encoding of 𝑣𝑘’s parent node. During the AST +encoding, Tree-LSTM encodes every node in the AST from bottom up as shown in Tree-LSTM Encoding in Figure 7. +After encoding all nodes in the AST, the hidden state of the root node is used as the encoding of the AST. +Manuscript submitted to ACM + +Asteria-Pro +13 +6.2 +Siamese Calculation +This step uses Siamese architecture that integrates two identical Tree-LSTM model to calculate similarity between +encoded vectors. The details of the Siamese architecture M(𝑇1,𝑇2) are shown in Figure 7. The Siamese architecture +consists of two identical Tree-LSTM networks that share the same parameters. In the process of similarity calculation, +the Siamese architecture first utilizes Tree-LSTM to encode ASTs into vectors. We design the Siamese architecture +with subtraction and multiplication operations to capture the relationship between the two encoding vectors. After the +operations, the two resulting vectors are concatenated into a larger vector. Then the resulting vector goes through a +layer of softmax function to generate a 2-dimensional vector. The calculation is defined as: +M(𝑇1,𝑇2) = 𝑠𝑜𝑓 𝑡𝑚𝑎𝑥(𝜎(𝑐𝑎𝑡(|N (𝑇1) − N (𝑇2)|, N (𝑇1) ⊙ N (𝑇2)) ×𝑊 ))) +(14) +where 𝑊 is a 2𝑛 × 2 matrix, the ⊙ represents Hadamard product [40], | · | denotes the operation of making an absolute +value, the function 𝑐𝑎𝑡(·) denotes the operation of concatenating vectors. The softmax function normalizes the vector +into a probability distribution. Since 𝑊 is a 2𝑛 × 2 weight matrix, the output of Siamese architecture is a 2 × 1 vector. +The format of output is [𝑑𝑖𝑠𝑠𝑖𝑚𝑖𝑙𝑎𝑟𝑖𝑡𝑦 𝑠𝑐𝑜𝑟𝑒,𝑠𝑖𝑚𝑖𝑙𝑎𝑟𝑖𝑡𝑦 𝑠𝑐𝑜𝑟𝑒], where the first value represents the dissimilarity score +and the second represents the similarity score. During the model training, the input format of Siamese architecture +is < 𝑇1,𝑇2,𝑙𝑎𝑏𝑒𝑙 >. In our work, the label vector [1, 0] means 𝑇1 and 𝑇2 are from non-homologous function pairs and +the vector [0, 1] means homologous. The resulting vector and the label vector are used for model loss and gradient +calculation. During model inference, the second value in the output vector is taken as the similarity of the two ASTs, +and the similarity of ASTs is used in re-ranking. +Name Match +High Similarity +Search +... +... +Relational +Struct +Match +Fig. 8. The Re-ranking Motivation Example. In the rectangular box with dashed line are the top K candidate homologous functions of +𝐹1 produced by the search (i.e., DL-based similarity detection). Solid line arrows indicate the function call relationship (e.g., 𝐹1 calls +𝐶𝐹1 +𝑛 ). The dotted line arrows indicate the callee function match in re-ranking. +7 +DK-BASED RE-RANKING +This module seeks to confirm the homology of top k candidate functions output by Tree-LSTM network by re-ranking +them. In the prior phase, the Tree-LSTM network infers the semantic information from AST, which is a intra-functional +feature. The knowledge gained from AST is insufficient for establishing the homology of functions. In this phase, +function call relationships are used as domain knowledge to compensate for the lack of knowledge regarding the +inter-functional features of the Tree-LSTM. To this end, we design an algorithm called Relational Structure Match. +In contrast to the callee application in the pre-filtering module, this module uses more extensive information from calle +relationships, to show degree of homology of candidate functions. +Manuscript submitted to ACM + +14 +Shouguo Yang, Chaopeng Dong, and Yang Xiao, et al. +7.1 +Motivated Example +Our algorithm is based on a conforming observation to an intuitive law: If a function 𝐹1 calls function 𝐶𝐹1, then its +homologous function 𝐹 ′ +1 will also call the homologous function 𝐶𝐹 ′ +1 of 𝐶𝐹1. As depicted in Figure 8, we have 𝐹1 calls +𝐶𝐹1, and 𝐹 ′ +1 calls 𝐶𝐹 ′ +1. Assume that the search process for 𝐹1 yields top K functions containing the target homologous +function 𝐹 ′ +1. We then employ the call relations of 𝐹1 and 𝐹 ′ +1 to conduct precise callee function match for re-ranking. In +particular, callee functions of 𝐹1 are divided into two categories, named callees 𝐶𝐹1 +𝑛 and anonymous callees 𝐶𝐹1 +𝑎 . For +named callees, their names are utilized to match callees of functions between source function 𝐹1 and candidate top K +functions. For anonymous callees, we employ DL-based similarity detection to calculate similarity between callees of +functions between source function 𝐹1 and candidate top K functions. Recall the observation, the homologous function +𝐹 ′ +1 of 𝐹1 holds the most matched callees. 𝐹 ′ +1 is re-ranked in first place after candidate functions are re-ranked based on +matched callees. +7.2 +Relational Structure Match Algorithm +This algorithm aims to rescore each candidate function by fully exploiting the call relationship of target function and +candidate functions. The relational structure refers to call relations between target function and all its callee functions +as illustrated in Section § 7.1. To match relational structure, given a source function 𝐹1, the algorithm executes one of +following two distinct operations (𝑂1 and 𝑂2) based on whether the source function has callee functions or not. +𝑂1: When 𝐹1 has callee function(s), the algorithm extracts all callee functions of 𝐹1 to build mixed callee function +set (MCFS) (described below). Based on MCFS, the algorithm detects similarities between the target functions +and candidate functions as new scores. It re-ranks all candidate functions by combining the Asteria scores +( Equation 6 ) with the newly calculated match scores. The details of MCFS and match score calculation are +described below. +𝑂2: When 𝐹 has no callee function, the algorithm removes all candidate functions which have callee function(s). +Then the left candidate function are re-ranked by their Asteria scores. +Mixed Callee Function Set. The mixed callee function set of function 𝐹 is comprised of two types of callee functions: +named callee and anonymous callee. Anonymous callee refers to a type function for which the function name has been +removed for security reasons. The other type of callee functions have their names preserved because they are imported +or exported functions and the function name is necessary for external link purpose. These callee functions are called +named callee. We denote MCFS of 𝐹 with 𝐶𝑆𝐹 = {𝐶𝐹 +𝑛1, ...,𝐶𝐹 +𝑛𝑗,𝐶𝐹 +𝑎1, ...,𝐶𝐹 +𝑎𝑗 }, where 𝐶𝐹 +𝑛𝑗 denotes named callee function +and 𝐶𝐹 +𝑎𝑗 denotes anonymous callee function. +Match Score Calculation. With MCFSs of target function 𝐹1 and all candidate functions extracted, the algorithm +conducts two kinds of matches between callees to calculate match score 𝑀 for each candidate function. +Named Callee Match. For all named callees 𝐶𝐹1 +𝑛𝑗 in 𝐶𝑆𝐹1, the algorithm matches them and named callees of each +candidate functions by function name. For example, the named callee 𝐶𝐹1 +𝑛 and 𝐶𝐹 ′ +1 +𝑛 share the same function name +in Figure 8 so they are matched. The number of matched functions of candidate function 𝐹𝑖 is denoted as N𝐹𝑖 +𝑛 . +Anonymous Callee Match. For all anonymous callee 𝐶𝐹1 +𝑎𝑖 in 𝐶𝑆𝐹1, the algorithm utilizes DL-based similarity +detection to calculate simialrity scores between all anonymous callee of all candidate functions. For each +anonymous callee 𝐶𝐹𝑖 +𝑎𝑗 in candidate function 𝐹𝑖, the algorithm takes the maximum similarity score between it +and all anonymous callees of target function as its score S𝐹𝑖 +𝑎𝑗. +Manuscript submitted to ACM + +Asteria-Pro +15 +After matching all callee functions of candidate functions, for candidate function 𝐹𝑖, the match score 𝑀𝐹𝑖 of 𝐹𝑖 is +calculated as follows: +𝑀𝐹𝑖 = N𝐹𝑖 +𝑛 + +∑︁ +S𝐹𝑖 +𝑎𝑗 +(15) +where S𝐹𝑖 +𝑎𝑗 ∈ 𝐶𝑆𝐹𝑖 . +Match Score-based Re-ranking. The re-ranking score of candidate function 𝐹𝑖 is combined by match score 𝑀𝐹𝑖 +and its DL-based similarity MF⟩ in Equation 14. We calculate new score 𝑆𝑟𝑒−𝑟𝑎𝑛𝑘 +𝐹𝑖 +for all candidate functions with +following equation: +𝑆𝑟𝑒−𝑟𝑎𝑛𝑘 +𝐹𝑖 += 𝛼 × MF⟩ + 𝛽 × 𝑀𝐹𝑖 +(16) +where 𝛼 + 𝛽 = 1. All candidate functions are resorted by their new rank scores 𝑆𝑟𝑒−𝑟𝑎𝑛𝑘 +𝐹𝑖 +in descending order. +8 +EVALUATION +We aim to conduct a comprehensive practicality evaluation of various state-of-the-art function similarity detection +methods for bug search. To this end, we adopt 8 different metrics to depict the search capability of different methods in +a more comprehensive way. Furthermore, we construct a large evaluation dataset, in a way that is closer to practical +usage of function similarity detection. +8.1 +Research Questions +In the evaluation experiments, we aim to answer following research questions: +RQ1. How does Asteria-Pro compare to baseline methods in cross-architecture function similarity detection on the +two detection tasks? +RQ2. What is the performance of Asteria-Pro, compared to baseline methods in Task-V? +RQ3. How much do DK-based filtration and DK-based re-ranking improves in accuracy and efficiency? +RQ4. How does Asteria-Pro perform in real-world bug search? +8.2 +Implementation Details +We utilize IDA Pro 7.5 [4] and its plug-in Hexray Decompiler to decompile binary code for AST extraction. This +version of Hexray Decompiler currently supports the architectures of x86, x64, PowerPC (PPC), and ARM. We use the +Hexray Decompiler to decompile the target binaries and extract the ASTs. For the encoding of leaf nodes in Formulas +(7)-(12), we assign the state vectors ℎ𝑘𝑙, ℎ𝑘𝑟 , 𝑐𝑘𝑙, and 𝑐𝑘𝑟 to zero vectors. The loss function for model training is BCELoss, +which measures the binary cross entropy between the labels and the predictions. The AdaGrad optimizer is applied +for gradient computation and weight-matrix updating after losses are computed. Since the The computation steps of +Tree-LSTM depend on the shape of the AST, therefore, we cannot perform parallel batch computation, which makes +the batch size always to be 1. The model is trained for 60 epochs. Our experiments are performed on a local server +equipped with two Intel(R) Xeon(R) CPUs E5-2620 v4 @ 2.10GHz, each with 16 cores, 128GB of RAM, and 4T of storage. +The code of Asteria-Pro runs in a Python 3.6 environment. We use gcc v5.4.0 compiler to compile source code in +our dataset, and use the buildroot-2018.11.1 [1] for the dataset construction. We use the tool binwalk [5] to unpack +the firmware for obtaining the binaries to conduct further analysis. In UpRelation algorithm of filtering module, we +set values of thresholds 𝑇𝐺𝐿,𝑇𝑐𝑎𝑙𝑙𝑒𝑒,𝑇𝑠𝑡𝑟𝑖𝑛𝑔 to 0.1, 0.8, 0.8 based on their 𝐹𝑠𝑐𝑜𝑟𝑒, respectively. The crucial threshold 𝑇𝐺𝐿 +Manuscript submitted to ACM + +16 +Shouguo Yang, Chaopeng Dong, and Yang Xiao, et al. +is discussed in § 8.7.1. We merely set 𝛼 = 0.1, 𝛽 = 0.9 in Equation 16 to emphasize role of callee function similarities in +re-ranking. +8.3 +Comprehensive Benchmark +To compare BCSD methods in a comprehensive way, we build an extensive benchmark based on multiple advanced +works [50, 60, 64]. The benchmark comprises of two datasets, two detection tasks, and six measure metrics, where two +datasets are utilized separately for each of the two detection tasks. +8.3.1 +Dataset. The functions not involved in the prefiltering test (see § 3) are divided into two datasets for model +training and testing and evaluation. +Model Dataset Construction. We select 31,940 functions from 1944 distinct binaries to construct 314,852 homologous +function pairs and 314,852 non-homologous function pairs, respectively. Then, we divided all function pairs by an 8:2 +ratio into training set and testing set. This dataset is constructed for Tree-LSTM training and testing. +Evaluation Dataset Construction. We randomly select 60,221 functions from each architecture’s 2,875 binaries. Using +these functions, two sub-datasets for two evaluation tasks are constructed. The first sub-dataset is constructed in a +classification manner for technique comparison [64, 65], and the second sub-dataset is constructed in a bug search +manner. Each dataset includes a large number of to-be-matched tuples, each of which is in form of (𝐹, 𝑃𝑠𝑒𝑡), where 𝑃𝑠𝑒𝑡 +denotes a function set containing candidate functions to be matched with source function 𝐹. Given a source function +𝐹, the first sub-dataset combines one of its homologous function 𝐹ℎ and a non-homologous function 𝐹𝑛 as 𝑃𝑠𝑒𝑡. To +emulate the bug search, the second sub-dataset puts more non-homologous functions into the 𝑃𝑠𝑒𝑡. Specifically, given a +source function 𝐹, we randomly choose a homologous function and pick 𝑁 non-homologous functions into the 𝑃𝑠𝑒𝑡. +We call the first sub-dataset g-dataset and the second sub-dataset v-dataset. In v-dataset, we randomly pick 10, 000 +non-homologous functions for the 𝑃𝑠𝑒𝑡. The formal representation of two datasets are as following: +g-dataset : {(𝐹, (𝐹ℎ, 𝐹𝑛)), } +(17) +v-dataset : {(𝐹, (𝐹ℎ, 𝐹𝑛1, ..., 𝐹𝑛𝑖, ..., 𝐹𝑛10000)), } +(18) +where 𝐹ℎ denotes the homologous functions, and 𝐹𝑛𝑖 denotes the ith non-homologous function. For each dataset, the +source function 𝐹 will be matched with all functions in the 𝑃𝑠𝑒𝑡 for evaluation. +8.3.2 +Metrics. We choose five distinct metrics for comprehensive evaluation from earlier works [53, 60, 68]. In our +evaluation, the similarity of a function pair is calculated as a score of 𝑟. Assuming the threshold is 𝛽, if the similarity +score 𝑟 of a function pair is greater than or equal to 𝛽, the function pair is regarded as a positive result, otherwise a +negative result. For a homologous pair, if its similarity score 𝑟 is greater than or equal to 𝛽, it is a true positive (TP). +If a similarity score of 𝑟 is less than 𝛽, the calculation result is a false negative (FN). For a non-homologous pair, if a +similarity score 𝑟 is greater than or equal to 𝛽, it is a false positive (FP). When the similarity score 𝑟 is less than 𝛽, it is a +true negative (TN). These metrics are described as following: +• TPR. TPR is short for true positive rate. TPR shows the accuracy of homologous function detection at threshold +𝛽. It is calculated as 𝑇𝑃𝑅 = +𝑇𝑃 +𝑇𝑃+𝐹𝑁 . +• FPR. FPR is short for false positive rate. FPR shows the accuracy of non-homologous function detection at +threshold 𝛽. It is calculated as 𝐹𝑃𝑅 = +𝐹𝑃 +𝐹𝑃+𝑇 𝑁 . +Manuscript submitted to ACM + +Asteria-Pro +17 +• AUC. AUC is short for area under the curve, where the curve is termed Receiver Operating Characteristic (ROC) +curve. The ROC curve illustrates the detection capacity of both homologous and non-homologous functions as +its discrimination threshold 𝛽 is varied. AUC is a quantitative representation of ROC. +• MRR. MRR is short for mean reciprocal rank, which is a statistic measure for evaluating the results of a sample +of queries, ordered by probability of correctness. It is commonly used in retrieval experiments. In our evaluation, +it is calculated as 𝑀𝑅𝑅 = +1 +|𝑃𝑠𝑒𝑡 | +� +𝐹ℎ𝑖 ∈𝑃𝑠𝑒𝑡 +1 +𝑅𝑎𝑛𝑘𝐹ℎ𝑖 , where 𝑅𝑎𝑛𝑘𝐹ℎ𝑖 denotes the rank of function 𝐹ℎ𝑖 in pairing +candidate set 𝑃𝑠𝑒𝑡, and |𝑃𝑠𝑒𝑡 | denotes the size of 𝑃𝑠𝑒𝑡. +• Recall@Top-k. It shows the capacity of homologous function retrieve at top k detection results. The top k +results are regarded as homologous functions (positive). It is calculated as follows: +𝑔(𝑥) = + + +1 +if 𝑥 = 𝑇𝑟𝑢𝑒 +0 +if 𝑥 = 𝐹𝑎𝑙𝑠𝑒 +𝑅𝑒𝑐𝑎𝑙𝑙@𝑘 = 1 +|𝐹 | +∑︁ +𝑔(𝑅𝑎𝑛𝑘𝑓 𝑔𝑡 +𝑖 +≤ 𝑘) +To demonstrate the reliability of the ranking results, we adopt Recall@Top-1 and Recall@Top-10. +8.3.3 +Detection Tasks. We present the following two function similarity detection tasks based on BCSD applications [35]: +• C-task. C-task stands for classification task. This task aims to test the ability of the methods to discriminate +between homologous and non-homologous functions. C-task performs binary classification for homologous and +non-homologous functions on dataset g-dataset and calculates three metrics: TPR, FPR, AUC, since they are +generally used to indicate the binary classification performance of the model. The g-dataset meets the dataset +requirement and is used in this task. +• V-task. V-task stands for bug (vulnerability) search task. This task aims to evaluate the capacity of identifying +vulnerable functions from a vast pool of candidate functions. In other words, given a source function, it is the +same action to find its homologous function from candidate functions. This data requirement is met by the +v-dataset. More specifically, for a to-be-matched tuple (𝐹, 𝑃𝑠𝑒𝑡), tested methods calculate function similarity +between source function 𝐹 and all functions in 𝑃𝑠𝑒𝑡. After similarity calculation, the functions in the 𝑃𝑠𝑒𝑡 can be +sorted by similarity scores. Metrics MRR, Recall@Top-1, and Recall@Top-10 are calculated in this task. +8.4 +Baseline Methods. +We choose various representative cross-architectural BCSD works, that make use of AST or are built around deep +learning encoding. These BCSD works consist of Diaphora [2], Gemini [64], SAFE [51], and Trex [53]. Moreover, we also +use our previous conference work Asteria as one of baseline methods. We go over these works in more details below. +Diaphora. Diaphora performs similarity detection also based on AST. Diaphora maps nodes in an AST to primes +and calculates the product of all prime numbers. Then it utilizes a difference function to calculate the similarity between +the prime products. We download the Diaphora source code from github [2], and extract Diaphora’s core algorithm for +AST similarity calculation for comparison. Noting that it would take a significant amount of time (several minutes) to +compute a pair of functions with extremely dissimilar ASTs, we add a filtering computation before the prime difference. +The filtering calculates the AST size difference and eliminates function pairs with a significant size difference. We +publish the improved Diaphora source code on our website [6]. +Manuscript submitted to ACM + +18 +Shouguo Yang, Chaopeng Dong, and Yang Xiao, et al. +Table 2. AUCs in Task-C. +Methods +X86-ARM +X86-X64 +X86-PPC +ARM-X64 +ARM-PPC +X64-PPC +Average +Asteria +0.995 +0.998 +0.998 +0.995 +0.998 +0.999 +0.997 +Gemini +0.969 +0.984 +0.984 +0.973 +0.968 +0.984 +0.977 +SAFE +0.851 +0.867 +- +0.872 +- +- +0.863 +Trex +0.794 +0.891 +- +0.861 +- +- +0.849 +Diaphora +0.389 +0.461 +0.397 +0.388 +0.455 +0.400 +0.415 +Gemini. Gemini encodes ACFGs (attributed CFGs) into vectors with a graph embedding neural network. The ACFG +is a graph structure where each node is a vector corresponding to a basic block. We have obtained Gemini’s source +code and its training dataset. Notice that in [64] authors mentioned it can be retrained for a specific task, such as the +bug search. To obtain the best accuracy of Gemini, we first use the given training dataset to train the model to achieve +the best performance. Then we re-train the model with the part of our training dataset. Gemini supports similarity +detection on X86, MIPS, and ARM architectures. +SAFE. SAFE works directly on disassembled binary functions, does not require manual feature extraction, is compu- +tationally more efficient than Gemini. In their vulnerability search task, SAFE outperforms Gemini in terms of recall. +SAFE supports three different instruction set architecture X64, X86, and ARM. We retrain SAFE based on the official +code [51] and use retrained model parameter for our test. In particular, we select all appropriate function pairs from the +training dataset, whose instruction set architectures are supported by SAFE. Then we extract the function features for +all function pairs selected and discard the function pairs whose features SAFE cannot extract. After feature extraction, +27,580 function pairs of three distinct architecture combinations (i.e., X86-X64, X86-ARM, and X64-ARM) are obtained +for training. Next, We adopt the default model parameters (e.g., embedding size) and training setting (e.g. training +epoches) to train SAFE. +Trex. Trex is based on pretrained model [53] of the state-of-the-art NLP technique, and micro-traces. It utilizes a +dynamic component to extract micro-traces and use them to pretrain a masked language model. Then it integrates +pretrained ML model into a similarity detection model along with the learned semantic knowledge from micro-traces. +It supports similarity detection of ARM, MIPS, X86, and X64. +8.5 +Comparison of Cross-architecture Similarity Detection (RQ1) +We evaluate various approaches on two distinct tasks. Due to the fact that the baseline methods may not be able to +detect for all four instruction set architectures, the detection results for some architecture combinations are empty. In +the two paragraphs that follow, the outcomes of two distinct tasks are discussed. +Comparison on task-C. For task-C, we evaluate all approaches by performing similarity detection on all supported +architectural combinations. After detection, the three task-C-referenced metrics are calculated and presented in Table 2 +and Figure 9. In each subplot of Figure 9, the x-axis represents FPR, while the y-axis represents TPR. Six subplots +depict the ROC curves of various architecture combinations. In general, methods with performance curves closer to the +upper-left corner have a superior performance. It is evident from all subplots that our model outperforms all baseline +methods. Quantitatively, the AUC values of our model are greater than those of the other baseline techniques for any +architectural combination in Table 2. +Manuscript submitted to ACM + +Asteria-Pro +19 +0 +0.2 +0.4 +0.6 +0.8 +1 +0 +0.2 +0.4 +0.6 +0.8 +1 +FPR +TPR +X86-ARM +Asteria +Gemini +SAFE +Diaphora +Trex +0 +0.2 +0.4 +0.6 +0.8 +1 +0 +0.2 +0.4 +0.6 +0.8 +1 +FPR +TPR +X86-X64 +Asteria +Gemini +SAFE +Diaphora +Trex +0 +0.2 +0.4 +0.6 +0.8 +1 +0 +0.2 +0.4 +0.6 +0.8 +1 +FPR +TPR +X86-PPC +Asteria +Gemini +Diaphora +0 +0.2 +0.4 +0.6 +0.8 +1 +0 +0.2 +0.4 +0.6 +0.8 +1 +FPR +TPR +ARM-X64 +Asteria +Gemini +SAFE +Diaphora +Trex +0 +0.2 +0.4 +0.6 +0.8 +1 +0 +0.2 +0.4 +0.6 +0.8 +1 +FPR +TPR +ARM-PPC +Asteria +Gemini +Diaphora +0 +0.2 +0.4 +0.6 +0.8 +1 +0 +0.2 +0.4 +0.6 +0.8 +1 +FPR +TPR +X64-PPC +Asteria +Gemini +Diaphora +Fig. 9. ROC Curves on All Cross-architecture Combination Detection. +Table 3. MRR and Recall of Different Methods. +Metrics +Methods +X86-X64 +X86-ARM +X86-PPC +X64-ARM +X64-PPC +ARM-PPC +Avg +Asteria-Pro +0.934 +0.887 +0.931 +0.879 +0.919 +0.903 +0.908 +Asteria +0.776 +0.724 +0.731 +0.708 +0.713 +0.750 +0.734 +Trex +0.414 +0.206 +- +0.309 +- +- +0.310 +Gemini +0.478 +0.250 +0.325 +0.336 +0.357 +0.256 +0.334 +Safe +0.029 +0.007 +- +0.009 +- +- +0.015 +MRR +Diaphora +0.023 +0.019 +0.020 +0.019 +0.020 +0.021 +0.020 +Asteria-Pro +0.917 +0.868 +0.912 +0.879 +0.899 +0.903 +0.896 +Asteria +0.706 +0.648 +0.652 +0.627 +0.631 +0.675 +0.657 +Trex +0.274 +0.110 +- +0.192 +- +- +0.192 +Gemini +0.405 +0.180 +0.242 +0.261 +0.279 +0.229 +0.266 +Safe +0.004 +0.002 +- +0.002 +- +- +0.003 +Recall@Top-1 +Diaphora +0.021 +0.016 +0.017 +0.016 +0.017 +0.018 +0.018 +Asteria-Pro +0.961 +0.921 +0.962 +0.913 +0.952 +0.932 +0.940 +Asteria +0.902 +0.867 +0.882 +0.857 +0.866 +0.890 +0.877 +Trex +0.710 +0.452 +- +0.575 +- +- +0.579 +Gemini +0.615 +0.383 +0.482 +0.478 +0.502 +0.468 +0.488 +Safe +0.022 +0.010 +- +0.014 +- +- +0.015 +Recall@Top-10 +Diaphora +0.029 +0.024 +0.026 +0.026 +0.025 +0.027 +0.026 +Comparison on task-V. As shown in Table 3, we calculate MRR, Recall@Top-1, and Recall@Top-10 for a variety of +architectural combinations. Recall@Top-1 is a rigorous metric that indicates the robust detection capacity of homologous +functions, whereas Recall@Top-10 demonstrates the capability to rank homologous functions in the top ten positions. +In the first column of the table are the metrics, and in the second column are the names of the methods. The third +through eighth columns provide the metric values for the various architectural combinations, whereas the last column +displays the mean for all architectures. Asteria-Pro and Asteria consistently outperform baseline approaches by a +Manuscript submitted to ACM + +20 +Shouguo Yang, Chaopeng Dong, and Yang Xiao, et al. +1 +CK_RV proxy_C_DigestInit(...){ +2 +/* +3 +Variable Initialization. +4 +*/ +5 +v5 = (Proxy *)self [1]. +C_GetSlotInfo; +6 +v7 = handle; +7 +result = map_session_to_real( +v5 ,&v7 ,&map ,V3); +8 +if (! result) +9 +result = map.funcs ->C_ +DigestInit(v7 , +mechanism); +10 +return result; +11 +} +1 +CK_RV proxy_C_DigestKey(...){ +2 +/* +3 +Variable Initialization. +4 +*/ +5 +v5 = (Proxy *)self [1]. +C_GetSlotInfo; +6 +v7 = handle; +7 +result = map_session_to_real( +v5 ,&v7 ,&map ,V3); +8 +if (! result) +9 +result = map.funcs ->C_ +DigestKey(v7 , mechanism +); +10 +return result; +11 +} +Fig. 10. Two Proxy Functions with only distinctions highlighted in red +significant margin across all architecture configurations. Asteria-Pro achieves a very high average MRR (0.908), +indicating an MRR improvement of up to 23.71% compared to Asteria. Even after retraining, Safe’s detection results +demonstrate that it improperly recognizes small functions despite its poor performance. Regarding Recall@Top-1, +Asteria-Pro and Asteria attain relatively high average precisions (0.89 and 0.65, respectively) that are 237% and 146% +greater than the best result (0.26). Asteria-Pro has a 36.4% improvement in Recall@Top-1 vs Asteria. Regarding +the metric Recall@Top-10, Asteria-Pro and Asteria continue to reign supreme. In comparison to Recall@Top-1, we +observe that the recall of other methods, such as Trex, increases dramatically, from 0.192 to 0.579, indicating that they +are able to rate homologous sequences quite highly. However, they are still far below Asteria-Pro. +Despite the similar ROC curve performance of Asteria, Gemini, SAFE, and Trex, their Task-V performance is entirely +different. Gemini, for instance, has a large AUC score of 0.977, which is similar to Asteria’s 0.997. However, in terms of +MRR, Gemini performs poorly (0.333) compared to Asteria (0.734) and Asteria-Pro (0.908). This suggests that testing +BCSD approaches in a single experiment setting (such as the Task-C setting) is insufficient to demonstrate application +behavior. +False Positive Analysis. There are two primary causes for Asteria’s false positive outcomes. +• Cause 1. Proxy functions hold similar syntactic structures, resulting in similar semantic. Figure 10 illustrates two +proxy functions that differ solely on line 9. Asteria-Pro fails to differentiate proxy functions since their semantics +are similar. In addition, the callees are difficult to confirm due to indirect jump table when symbols are lacking. +• Cause 2. Compilers for distinct architectures utilize various intrinsic functions that substitute libc function calls +with optimized assembly instructions. For instance, the gcc-X86 compiler may replace the memcpy function with +several memory operation instructions, causing the function to be absent from the callee function list. Asteria’s +filtering and re-ranking modules lack a complete set of callee functions for score calculation, resulting in a loss +of precision. +Manuscript submitted to ACM + +Asteria-Pro +21 +Answer to RQ1: Asteria-Pro demonstrates superior accuracy in both Task-C and Task-V. In Task-C, +dominant model in Asteria-Pro demonstrates the best classification performance by producing the highest +AUC (0.997). Regarding Task-V, Asteria-Pro outperforms other baseline methods by a large margin in +MRR, Recall@Top-1, and Recall@Top-10. In particular, Asteria-Pro has 172%, 236%, 147% higher MRR, +Recall@Top-1, Recall@Top-10 than the best baseline methods. Compared with Asteria, Asteria-Pro manages +to improve it for Task-V with 23.71% higher MRR, 36.4% higher Recall@Top-1, and 7.2% higher Recall@Top-10. +0 +2 +4 +6 +Asteria-Pro +Asteria +Trex +Gemini +Safe +Diaphora +Time/10−2s +(a) Average Feature Extraction Time for One Function +0 +50 +100 +150 +200 +250 +300 +Asteria-Pro +Asteria(/10) +Trex(/100) +Gemini +Safe +Diaphora(/10) +Time/s +Phase 1 +Phase 2 +(b) Average Time for One Search +Fig. 11. Performance Comparison of All Methods on Task-V +8.6 +Performance Comparison (RQ2) +In this section, the detection time of function similarity for all baseline approaches and Asteria-Pro are measured. +Since the DK-based prefiltration and DK-based re-ranking modules are intended to enhance performance in Task-V, we +only count the timings in Task-V. In task-V, given a source function, methods extract the function features of source and +all candidate functions, which is referred to as phase 1. Next, the extracted function features are subjected to feature +encoding and encoding similarity computation to determine the final similarities, which is referred to as phase 2. +As shown in Figure 11a, we calculate the average feature extraction time for each function. The x-axis depicts +extraction time, while the y-axis lists various extraction methods. During phase 1, Asteria-Pro, Asteria, and Diaphora +all execute the same operation (i.e., AST extraction), resulting in the same average extraction time. Since AST extraction +requires binary disassembly and decompilation, it requires the most time compared to other methods. Trex requires +the least amount of time for feature extraction, which is less than 0.001s per function, as code disassembly is the only +time-consuming activity. +Figure 11b illustrates the average duration of a single search procedure for various methods. The phases 1 and 2 of a +single search procedure are denoted by distinct signs. Due to its efficient filtering mechanism, Asteria-Pro requires +the least amount of time (58.593s) to complete a search. Due to its extensive pre-training model encoding computation, +Trex is the most time-consuming algorithm. Asteria-Pro cuts search time by 96.90%, or 1831.36 seconds, compared +to Asteria (1889.96 seconds). +Manuscript submitted to ACM + +22 +Shouguo Yang, Chaopeng Dong, and Yang Xiao, et al. +Answer to RQ2: Asteria-Pro costs the least average time to accomplish task-V. Compared with Asteria, +Asteria-Pro cuts search time by 96.90% by introducing the filtering module. +Table 4. Accuracy of Different Module Combination +Module Combination +MRR +Recall@Top-1 +Recall@Top-10 +Average Time(s) +Pre-filtering + Asteria +0.824 +0.764 +0.929 +57.8 +Asteria + Reranking +0.882 +0.864 +0.910 +1889.8 +8.7 +Ablation Experiments (RQ3) +To demonstrate the progresses made by different modules of DK-based filtration and DK-based re-ranking, we conduct +ablation experiments by evaluating the different module combinations in Asteria-Pro. The module combinations +are Pre-filtering + Asteria and Asteria + Re-ranking. The two module combinations performs Task-V and the results +are shown in Table 4. For Asteria + Re-ranking, the top 20 similarity detection results are re-ranked by the Re-ranking +module. +Filtration Improvement. Compared to Asteria, the integration of pre-filtering improves MRR, Recall@Top-1, and +Recall@Top-10 by 12.26%, 16.29%, and 5.93%, respectively. In term of efficiency, it cuts search time by 96.94%. The Pre- +filtering + Asteria combination performs better than Asteria + Re-ranking in terms of Recall@Top-10 and time consumption. +It generates a greater Recall@Top-10 because it filters out a large proportion of highly rated non-homologous functions. +Re-ranking Improvement. Compared to Asteria, the integration of Re-ranking module improves MRR, Recall@Top- +1, and Recall@Top-10 by 20.16%, 31.51%, and 3.76%, respectively. In terms of efficiency, it costs average additional 0.13s +for re-ranking, which is negligible. Compared to Pre-filtering + Asteria, re-ranking module contributes to an increase in +MRR and Recall@Top-1 by enhancing the rank of homologous functions. +Answer to RQ3: The filtering significantly cuts the calculation time by 96.94%, and increase precision slightly. +Re-ranking improves MRR, Recall@Top-1, and Recall@Top-10 by 20.16%, 31.51%, and 3.76%, respectively, with +negligible time costs. +Table 5. Capacity to Filter of Various Filtering Thresholds. +𝑇𝐺𝐿 +# Filtered Function +Recall +0.1 +9666.7 +0.9813 +0.2 +9734.1 +0.9808 +0.3 +9777.4 +0.9791 +0.4 +9793.5 +0.9773 +0.5 +9805.5 +0.9737 +Manuscript submitted to ACM + +Asteria-Pro +23 +8.7.1 +Different Filtering Threshold. In Algorithm 1, the threshold 𝑇𝐺𝐿 determines the number of functions that are +filtered out. We evaluate the efficacy of the filtering module by utilizing various𝑇𝐺𝐿 values, and the results are presented +in Table 5. The threshold values range from 0.1 to 0.5 in the first column, where a higher threshold value suggests a +more severe selection of the similarity function. The second column indicates the number of functions omitted by the +filter, while the third column displays the recall rate in the filteration results. As the threshold value increases, the recall +rate declines and the number of filtered-out functions grows. We use 0.1 as our threshold value for two key reasons: a) +the high recall rate of filtering results is advantageous for subsequent homologous function detection, and b) there is no +significant difference in the number of functions that are filtered out. +8.8 +Real World Bug Search (RQ4) +To assess the efficacy of Asteria-Pro, we conduct a massive real-world search for bugs. To accomplish this, we +obtain firmware and compile vulnerability functions to create a firmware dataset and a vulnerability dataset. Utilizing +vulnerability dataset, we then apply Asteria-Pro to detect vulnerable functions in the firmware dataset. To confirm +vulnerability in the resulting functions, we design a semi-automatic method for identifying vulnerable functions. +Through a comprehensive analysis of the results, we discover intriguing facts regarding vulnerabilities existed in IoT +firmware. +Table 6. Vulnerability Dataset +Software +CVE # +Disclosure Years +Vulnerable Version Range +OpenSSL +22 +2013∼2016 +[1.0.0, 1.0.0s] +[1.0.1, 1.0.1t] +[1.0.2, 1.0.2h] +Busybox +10 +2015∼2019 +[0.38, 1.29.3] +Dnsmasq +14 +20{15,17,20,21} +[2.42, 2.82], 2.86 +Lighttpd +10 +20{08,10,11,13,14,15,18} +[1.3.11, 1.4.49] +Tcpdump +36 +2017 +[3.5.1, 4.9.1] +8.8.1 +Dataset Construction. In contrast to our prior work, we expand both the vulnerability dataset and the firmware +dataset for a comprehensive vulnerability detection evaluation. +Vulnerability Dataset. The prior vulnerability dataset of 7 CVE functions is enlarged to 90, as shown in Table 6. Vul- +nerability information is primarily gathered from the NVD website [11]. As shown in the first column, the vulnerabilities +are collected from widely used open-source software in IoT firmware, including OpenSSL, Busybox, Dnsmasq, Lighttpd, +and Tcpdump. In the second column, the number of software vulnerabilities is listed. In the third column, the timeframe +or specific years of the disclosure of the vulnerability are listed. The final column describes the software version ranges +affected by vulnerabilities. Note that the version ranges are obtained by calculating the union of all versions mentioned +in the vulnerability reports. As a result, Asteria-Pro is expected to generate vulnerability detection results for all +software versions falling within the specified ranges. +Firmware Dataset. We download as much of firmware from six popular IoT vendors as we could, consisting of +Netgear [3], Tp-Link [14], Hikvision [10], Cisco [7], Schneider [13], and Dajiang [8] as shown in first column of Table 7. +These firmware are utilized by routers, IP cameras, switches, and drones, all of which play essential parts in our life. The +Manuscript submitted to ACM + +24 +Shouguo Yang, Chaopeng Dong, and Yang Xiao, et al. +Table 7. Firmware Dataset and Its Software Statistics. # denotes number. +Firmware Dataset +Software Statistics +Vendor +Firmware # +Binary # +Function # +OpenSSL +Busybox +Dnsmasq +Lighttpd +Tcpdump +Netgear +548 +984 +2,627,143 +349 +512 +85 +14 +24 +TP-Link +95 +177 +427,795 +66 +90 +11 +3 +7 +Hikvision +90 +92 +279,299 +55 +35 +0 +0 +2 +Cisco +29 +66 +60,396 +23 +26 +10 +5 +2 +Schneider +10 +20 +31,228 +7 +9 +2 +2 +0 +Dajiang +7 +16 +57,275 +7 +7 +1 +0 +1 +All +779 +1,355 +3,483,136 +507 +679 +109 +24 +36 +second column shows the firmware numbers, which range from 7 to 548. The third and fourth columns gives numbers +of binaries and functions after unpacking firmware by using binwalk. Note that the binary number is the number of +software selected to be in the vulnerability dataset. The fifth column to ninth column gives the five software numbers +in all firmware vendors. OpenSSL and Busybox are widely integrated in these IoT firmware as their numbers are close +to those of the firmware. Through querying their official websites for device type information, we find that the majority +of Hikvision vendor firmware is for IP cameras, whereas Cisco vendor firmware is for routers. In particular, IP camera +firmware incorporates less software than router firmware because routers offer more functionality. For example, the +firmware of the Cisco RV340 router includes OpenSSL, Tcpdump, Busybox, and Dnsmasq, whereas the majority of IP +camera firmware only include OpenSSL. Similarly, the majority of the firmware of Netgear and Tp-Link consists of +routers, while Schneider and Dajiang’firmware include specialized devices such as Ethernet Radio and Stabilizers. +8.8.2 +Large Scale Bug Search. Asteria-Pro is employed to identify vulnerable homologous functions among 3,483,136 +firmware functions by referencing 90 functions from the vulnerability dataset. Specifically, in order to expedite the +detection process, vulnerability detection is restricted to the same software between firmware dataset and vulnerability +dataset. For instance, the vulnerable functions disclosed in OpenSSL are utilized to detect vulnerable homologous +functions in OpenSSL in the firmware dataset. For each software 𝑆, we first extract features (i.e., ASTs and call graphs) of +all functions in firmware dataset and vulnerable functions in vulnerability dataset. For each vulnerability disclosed in 𝑆, +the pre-filtration module uses the call graph to filter out non-homologous functions, followed by the Tree-LSTM model +encoding all remaining functions as vectors. Asteria-Pro then computes the AST similarity between the vulnerable +function vectors and the firmawre function vector. Asteria-Pro computes reranking scores based on the top 20 of +AST similarities based on similarity scores, since the evaluation demonstrates a very high recall in the top 20. As a +final step, Asteria-Pro generates 20 candidate homologous functions for each 𝑆 as a bug search result for each +vulnerability. To further refine the bug search results, we compute the average similarity score of homologous functions +in Section 8.5 and use it to eliminate non-vulnerable functions. In particular, the average similarity score of 0.89 is used +to eliminate 3987 of 5604 results. We perform heuristic confirmation of vulnerability for the remaining 1617 results. +Vulnerability Confirmation Method. We devise a semi-automatic method for confirming the actual vulnerable +functions from the candidate homologous functions. The method makes use of the symbols and string literals within +the firmware binaries of the target. Specifically, we use unique regular expressions to match version strings for each +software and to extract function symbols from the software. The method is then comprised of two distinct operations +that correspond to two distinct vulnerable circumstances 𝑉𝐶1, 𝑉𝐶2. +Manuscript submitted to ACM + +Asteria-Pro +25 +• 𝑉𝐶1. In this circumstances, the target binary contains version string (e.g., “OpenSSL 1.0.0a”) and the symbol of +target function is not removed. +• 𝑉𝐶2. Target binary contains version strings whereas the symbol of vulnerable homologous function is removed. +The versions of software listed in Table 6 are easy to extract using version strings [26]. The descriptions of the two +confirmation operations 𝐶𝑂1 and 𝐶𝑂2 are as follows: +• 𝐶𝑂1. For 𝑉𝐶1, we confirm the vulnerable function based on the version and name of the target software. In +particular, a vulnerable function is confirmed when the following two conditions are met: 1) software version is +in vulnerable version range, 2) the vulnerable function name retains after elimination with average similarity +score. +• 𝐶𝑂2. For 𝑉𝐶2, if the software versions are in the range of vulnerable versions, we manually compare the code +between the CVE functions and remaining functions to confirm the vulnerability. +Table 8. Numbers of Vulnerable Functions, Software, Firmware in Confirmation Results. +vendor +Vulnerable Function # +Vulnerable Software # +Vulnerable +Firmware # +OpenSSL +Busybox +Dnsmasq +Lighttpd +Tcpdump +All +OpenSSL +Busybox +Dnsmasq +Lighttpd +Tcpdump +All +Netgear +367 +0 +31 +0 +26 +424 +133 +0 +7 +0 +10 +150 +145 (26.46%) +TP-Link +394 +9 +0 +2 +5 +410 +36 +3 +0 +2 +5 +46 +36 (37.89%) +Hikvision +553 +0 +0 +0 +12 +565 +52 +0 +0 +0 +1 +53 +53 (58.89%) +Cisco +0 +0 +0 +0 +2 +2 +0 +0 +0 +0 +2 +2 +2 (6.90%) +Schneider +10 +0 +0 +0 +0 +10 +1 +0 +0 +0 +0 +1 +1 (10.00%) +Dajiang +70 +0 +0 +0 +1 +71 +7 +0 +0 +0 +1 +8 +7 (100.00%) +Total +1,394 +9 +31 +2 +46 +1,482 +229 +3 +7 +2 +19 +260 +244 (31.32%) +CVE-2016-2180 +CVE-2016-0797 +CVE-2016-2105 +CVE-2015-0286 +CVE-2016-2176 +CVE-2015-1788 +CVE-2015-1790 +CVE-2015-0287 +CVE-2015-0289 +CVE-2016-2160 +1 +50 +100 +7 +7 +7 +7 +7 +7 +7 +0 +7 +7 +52 +52 +52 +52 +47 +52 +52 +52 +52 +32 +117 +27 +27 +18 +27 +16 +16 +16 +14 +12 +1 +1 +1 +1 +1 +1 +1 +0 +1 +1 +30 +30 +30 +35 +30 +29 +29 +25 +15 +29 +Number +Dajiang +Hikvision +NETGEAR +Schneider +Tplink +Fig. 12. # of Vulnerable Functions Detected from Five Vendors +Results Analysis. In Table 8, we tally the number of vulnerable functions, software, and firmware upon vulnerability +confirmation. The first column contains the names of different vendors. The second through sixth columns show the +amount of vulnerable functions in various software, while the seventh column indicates the total number of vulnerable +functions across all vendors. The eighth through twelfth columns display the amount of vulnerable software binaries in +various software, while the thirteenth column provides the total number of vulnerable software binaries. According to +the seventh column of Table 7, there are a total of 1,482 vulnerable functions. 1456 are confirmed by 𝑉𝑂1, whereas +26 are confirmed by 𝑉𝑂2. For a total of 1,456 𝑉𝑂1 vulnerable functions, 1,377 vulnerable functions rank first and 79 +Manuscript submitted to ACM + +26 +Shouguo Yang, Chaopeng Dong, and Yang Xiao, et al. +1.0.0 +1.0.0f +1.0.0g +1.0.1e +1.0.1i +1.0.1j +1.0.1m +1.0.1p +1.0.1q +1.0.1t +1.0.2c +1.0.2d +1.0.2h +CVE-2013-0166 +CVE-2014-3508 +CVE-2014-8275 +CVE-2015-0286 +CVE-2015-0287 +CVE-2015-0288 +CVE-2015-0289 +CVE-2015-0292 +CVE-2015-1788 +CVE-2015-1790 +CVE-2015-1793 +CVE-2015-3195 +CVE-2016-0797 +CVE-2016-2105 +CVE-2016-2106 +CVE-2016-2176 +CVE-2016-2180 +CVE-2016-2182 +CVE-2016-2160 +0 +0 +0 +8 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +1 +2 +8 +0 +0 +0 +0 +0 +0 +0 +0 +0 +1 +1 +2 +8 +4 +2 +0 +0 +0 +0 +0 +0 +0 +1 +1 +2 +8 +4 +2 +0 +0 +0 +0 +0 +0 +0 +1 +1 +0 +8 +4 +2 +0 +0 +0 +0 +0 +0 +0 +1 +0 +0 +6 +0 +1 +0 +0 +0 +0 +0 +0 +0 +1 +1 +2 +8 +0 +2 +0 +0 +0 +0 +0 +0 +0 +1 +1 +2 +8 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +8 +4 +2 +2 +0 +0 +0 +0 +0 +0 +0 +0 +0 +8 +4 +2 +2 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +0 +4 +0 +0 +0 +0 +0 +0 +0 +0 +2 +1 +0 +0 +0 +0 +0 +0 +0 +0 +8 +4 +2 +2 +1 +1 +0 +4 +5 +0 +0 +0 +0 +8 +4 +2 +2 +1 +1 +0 +4 +5 +0 +0 +0 +0 +0 +0 +2 +2 +1 +1 +0 +0 +0 +0 +0 +0 +0 +8 +4 +2 +2 +1 +1 +0 +4 +5 +0 +0 +0 +0 +8 +0 +2 +2 +1 +1 +2 +4 +5 +92 +0 +0 +0 +2 +0 +2 +2 +1 +1 +10 +0 +0 +0 +0 +0 +0 +8 +4 +0 +0 +0 +0 +0 +0 +0 +0 +0 +20 +40 +60 +80 +(a) Netgear +1.0.0d +1.0.0e +1.0.0f +1.0.0g +1.0.1e +1.0.2d +CVE-2013-0166 +CVE-2014-3508 +CVE-2014-8275 +CVE-2015-0286 +CVE-2015-0287 +CVE-2015-0288 +CVE-2015-0289 +CVE-2015-0292 +CVE-2015-1788 +CVE-2015-1790 +CVE-2016-0797 +CVE-2016-2105 +CVE-2016-2176 +CVE-2016-2180 +CVE-2016-2182 +CVE-2016-2160 +0 +0 +0 +0 +29 +0 +1 +1 +3 +1 +29 +0 +1 +1 +3 +1 +29 +0 +1 +1 +3 +1 +29 +0 +0 +0 +3 +0 +22 +0 +0 +0 +0 +0 +5 +0 +1 +1 +3 +1 +9 +0 +1 +1 +3 +1 +29 +0 +0 +0 +0 +0 +29 +0 +0 +0 +0 +0 +29 +0 +0 +0 +0 +0 +29 +1 +0 +0 +0 +0 +29 +1 +0 +0 +0 +0 +29 +1 +0 +0 +0 +0 +29 +1 +0 +0 +0 +0 +2 +0 +0 +0 +0 +0 +29 +0 +0 +5 +10 +15 +20 +25 +(b) TP-Link +1.0.1e +1.0.1l +CVE-2013-0166 +CVE-2014-3508 +CVE-2014-8275 +CVE-2015-0286 +CVE-2015-0287 +CVE-2015-0288 +CVE-2015-0289 +CVE-2015-0292 +CVE-2015-1788 +CVE-2015-1790 +CVE-2016-0797 +CVE-2016-2105 +CVE-2016-2176 +CVE-2016-2180 +CVE-2016-2182 +CVE-2016-2160 +14 +0 +4 +0 +14 +0 +14 +38 +14 +38 +4 +23 +14 +38 +14 +0 +14 +38 +14 +38 +14 +38 +14 +38 +14 +33 +14 +38 +4 +13 +4 +28 +0 +5 +10 +15 +20 +25 +30 +35 +(c) Hikvision +Fig. 13. The Distribution of CVEs for Different OpenSSL Versions in vendors Netgear, TP-Link, Hikvision from left to right. +vulnerable functions rank second. 𝑉𝑂2 is performed on 47 detection results, of which 26 are confirmed. Since they +contain the majority of functions, three vendors, Netgear, Tp-Link, and Hikvision, account for the vast majority (94.4%) +of vulnerable functions. Specifically, a large proportion of vulnerable functions are found in the OpenSSL software used +by the three vendors. The number of vulnerable software is consistent with this circumstance. The final column shows +the number of firmware containing at least one vulnerable function, together with its proportion of total firmware. +Every Dajiang firmware contains at least one CVE vulnerability because all OpenSSL components used in firmware are +vulnerable. In addition, Hikvision is detected to have a large proportion of vulnerable firmware (58.89%). To inspect the +CVE vulnerable function distribution, we plot the top 10 CVEs and their distributions in five vendors except Cisco in +Figure 12, since Cisco takes additional two CVEs. +• Top 10 CVE Analysis. Figure 12 demonstrates the top 10 CVE distribution in various vendors. The total number +of discovered CVE vulnerabilities decreases from left to right along the x-axis. Except for CVE-2015-0287, all +of the top 10 CVE vulnerabilities are discovered in every Dajiang firmware. This is because Dajiang utilizes +an outdated version of OpenSSL 1.0.1h that contains numerous vulnerable functions [12]. Although Hikvision +firmware has the third largest number of firmware, it has the most vulnerable functions in our experiment +settings. The reason for this is that Hikvision firmware heavily uses OpenSSL-1.0.1e (184) and OpenSSL-1.0.1l +(401) versions, both of which contain a large number of vulnerabilities. Finding: Since they typically adopt the +same vulnerable software version, it is highly plausible that firmware from the same vendor and released at +the same period contains identical vulnerabilities. Security analysts can quickly narrow down the vulnerability +analysis based on the firmware release date. +• CVE and Version Analysis. Figure 13 depicts the distribution of vulnerable OpenSSL versions for various +CVEs from various vendors. where the x-axis represents the version and the y-axis represents the CVE ID +associated with the vulnerability. Each square in each subfigure indicates the number of OpenSSL versions that +are vulnerable and contain the corresponding CVE along the y-axis. The number is greater the lighter the red +colour. The left subfigure demonstrates that OpenSSL 1.0.2h is widely used by Netgear, resulting in a significant +number of CVE-2016-2180 vulnerabilities (92). Additionally, OpenSSL version 1.0.1e exposes the majority of +CVEs listed on the y-axis, which may increase the device’s attack surface. The TP-Link firmware incorporates +Manuscript submitted to ACM + +Asteria-Pro +27 +OpenSSL version 1.0.1e, resulting in brighter hues. Hikvision firmware utilizes versions 1.0.1e and 1.0.1l, which +are vulnerable to a number of CVEs. Comparing vulnerability distribution in OpenSSL version 1.0.1e among +different vendors reveals inconsistencies in the existence of vulnerabilities. For instance, CVE-2016-2106 is +present in OpenSSL 1.0.1e from Hikvision but not from Netgear and TP-Link. Finding: Despite using the same +version of software, various vendor firmware behaves differently in terms of vulnerability since they can tailor +the software to the device’s specific capabilities. +• CVE-2016-2180 Analysis. The CVE-2016-2180, which is a remote Denial-of-Service flaw caused by received +forged time-stamp file, impacting OpenSSL 1.0.1 through 1.0.2h, exists in 207 firmware. NETGEAR is responsible +for 117 of these, as it deploys 92 OpenSSL 1.0.2h out of a total of 548 firmware. NETGEAR incorporated an +extra nine OpenSSL 1.0.2 series software and sixteen OpenSSL 1.0.1 series software. The vulnerable version +1.0.2h was released in May 2016, and by comparing their timestamps, we determined that OpenSSL 1.0.2h was +integrated into firmware between 2016 and 2019. Finding: Even after their vulnerabilities have been discovered, +the vulnerable versions of software continue to be used for firmware development. +Based on the confirmation results, Asteria-Pro manages to detect 1,482 vulnerable functions out of 1617 bug +search results, indicating that Asteria-Pro achieves a high vulnerability detection precision of 91.65% under our +experiment settings. By randomly selecting 1,000 of 5,604 bug search results, we manually validate the existence of +vulnerabilities in software binaries in order to calculate the recall. Among 1000 bug search results, 205 target function +are confirmed to be vulnerable by checking software versions and the vulnerable functions. Targeting 205 vulnerable +functions, Asteria-Pro detects 53 of them, representing a recall rate of 25.85%. +Finding Inlined Vulnerable Code. During the analysis of mismatched cases, in which the target homologous +functions are not in the top ranking position, we observe that the top-ranked functions contain the same vulnerable +code. We use CVE-2017-13001 as an illustration of inlined vulnerable code detection. CVE-2017-13001 is a buffer +over-read vulnerability in the Tcpdump nfs_printfh function prior to version 4.9.2. After a confirmation operation +𝐶𝑂2, Asteria-Pro reports a single function, parsefh as being vulnerable. We manually compare the decompiled +code of the parsefh function to the source code of nfs_printfh in tcpdump version 4.9.1 (i.e., vulnerable version). +Figure 14 demonstrates that the source code of nfs_printfh (on the left) and the partial code of parsefh (on the right) +are consistent. We designate codes with apparently identical semantics with distinct backdrop hues. In other words, +during compilation, function nfs_printfh is inlined into function parsefh. As a result, the function parsefh contains +CVE-2017-13001 vulnerable code, and Asteria-Pro manages to identify the inlined vulnerable code. Asteria-Pro +has detected an additional eight instances of inlined vulnerable code out of 20 functions in vulnerable circumstance +𝑉𝐶2. +The preceding analysis and conclusions are constrained by the dataset we constructed, which offers security analysts +some recommendations for the security analysis of firmware. +Answer to RQ4. We employ 90 CVE vulnerabilities to search for bugs in 3,483,136 real firmware functions. +Asteria-Pro detects 1,482 vulnerable functions with a high level of precision of 91.65%. In addition, the +capability of Asteria-Pro to identify inlined vulnerable code is stated and illustrated in detail. In conclusion, +Asteria-Pro generates bug search results with a high degree of confidence, thereby reducing analysis labor +by a substantial margin. +Manuscript submitted to ACM + +28 +Shouguo Yang, Chaopeng Dong, and Yang Xiao, et al. +1 +{ +2 +... +3 +if (ndo ->ndo_uflag) { +4 +u_int i; +5 +char const *sep = ""; +6 +ND_PRINT((ndo, " fh[")); +7 +for (i=0; i