论文标题
不太快:理解和减轻编译器优化对代码重用小工具集的负面影响
Not So Fast: Understanding and Mitigating Negative Impacts of Compiler Optimizations on Code Reuse Gadget Sets
论文作者
论文摘要
尽管对其功能语义进行了广泛的测试和正确性认证,但已证明许多编译器优化违反了源代码中实施的安全保证。虽然先前的工作已经阐明了这种优化如何将语义安全弱点引入程序中,但关于编译器优化对非语义性属性的影响以及安全含义的影响仍然存在很大的知识差距。特别是,目前,关于编译器做出的代码生成和优化决策如何影响可重复使用的代码段的可用性和实用性,该段称为“实施代码重复使用攻击方法”,例如以返回为导向的编程所需的可用性和实用性。 在本文中,我们通过研究编译器优化对代码重用小工具集的影响的研究来弥合这一差距。我们分析并比较了使用两个生产编译器(GCC和Clang)构建的20种不同基准程序的1,187个变体,以确定其优化行为如何影响程序变体中有关定量和定性指标的代码重复使用小工具集。我们的研究暴露了一个重要的意外问题。编译器优化以高速率介绍新小工具,并制作包含小工具集的代码,这些小工具集通常比不优化代码的攻击者更有用。使用差分二元分析,我们在该现象的根源上识别出几种不良行为。反过来,我们提出并评估几种减轻这些行为的策略。特别是,我们表明后期制作的二进制重新编译可以有效地减轻这些行为的性能忽略不计,从而产生了优化的代码,并具有明显较小且有用的小工具集明显较小且有用的小工具集。
Despite extensive testing and correctness certification of their functional semantics, a number of compiler optimizations have been shown to violate security guarantees implemented in source code. While prior work has shed light on how such optimizations may introduce semantic security weaknesses into programs, there remains a significant knowledge gap concerning the impacts of compiler optimizations on non-semantic properties with security implications. In particular, little is currently known about how code generation and optimization decisions made by the compiler affect the availability and utility of reusable code segments called gadgets required for implementing code reuse attack methods such as return-oriented programming. In this paper, we bridge this gap through a study of the impacts of compiler optimization on code reuse gadget sets. We analyze and compare 1,187 variants of 20 different benchmark programs built with two production compilers (GCC and Clang) to determine how their optimization behaviors affect the code reuse gadget sets present in program variants with respect to both quantitative and qualitative metrics. Our study exposes an important and unexpected problem; compiler optimizations introduce new gadgets at a high rate and produce code containing gadget sets that are generally more useful to an attacker than those in unoptimized code. Using differential binary analysis, we identify several undesirable behaviors at the root of this phenomenon. In turn, we propose and evaluate several strategies to mitigate these behaviors. In particular, we show that post-production binary recompilation can effectively mitigate these behaviors with negligible performance impacts, resulting in optimized code with significantly smaller and less useful gadget sets.