NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Unsupervised Binary Code Translation with Application to Code Clone Detection and Vulnerability Discovery

Iftakhar Ahmad, Lannan LuoEMNLP 2023

Introduction

Binary code analysis is a critical component of modern software security, enabling researchers to identify vulnerabilities and detect intellectual property theft without access to source code. However, the effectiveness of deep learning-based analysis tools is heavily dependent on the availability of large-scale labeled datasets. This creates a significant "wealth gap" in the field: while high-resource architectures like x86 benefit from extensive datasets, low-resource architectures common in Internet of Things (IoT) devices, such as ARM and MIPS, suffer from a severe lack of labeled training data.

To bridge this gap, Ahmad and Luo (2023) introduced UNSUPERBINTRANS, a framework designed to translate binary code from low-resource Instruction Set Architectures (ISAs) to high-resource ones. By converting ARM code into x86, security analysts can leverage mature x86-based models to analyze binaries from entirely different architectures without the need for expensive, manually labeled datasets for every new chip.

The UNSUPERBINTRANS Framework

The core philosophy of UNSUPERBINTRANS is to treat assembly code as a language and binary translation as an unsupervised machine translation problem. The framework operates through a three-stage pipeline: preprocessing, embedding alignment, and unsupervised neural machine translation (NMT).

Preprocessing and Normalization

Assembly code is notoriously difficult for standard NMT models due to the presence of architecture-specific memory addresses, constants, and labels. These elements often act as Out-of-Vocabulary (OOV) words that appear only once, hindering the model's ability to learn general patterns. To address this, the authors implement a normalization step where specific values are replaced with generic tags.

Figure 3: Preprocessing assembly code by replacing specific constants, addresses, and tags with generic placeholders to reduce OOV issues.

As shown in Figure 3, this process allows the model to focus on the underlying logic (opcodes) rather than specific, non-repeating operands.

Cross-Architecture Instruction Embeddings (CAIE)

To facilitate translation, the system must understand the semantic relationship between different ISAs. Using fastText, the researchers first generate embeddings for instructions within individual ISAs. They then employ vecmap to mathematically align these separate vector spaces into a shared cross-architecture space. This ensures that semantically similar operations—such as a "jump" in ARM and a "jump" in x86—are positioned near each other in the embedding space.

Unsupervised Neural Machine Translation

The translation engine itself is a Transformer-based encoder-decoder model. Unlike traditional translation models that require parallel corpora (matching pairs of ARM and x86 code), UNSUPERBINTRANS is entirely unsupervised. It learns the translation mapping through two primary mechanisms:

  1. Denoising Auto-encoding: The model learns to reconstruct original code from versions that have been intentionally corrupted (e.g., by swapping or deleting instructions).
  2. Backtranslation: The model translates a sequence from ARM to x86 and then back to ARM, optimizing for the preservation of the original semantic meaning.
Figure 2: The UNSUPERBINTRANS architecture, featuring a shared encoder and dual decoders for cross-architecture translation and analysis.

The overall architecture, illustrated in Figure 2, allows the shared encoder to capture universal logic while the decoders handle the specific syntax of the target ISA.

Experimental Evaluation

The researchers evaluated UNSUPERBINTRANS using popular open-source packages like binutils, coreutils, and OpenSSL, compiled for both x86 and ARM across four optimization levels (O0 to O3).

Translation Quality and Code Similarity

The framework achieved impressive translation quality, with BLEU scores ranging between 0.76 and 0.77. In code clone detection tasks—determining if two binaries were compiled from the same source—the model reached an accuracy of 95.3% when using fastText embeddings at the O2 optimization level. This demonstrates that the translation process preserves the essential logic of the original program.

Vulnerability Discovery

The most significant test of the framework was its application to vulnerability discovery. The authors attempted to detect the "Heartbleed" vulnerability (CVE-2014-0160) and other major CVEs in ARM binaries. By translating the ARM code to x86 and utilizing an x86-trained Support Vector Machine (SVM), UNSUPERBINTRANS achieved a 100% True Positive Rate. Remarkably, this performance was on par with baseline models trained directly on ARM data, proving that the "translate-and-analyze" approach is a viable alternative to architecture-specific training.

Conclusion and Future Directions

UNSUPERBINTRANS represents a significant step forward in cross-architecture binary analysis. By leveraging the abundance of x86 data, it provides a scalable solution for securing the diverse and rapidly growing IoT ecosystem. While the current work focuses on x86 and ARM, future research may extend this approach to more specialized architectures and explore finer granularities of code representation to further improve translation accuracy for complex, architecture-specific logic.

Reference: Ahmad, I., & Luo, L. (2023). Unsupervised Binary Code Translation with Application to Code Similarity Detection and Vulnerability Discovery. Findings of the Association for Computational Linguistics: EMNLP 2023.

Summary updated

BibTeX
@inproceedings{ahmad2023unsupervised,
  author = {Iftakhar Ahmad and Lannan Luo},
  title = {{Unsupervised Binary Code Translation with Application to Code Clone Detection and Vulnerability Discovery}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  doi = {10.18653/v1/2023.findings-emnlp.971},
}
Figure