WaDec:使用大语言模型反编译WebAssembly
WaDec: Decompiling WebAssembly Using Large Language Model
AI总结:
针对Wasm二进制代码反编译可读性差的问题,提出基于微调LLM的WaDec方法,使用wat-c数据集自监督训练,在多项指标上显著优于现有最先进工具。
摘要:
WebAssembly(缩写为Wasm)已成为Web开发的基石,它提供了一种紧凑的二进制格式,使高性能应用程序能够在Web浏览器中以接近原生的速度运行。尽管具有诸多优势,Wasm的二进制特性给开发者和研究人员带来了重大挑战,尤其是在调试或分析Web应用程序时的可读性方面。因此,有效的反编译变得至关重要。遗憾的是,传统反编译器往往难以生成具有可读性的输出。虽然一些基于大语言模型(LLM)的反编译器已表现出对通用二进制文件的良好兼容性,但它们在处理Wasm时仍面临特定挑战。\n在本文中,我们提出了一种新颖的方法WaDec,这是首次使用经过微调的LLM将Wasm二进制代码解释并反编译为更高级、更易理解的源代码表示形式。我们使用专门的wat-c代码片段数据集,采用自监督学习技术对LLM进行了精细的微调。这使得WaDec不仅能够有效反编译完整的wat函数,还能反编译更细粒度的wat代码片段。\n我们的实验表明,WaDec显著优于当前最先进的工具,在多项指标上实现了大幅提升。它的代码膨胀率仅为3.34%,与最先进工具的116.94%相比大幅降低了97%。与基线方法无法直接编译或执行的输出不同,WaDec保持了52.11%的可重编译率、43.55%的可重执行率以及27.15%的输出一致性。此外,它在AST编辑距离相似度上比最先进性能高出185%,圈复杂度高出8%,余弦相似度高出41%,平均代码相似度超过50%。
英文摘要:
WebAssembly (abbreviated Wasm) has emerged as a cornerstone of web development, offering a compact binary format that allows high-performance applications to run at near-native speeds in web browsers. Despite its advantages, Wasm's binary nature presents significant challenges for developers and researchers, particularly regarding readability when debugging or analyzing web applications. Therefore, effective decompilation becomes crucial. Unfortunately, traditional decompilers often struggle with producing readable outputs. While some large language model (LLM)-based decompilers have shown good compatibility with general binary files, they still face specific challenges when dealing with Wasm. In this paper, we introduce a novel approach, WaDec, which is the first use of a fine-tuned LLM to interpret and decompile Wasm binary code into a higher-level, more comprehensible source code representation. The LLM was meticulously fine-tuned using a specialized dataset of wat-c code snippets, employing self-supervised learning techniques. This enables WaDec to effectively decompile not only complete wat functions but also finer-grained wat code snippets. Our experiments demonstrate that WaDec markedly outperforms current state-of-the-art tools, offering substantial improvements across several metrics. It achieves a code inflation rate of only 3.34%, a dramatic 97% reduction compared to the state-of-the-art's 116.94%. Unlike baselines' output that cannot be directly compiled or executed, WaDec maintains a recompilability rate of 52.11%, a re-execution rate of 43.55%, and an output consistency of 27.15%. Additionally, it significantly exceeds state-of-the-art performance in AST edit distance similarity by 185%, cyclomatic complexity by 8%, and cosine similarity by 41%, achieving an average code similarity above 50%.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。