Skip to main content
QUICK REVIEW

[Paper Review] Symbol Preference Aware Generative Models for Recovering Variable Names from Stripped Binary

Xiangzhe Xu, Zhuo Zhang|arXiv (Cornell University)|Jun 5, 2023
Topic ModelingComputer Science3 citations
TL;DR

This paper proposes LmPa, a novel method that synergizes large language models (LLMs) with program analysis to recover meaningful variable names from stripped binaries. By iteratively querying LLMs with contextually enriched program fragments and propagating results via static analysis, LmPa improves name recovery precision and recall by 16.5% and 20.23% over the state of the art, achieving 75% user-considered 'good' names.

ABSTRACT

Decompilation aims to recover the source code form of a binary executable. It has many security applications, such as malware analysis, vulnerability detection, and code hardening. A prominent challenge in decompilation is to recover variable names. We propose a novel technique that leverages the strengths of generative models while mitigating model biases. We build a prototype, GenNm, from pre-trained generative models CodeGemma-2B, CodeLlama-7B, and CodeLlama-34B. We finetune GenNm on decompiled functions and teach models to leverage contextual information. GenNm includes names from callers and callees while querying a function, providing rich contextual information within the model's input token limitation. We mitigate model biases by aligning the output distribution of models with symbol preferences of developers. Our results show that GenNm improves the state-of-the-art name recovery precision by 5.6-11.4 percentage points on two commonly used datasets and improves the state-of-the-art by 32% (from 17.3% to 22.8%) in the most challenging setup where ground-truth variable names are not seen in the training dataset.

Motivation & Objective

  • To address the critical challenge of variable name recovery in decompiled binaries, where existing methods suffer from limited context and poor performance.
  • To overcome the input length constraints of LLMs by decomposing the name recovery task into multiple context-aware queries.
  • To enhance LLM performance by iteratively propagating and refining name predictions using program semantics and static analysis.
  • To demonstrate that synergy between LLMs and program analysis significantly outperforms standalone LLM-based or rule-based approaches.
  • To validate the method’s robustness and generalization through user studies and ablation on diverse binaries.

Proposed method

  • The method divides a binary function into multiple contextually relevant fragments to fit LLM input limits, enabling focused name prediction.
  • It employs a multi-iteration process where LLM predictions are propagated and refined using control-flow and data-flow analysis to maintain semantic consistency.
  • Program analysis is used to correlate variable usages across fragments, ensuring that names are consistently applied across the function’s scope.
  • The system uses a feedback loop: LLM predictions inform static analysis, which in turn provides enriched context for subsequent LLM queries.
  • It leverages pre-trained LLMs like GPT-4 and ChatGPT, prompting them with code snippets and program context to generate semantically plausible variable names.
  • The approach supports both function-level and cross-function name recovery by analyzing call graphs and parameter passing.
Figure 1 . Motivating example
Figure 1 . Motivating example

Experimental results

Research questions

  • RQ1Can the synergy between LLMs and program analysis significantly improve variable name recovery in decompiled binaries?
  • RQ2How does context-aware decomposition and iterative propagation affect the quality of recovered variable names?
  • RQ3To what extent does program analysis enhance LLM performance when input context is limited?
  • RQ4How does LmPa compare to the state-of-the-art DIRTY method in terms of precision and recall for variable name recovery?
  • RQ5Does the performance of LmPa generalize across diverse binaries, including those not seen during LLM pre-training?

Key findings

  • LmPa achieves 75% of recovered variable names rated as 'good' by human evaluators in a user study, indicating strong human interpretability.
  • With GPT-4, LmPa improves precision by 16.5% and recall by 20.23% over the state-of-the-art DIRTY method on the benchmark dataset.
  • The method demonstrates stable performance across multiple LLMs, including GPT-4 and ChatGPT, with consistent gains in both metrics.
  • Ablation studies confirm that iterative propagation and program analysis significantly boost LLM performance, especially in complex binaries.
  • The method remains effective even on recently compiled binaries not likely present in LLM training data, indicating generalization beyond memorization.
  • User study results show that LmPa’s output is significantly more readable and semantically accurate than baseline methods.
Figure 4 . Three rounds of interactions with ChatGPT. Round 1’s query is partially shown in Fig. 3 . Each box shows a function with symbols renamed according to ChatGPT’s response. Red circles show the numbers of rounds. Red arrows and boxes indicate how LmPa uses information from previous response
Figure 4 . Three rounds of interactions with ChatGPT. Round 1’s query is partially shown in Fig. 3 . Each box shows a function with symbols renamed according to ChatGPT’s response. Red circles show the numbers of rounds. Red arrows and boxes indicate how LmPa uses information from previous response

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.