Skip to main content
QUICK REVIEW

[Paper Review] Trex: Learning Execution Semantics from Micro-Traces for Binary Similarity

Kexin Pei, Xuan Zhou|arXiv (Cornell University)|Dec 16, 2020
Advanced Malware Detection TechniquesComputer Science73 references35 citations
TL;DR

Trex learns execution semantics from under-constrained micro-traces via pretraining with masked LM and a hierarchical Transformer, then finetunes to match semantically similar functions across architectures, optimizations, and obfuscations with improved accuracy and speed.

ABSTRACT

Detecting semantically similar functions -- a crucial analysis capability with broad real-world security usages including vulnerability detection, malware lineage, and forensics -- requires understanding function behaviors and intentions. This task is challenging as semantically similar functions can be implemented differently, run on different architectures, and compiled with diverse compiler optimizations or obfuscations. Most existing approaches match functions based on syntactic features without understanding the functions' execution semantics. We present Trex, a transfer-learning-based framework, to automate learning execution semantics explicitly from functions' micro-traces and transfer the learned knowledge to match semantically similar functions. Our key insight is that these traces can be used to teach an ML model the execution semantics of different sequences of instructions. We thus train the model to learn execution semantics from the functions' micro-traces, without any manual labeling effort. We then develop a novel neural architecture to learn execution semantics from micro-traces, and we finetune the pretrained model to match semantically similar functions. We evaluate Trex on 1,472,066 function binaries from 13 popular software projects. These functions are from different architectures and compiled with various optimizations and obfuscations. Trex outperforms the state-of-the-art systems by 7.8%, 7.2%, and 14.3% in cross-architecture, optimization, and obfuscation function matching, respectively. Ablation studies show that the pretraining significantly boosts the function matching performance, underscoring the importance of learning execution semantics.

Motivation & Objective

  • Motivate semantic function similarity for security tasks like vulnerability detection, malware tracing, and forensics.
  • Address cross-architecture and cross-optimization challenges by learning execution semantics from micro-traces.
  • Develop a pretrained model that captures instruction-level execution effects and transfer it to function similarity tasks.

Proposed method

  • Pretrain a hierarchical Transformer on micro-traces derived from under-constrained dynamic execution using a masked language modeling objective.
  • Represent micro-traces with five input sequences capturing code tokens, dynamic values, instruction positions, operand positions, and architecture, including a value-encoding bi-LSTM for 8-byte values.
  • Train the model to predict masked code tokens and 8-byte dynamic values to learn approximate execution semantics.
  • Finetune by stacking a small MLP atop the pretrained model to produce function embeddings and optimize a cosine-based similarity objective.
  • During inference, compute function embeddings and measure semantic similarity via cosine similarity without needing on-the-fly execution.

Experimental results

Research questions

  • RQ1Can under-constrained micro-traces be used to learn approximate execution semantics that transfer to cross-architecture, cross-optimization, and cross-obfuscation function matching?
  • RQ2Does pretraining with micro-traces improve semantic function similarity beyond static code-based approaches?
  • RQ3Does the hierarchical Transformer efficiently model long execution traces across architectures to enable scalable binary similarity search?

Key findings

  • Trex outperforms state-of-the-art systems by 7.8% in cross-architecture function matching, 7.2% in cross-optimization matching, and 14.3% in cross-obfuscation matching.
  • Trex runs up to 8× faster than prior neural architectures for function matching.
  • Pretraining with the micro-trace masked LM task boosts matching accuracy by 15.7% in ablation studies.
  • Evaluations cover 1,472,066 functions from 13 projects across x86, x64, ARM, and MIPS with four optimizations and five obfuscations.
  • Case studies on 180 real-world firmware images reveal 16 undisclosed CVEs uncovered by Trex.

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.