[Paper Review] Improving type information inferred by decompilers with supervised machine learning
This paper proposes a supervised machine learning approach to improve type inference in decompilers by training models on a large dataset of C source code and corresponding binaries. By instrumenting code to label binary patterns with high-level type information, the system achieves a 79.1% F1-score in predicting function return types—significantly outperforming existing decompilers (30% F1-score), while also documenting actionable binary patterns for decompiler integration.
In software reverse engineering, decompilation is the process of recovering source code from binary files. Decompilers are used when it is necessary to understand or analyze software for which the source code is not available. Although existing decompilers commonly obtain source code with the same behavior as the binaries, that source code is usually hard to interpret and certainly differs from the original code written by the programmer. Massive codebases could be used to build supervised machine learning models aimed at improving existing decompilers. In this article, we build different classification models capable of inferring the high-level type returned by functions, with significantly higher accuracy than existing decompilers. We automatically instrument C source code to allow the association of binary patterns with their corresponding high-level constructs. A dataset is created with a collection of real open-source applications plus a huge number of synthetic programs. Our system is able to predict function return types with a 79.1% F1-measure, whereas the best decompiler obtains a 30% F1-measure. Moreover, we document the binary patterns used by our classifier to allow their addition in the implementation of existing decompilers.
Motivation & Objective
- To improve the accuracy of type information inferred by decompilers, particularly for function return types.
- To address the challenge of recovering high-level type semantics from binary code, which is inherently lossy due to compiler optimizations.
- To create a large-scale, labeled dataset of binary patterns paired with high-level type information for training ML models.
- To identify and document reusable binary patterns that distinguish between types of the same size and representation.
- To enable integration of learned patterns into existing decompilers to enhance their reverse engineering capabilities.
Proposed method
- Instrumenting C source code to associate binary machine code patterns with high-level type constructs such as int, float, bool, and struct.
- Generating a dataset combining real open-source C applications and synthetic programs compiled with Microsoft Visual C++ for 32-bit Windows.
- Training multiple supervised classification models—particularly gradient boosting—on binary opcode sequences and post-call instruction patterns to predict return types.
- Using feature engineering to extract RET (return) and POST CALL (post-call) patterns that encode how values are passed back to the caller.
- Applying rule-based pattern extraction to identify high-confidence, specific binary instruction sequences that correspond to particular types.
- Validating models on unseen code to ensure generalization beyond training data, using F1-score as the primary evaluation metric.
Experimental results
Research questions
- RQ1Can supervised machine learning improve the accuracy of function return type inference in decompilers beyond current state-of-the-art tools?
- RQ2What specific binary opcode patterns correlate with distinct high-level types such as int, float, bool, and struct?
- RQ3How do RET and POST CALL instruction patterns contribute to distinguishing between types of the same size and representation?
- RQ4Can the learned patterns be generalized and reused to enhance existing decompilers?
- RQ5How does model performance vary across different types, especially when they share the same binary size and representation?
Key findings
- The proposed system achieves a 79.1% F1-score in predicting function return types on unseen code, significantly outperforming the best existing decompiler, which achieves only 30% F1-score.
- Gradient boosting was the most effective classification algorithm for this task, outperforming other models such as random forests and XGBoost.
- The system identified high-confidence binary patterns—such as specific sequences of opcodes and post-call instruction usage—that distinguish between types like float and double, or bool and int.
- Combining RET and POST CALL patterns increased classification confidence, with one rule achieving 100% confidence by incorporating both sequences.
- The method successfully identified and documented code generation templates used by the Microsoft C compiler, such as those for returning structs via pointer and comparison results as integers.
- The dataset and patterns are publicly released, enabling direct integration into existing decompilers to improve type inference.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.