一句话:提出 LeanBin,结合动态执行轨迹与无启发式静态分析进行二进制提升和重编译,实现应用及共享库的去膨胀与特化。
为减少潜在攻击面,二进制去膨胀/特化工具会移除不必要代码。本文提出 LeanBin,结合动态执行轨迹与无启发式静态分析进行二进制提升和重编译。它先记录给定输入下必需的指令与控制流,再用静态分析扩展控制流以避免过度限制输入空间;然后结构化控制流,将二进制指令翻译为 C 子集并重新编译得到 LLVM IR 和精简二进制。该方法可同时处理应用与共享库,且不依赖静态提升器可能不健全的启发式,也避免了动态提升器执行时间过长的问题。在 SPEC CPU2006 INT 上,提升与去膨胀几何平均耗时为原生 1.78 倍,精简二进制运行开销 1.21 倍,gadget 降至 24.10%–30.22%,代码大小最低 53.59%;SQLite 案例运行最高快 1.24 倍,gadget 仅 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×, normalized to the native execution, and the debloated binary runs with a geomean overhead of 1.21×. 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× faster with 3.65% gadgets.