arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2507.06112cs.CR
收藏

旗帜的乐趣:编译器如何破坏并修复恒定时间代码

Fun with flags: How Compilers Break and Fix Constant-Time Code

Antoine Geimer, Clementine Maurice

AI总结:

针对编译器优化破坏恒定时间代码导致计时侧信道漏洞的问题,通过分析GCC和LLVM编译器内部优化过程,提出用编译器标志禁用选定过程的方法,以最小性能开销减少漏洞,提供可立即部署的防御措施。

摘要:

开发者依赖恒定时间编程来防止计时侧信道攻击,但编译器的优化可能会悄无声息地重新引入漏洞,从而破坏这些努力。虽然最近的研究已经测量了此类漏洞的程度,但它们并未为开发者提供可操作的见解:哪些优化过程是罪魁祸首,以及如何在不修改编译器的情况下禁用这些过程仍不清楚。在本文中,我们对编译器优化如何破坏恒定时间代码进行了定性分析。我们构建了一个编译器引入的恒定时间违规数据集,并分析了GCC和LLVM这两个广泛使用的编译器的内部结构,以确定具体负责的优化过程。我们的关键见解是,一小部分过程是大多数漏洞的根源。据我们所知,我们也是第一个描述这些过程之间的相互作用如何导致漏洞的研究。基于此分析,我们提出了一种原创且实用的缓解措施,无需修改源代码或自定义编译器:通过编译器标志禁用选定的优化过程。我们表明,这种方法以最小的性能开销显著减少了漏洞,为开发者提供了一种可立即部署的防御措施。

英文摘要:

Developers rely on constant-time programming to prevent timing side-channel attacks. But these efforts can be undone by compilers, whose optimizations may silently reintroduce leaks. While recent works have measured the extent of such leakage, they leave developers without actionable insights: which optimization passes are responsible, and how to disable them without modifying the compiler remains unclear. In this paper, we conduct a qualitative analysis of how compiler optimizations break constant-time code. We construct a dataset of compiler-introduced constant-time violations and analyze the internals of two widely used compilers, GCC and LLVM, to identify the specific optimization passes responsible. Our key insight is that a small set of passes are at the root of most leaks. To the best of our knowledge, we are also the first to characterize how the interactions between these passes contribute to leakage. Based on this analysis, we propose an original and practical mitigation that requires no source code modification or custom compiler: disabling selected optimization passes via compiler flags. We show that this approach significantly reduces leakage with minimal performance overhead, offering an immediately deployable defense for developers.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑