RUS  ENG
Full version
JOURNALS // Proceedings of the Institute for System Programming of the RAS // Archive

Proceedings of ISP RAS, 2021 Volume 33, Issue 4, Pages 195–210 (Mi tisp622)

This article is cited in 1 paper

Prevention of vulnerabilities arising from optimization of code with undefined behavior

R. V. Baev, L. V. Skvortsov, E. A. Kudryashov, R. A. Buchatskiy, R. A. Zhuykov

Ivannikov Institute for System Programming of the Russian Academy of Sciences

Abstract: Aggressive optimization in modern compilers may uncover vulnerabilities in program code that did not lead to bugs prior to optimization. The source of these vulnerabilities is in code with undefined behavior. Programmers use such constructs relying on some particular behavior these constructs showed before in their experience, but the compiler is not obliged to stick to that behavior and may change the behavior if it's needed for optimization since the behavior is undefined by language standard. This article describes approaches to detection and elimination of vulnerabilities arising from optimization in the case when source code is available but its modification is undesirable or impossible. Concept of a safe compiler (i.e. compiler that ensures no vulnerability is added to the program during optimization) is presented and implementation of such a compiler on top of GCC compiler is described. Implementation of safe compiler's functionality is divided into three security levels whose applicability is discussed in the article. Feasibility of using the safe compiler on real-world codebases is demonstrated and possible performance losses are estimated.

Keywords: compiler, vulnerability, undefined behavior.

DOI: 10.15514/ISPRAS-2021-33(4)-14



© Steklov Math. Inst. of RAS, 2024