"Len or index or count, anything but v1": Predicting Variable Names in Decompilation Output with Transfer Learning - Pal, Kuntal Kumar; Bajaj, Ati Priya; Banerjee, Pratyay; Dutcher, Audrey; Nakamura, Mutsumi; Basque, Zion Leonahenahe; Gupta, Himanshu; Sawant, Saurabh Arjun; Anantheswaran, Ujjwala; Shoshitaishvili, Yan; Doupe, Adam; Baral, Chitta; et al. (Proceedings - IEEE Symposium on Security and Privacy, 2024)
Binary reverse engineering is an arduous and tedious task performed by skilled and expensive human analysts. Information about the source code is irrevocably lost in the compilation process. While modern decompilers attempt to generate C-style source code from a binary, they cannot recover lost variable names. Prior works have explored machine learning techniques for predicting variable names in decompiled code. However, the state-of-the-art systems, DIRE and DIRTY, generalize poorly to functions in the testing set that are not included in the training set-31.8% for DIRE on DIRTY's data set and 36.9% for DIRTY on DIRTY's data set.In this paper, we present VarBERT, a Bidirectional Encoder Representations from Transformers (BERT) to predict meaningful variable names in decompilation output. An advantage of VarBERT is that we can pre-train on human source code and then fine-tune the model to the task of predicting variable names. We also create a new data set VarCorpus, which significantly expands the size and variety of the data set. Our evaluation of VarBERT on VarCorpus, demonstrates a significant improvement in predicting the developer's original variable names for O2 optimized binaries achieving accuracies of 54.43% for IDA and 54.49% for Ghidra. VarBERT is strictly better than state-of-the-art techniques: On a subset of VarCorpus, VarBERT could predict the developer's original variable names 50.70% of the time, while DIRE and DIRTY predicted original variable names 35.94% and 38.00% of the time, respectively.