Skip to main content
QUICK REVIEW

[Paper Review] Towards Neural Decompilation

Omer Katz, Yuval Olshaker|arXiv (Cornell University)|May 20, 2019
Adversarial Robustness in Machine LearningComputer Science28 references8 citations
TL;DR

This paper presents a neural machine translation-based approach to automatic decompilation, training a decompiler from a compiler's forward translation to reverse low-level code (LLVM IR or x86 assembly) into human-readable C code. The method achieves 97% and 88% success rates on benchmarks for LLVM and x86, respectively, significantly outperforming prior rule-based systems by leveraging learned patterns rather than hand-crafted rules.

ABSTRACT

We address the problem of automatic decompilation, converting a program in low-level representation back to a higher-level human-readable programming language. The problem of decompilation is extremely important for security researchers. Finding vulnerabilities and understanding how malware operates is much easier when done over source code. The importance of decompilation has motivated the construction of hand-crafted rule-based decompilers. Such decompilers have been designed by experts to detect specific control-flow structures and idioms in low-level code and lift them to source level. The cost of supporting additional languages or new language features in these models is very high. We present a novel approach to decompilation based on neural machine translation. The main idea is to automatically learn a decompiler from a given compiler. Given a compiler from a source language S to a target language T , our approach automatically trains a decompiler that can translate (decompile) T back to S . We used our framework to decompile both LLVM IR and x86 assembly to C code with high success rates. Using our LLVM and x86 instantiations, we were able to successfully decompile over 97% and 88% of our benchmarks respectively.

Motivation & Objective

  • To address the high cost and inflexibility of traditional rule-based decompilers that require expert intervention for each new language or feature.
  • To enable automatic decompiler generation from any existing compiler, reducing manual effort in decompiler development.
  • To improve decompiled code quality by producing semantically equivalent, human-readable C code without excessive use of goto statements or low-level constructs.
  • To overcome limitations of prior neural decompilation approaches that failed to compile or semantically match original code due to lack of domain-specific knowledge.

Proposed method

  • The framework uses a two-phase approach: first generating a structural code template that preserves control-flow and syntax structure without variable or constant assignments.
  • In the second phase, the template is filled with actual values using a neural sequence-to-sequence model trained on compiler-generated source-to-assembly pairs.
  • The method leverages a compiler's forward translation to implicitly learn the inverse mapping, enabling end-to-end training of a decompiler without direct decompilation supervision.
  • Domain-specific knowledge is integrated by using compiler-optimized, semantically equivalent code pairs to improve generalization and correctness.
  • The model employs sequence-to-sequence neural networks with attention mechanisms, similar to neural machine translation, adapted for programming language syntax and semantics.
  • Training data is constructed from compiler outputs, ensuring no overlap between training and test sets, and benchmarks include complex, multi-statement programs up to 668 input tokens.

Experimental results

Research questions

  • RQ1Can a neural machine translation model be effectively adapted to decompile low-level code into high-level source code with high accuracy?
  • RQ2Can a decompiler be automatically learned from a compiler’s forward translation, eliminating the need for hand-crafted rules?
  • RQ3Does incorporating domain knowledge from compiler-optimized code improve the quality and compile-time correctness of decompiled output?
  • RQ4How does the performance of a neural decompiler compare to traditional rule-based decompilers on complex, real-world code snippets?
  • RQ5Can the framework generalize across different low-level representations, such as LLVM IR and x86 assembly, using the same training paradigm?

Key findings

  • The framework successfully decompiled 97% of LLVM IR benchmarks into semantically equivalent C code, demonstrating high accuracy on a diverse set of test cases.
  • For x86 assembly, the decompiler achieved an 88% success rate, significantly outperforming prior neural approaches that struggled with compilation and correctness.
  • The model produced decompiled code that was free of goto statements and used high-level language constructs, making it more readable and recompilable than traditional decompilers.
  • The approach eliminated the need for expert rule engineering by learning from compiler-generated pairs, enabling rapid adaptation to new languages or targets.
  • The framework outperformed prior neural decompilation methods by incorporating domain-specific knowledge and avoiding data leakage through strict train-test separation.
  • The method successfully handled complex programs with up to 668 input tokens and 177 output tokens, far exceeding the single-statement limits of earlier work.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.