LeanBin:利用提升与重编译实现二进制代码瘦身
LeanBin: Harnessing Lifting and Recompilation to Debloat Binaries
AI总结:
本研究提出二进制瘦身工具LeanBin,结合无启发式静态分析与动态执行轨迹,通过代码提升和重编译实现应用及共享库瘦身,在缩减代码体积与攻击面的同时控制运行开销。
摘要:
为减少潜在漏洞利用的来源,二进制代码瘦身(或称特化)工具被用于移除二进制文件中的不必要代码。本文提出了一种新型二进制代码瘦身与特化工具LeanBin,该工具基于观测到的执行轨迹,利用代码提升与重编译技术实现功能。动态记录的执行轨迹捕获了给定输入集下应用二进制文件所需的指令子集与控制流。随后,通过无启发式的静态分析对这一初始控制流进行扩充,避免对输入空间造成过度限制。通过对控制流进行进一步结构化处理,并将二进制指令翻译为C语言子集,可轻量生成能够重编译的代码,进而得到LLVM IR(中间表示)与全新的瘦身二进制文件。与大多数瘦身方法不同,LeanBin可同时实现应用程序与共享库的二进制瘦身,同时复用现有编译器基础设施。此外,与现有二进制提升工具不同,它不依赖静态提升工具所使用的可能不可靠的启发式方法,也不存在现有动态提升工具执行时间过长的局限。相反,LeanBin结合了无启发式的静态分析与动态分析。对SPEC CPU2006 INT基准测试程序进行提升与瘦身的运行时间,以原生执行时间为基准归一化后的几何均值为1.78倍,瘦身後的二进制文件运行时的几何均值开销为1.21倍。与原始二进制文件相比, gadgets(代码小工具)占比的几何均值在24.10%到30.22%之间,具体取决于所采用的瘦身策略;代码体积最低可降至原始的53.59%。在SQLite用例中,LeanBin对包含其共享库的二进制文件进行瘦身,生成的瘦身二进制文件运行速度最高提升1.24倍,gadgets占比仅为3.65%。
英文摘要:
To reduce the source of potential exploits, binary debloating or specialization tools are used to remove unnecessary code from binaries. This paper presents a new binary debloating and specialization tool, LeanBin, that harnesses lifting and recompilation, based on observed execution traces. The dynamically recorded execution traces capture the required subset of instructions and control flow of the application binary for a given set of inputs. This initial control flow is subsequently augmented using heuristic-free static analysis to avoid excessively restricting the input space. The further structuring of the control flow and translation of binary instructions into a subset of C enables a lightweight generation of the code that can be recompiled, obtaining LLVM IR and a new debloated binary. Unlike most debloating approaches, LeanBin enables both binary debloating of the application and shared libraries, while reusing the existing compiler infrastructure. Additionally, unlike existing binary lifters, it does not rely on potentially unsound heuristics used by static lifters, nor suffers from long execution times, a limitation of existing dynamic lifters. Instead, LeanBin combines both heuristic-free static and dynamic analysis. The run time of lifting and debloating SPEC CPU2006 INT benchmarks has a geomean of 1.78$\times$, normalized to the native execution, and the debloated binary runs with a geomean overhead of 1.21$\times$. The percentage of gadgets, compared to the original binary, has a geomean between 24.10% and 30.22%, depending on the debloating strategy; and the code size can be as low as 53.59%. For the SQLite use-case, LeanBin debloats a binary including its shared library and generates a debloated binary that runs up to 1.24$\times$ faster with 3.65% gadgets.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。