Protecting Cryptographic Libraries against Side-Channel and Code-Reuse Attacks
Rodothea Myrsini Tsoupidi, [email protected], Elena Troubitsyna, [email protected], Panos Papadimitratos, [email protected] · 2024
Read Protecting Cryptographic Libraries against Side-Channel and Code-Reuse Attacks by Rodothea Myrsini Tsoupidi, [email protected], Elena Troubitsyna, [email protected], Panos Papadimitratos, [email protected] (2024) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2412-19310.txt.
Introduction
Tsoupidi, Troubitsyna, and Papadimitratos audit the defenses of crypto libraries in a 2024 article. These libraries guard keys and coded messages across the internet, yet they leak through side channels and memory flaws. The team reviews popular libraries and the guards each one carries. Gaps are named, and fixes for the build process are proposed.
Side-channel attacks read secrets from timing or power traces rather than breaking the math. Code-reuse attacks bend flawed memory handling to hijack flow. The authors argue that library teams should bake checks for both into daily work. The article serves builders of security software who want a map of weak spots.
Catalog record
| CREATOR | Rodothea Myrsini Tsoupidi, [email protected], Elena Troubitsyna, [email protected], Panos Papadimitratos, [email protected] |
|---|---|
| YEAR | 2024 |
| COLLECTION | PAPERS |
| FORMAT | TXT |
| FILE SIZE | 40 KB |
| VERSION | 1.0 |
| LICENSE | http://creativecommons.org/licenses/by/4.0/ |
| RIGHTS | CC BY |
| SOURCE | arXiv |
Source: https://arxiv.org/abs/2412-19310
Browse the full library · About the Tower of Babel
Full text
The opening of the work, from the library's hosted text:
Protecting Cryptographic Libraries against Side-Channel and Code-Reuse Attacks Rodothea Myrsini Tsoupidi, [email protected], Elena Troubitsyna, [email protected], Panos Papadimitratos, [email protected] Abstract Cryptographic libraries, an essential part of cybersecurity, are shown to be susceptible to different types of attacks, including side-channel and memory-corruption attacks. In this article, we examine popular cryptographic libraries in terms of the security measures they implement, pinpoint security vulnerabilities, and suggest security improvements in their development process. keywords: cryptographic libraries, code-reuse attacks, side-channel attacks, compiler-based security \jvol XX \jnum XX \paper 8 \jmonth Month \jtitle Publication Title \sptitle Journal: Publication Name \chapteri Cryptographic algorithms and protocols constitute an essential part of software security. Cryptosystems, that is, ensembles of cryptographic algorithms, provide security services, such as confidentiality, authentication, integrity, and non-repudiation, based on mathematical problems deemed computationally intractable. Cryptographic libraries implement cryptographic algorithms in software and they offer an essential building block for implementing any cryptographic protocol. The importance of cryptographic libraries in security-critical applications has attracted malicious attackers that aim at exploiting the target system. For example, various cyberattacks [ 1 , 2 ] have demonstrated the presence of exploitable vulnerabilities in different versions of OpenSSL 1 1 1 OpenSSL: https://www.openssl.org/ , a popular cryptographic library, and other cryptographic libraries [ 3 ] . Side-channel attacks are powerful attacks that often target cryptographic software. These attacks allow unauthorized users to extract sensitive information during the program execution by recording different metrics, such as the execution time of the program. Cryptographic algorithms are specially targeted by side-channel attacks that aim at extracting secret information, in particular secret or private cryptographic keys. Revealing these values may allow an adversary to compromise a secure communication channel. For example, the adversary may access and/or modify at will end-to-end encrypted and authenticated messages, or impersonate a user using their private key to sign emails [ 1 ] . Another, highly exploitable class of software-enabled attacks is based on memory leaks. Memory-buffer vulnerabilities are among the most common security vulnerabilities, comprising approximately 20% of the reported vulnerabilities in cryptographic libraries [ 3 ] . Code-reuse attacks are among the most powerful attacks that are based on a memory corruption vulnerability, such as a buffer overflow, to alter the program control flow and hijack the target system. It is worth noting that many popular cryptographic libraries, such as OpenSSL, libsodium 2 2 2 libsodium: https://nacl.cr.yp.to/ , and cryptlib 3 3 3 cryptlib: https://www.cs.auckland.ac.nz/~pgut001/cryptlib/ , are implemented in unsafe programming languages, such as C and C++ [ 4 ] , which allow memory-corruption vulnerabilities and unstructured control flow. To deal with these threats, cryptographic-library developers implement security measures to protect the library implementation. These mitigations include source-code countermeasures and compiler-based mitigations. Note that timing side channel and code-reuse attacks require different types of countermeasures and applying these mitigations independently may compromise the security of the system [ 5 ] . A recent survey by Jancar et al. [4] studies mitigation techniques against timing side-channel attacks in popular cryptographic libraries. The study reveals that only 13 out of 27 libraries claim resistance against timing attacks. Moreover, the applied mitigation techniques in some libraries cannot guarantee the absence of timing side-channel vulnerabilities in the executable code. The survey focuses on the developers’ effort to protect their code and the use of verification tools in the testing process of the library to ensure the absence of timing leaks. Instead, in this work, we focus on the compilation process as the main mitigation stage. Compilers play an essential role in the development of cryptographic libraries. In particular, cryptographic libraries typically use general-purpose optimizing compilers, such as GCC 4 4 4 GCC: https://gcc.gnu.org/ and LLVM 5 5 5 LLVM: https://llvm.org/ , to compile the source code and generate efficient code for a wide range of target processors. However, code optimization and compiler-based security are two conflicting goals [ 6 ] , and general-purpose compilers often lean towards efficiency. Instead, secure compilation approaches allow for secure-by-design development of security-critical applications often at the cost of code efficiency. In this work, we investigate the current mitigations of eleven popular cryptographic libraries against code-reuse attacks and side-channel attacks and discuss different existing compiler approaches that may improve security in cryptographic libraries. Many of these secure compilation approaches have drawbacks, such as supporting a subset of cyberattacks, introducing high overhead, or providing low maintenance. As a way to deal with these open challenges, we propose possible directions toward improving the compilation of popular cryptographic libraries: • General-purpose compiler developers need to provide additional security countermeasures and control over the compilation procedure to the programmer; • Secure compilation approaches need to target multiple attacker models, consider optimization goals, and improve maintenance; • Cryptographic library developers need to adapt secure compilation approaches or enable additional protection options in their current compilation scheme. In the following sections, we first describe how timing and code-reuse attacks operate and common mitigations against these attacks. Subsequently, we present a summary of compiler-based or post-compilation countermeasures in cryptographic libraries. Finally, we present a set of secure compilation approaches that may be used to protect cryptographic libraries and discuss possible directions for improving the security of cryptographic libraries. CYBERATTACKS Cryptographic libraries are vulnerable to side-channel attacks. In particular, side-channel attacks measure time, power consumption, sound, or electromagnetic emissions, to infer security-critical values, notably cryptographic keys. Timing side-channel attacks are particularly effective against cryptographic implementations because they do not require physical access to the target device. For example, OpenSSL and PolarSSL (now Mbed TLS) implementations had a timing vulnerability, known as lucky thirteen vulnerability (CVE-2013-0169). Furthermore, a cryptographic library is software that may contain memory vulnerabilities. More specifically, memory vulnerabilities threaten cryptographic implementations. For example, the Heartbleed vulnerability (CVE-2014-0160) in OpenSSL allowed reading sensitive memory. Code-reuse attacks constitute powerful attacks that allow full control of the system using a memory corruption vulnerabilities. In general, memory vulnerabilities may enable powerful code-reuse attacks in two ways: 1) initiate the attack using a memory corruption vulnerability that is present in the library and 2) use code snippets from the library code base to stitch a code-reuse attack. Timing Side-Channel Attacks Cryptographic implementations are typically written in high-level languages, such as C and C++. This code is translated to the target processor machine code, which consists of a set of hardware instructions. The execution sequence of these instructions and the values they process affect the observable execution time of the code. Precise time measurements allow the observer to extract information about the processed values. For example, the execution time of arithmetic division may take shorter time if the divisor is equal to one than otherwise. Cryptographic libraries implement cryptographic protocols, which process security-sensitive values that should remain secret, such as an encryption key. The implementation of a cryptographic algorithm may lead to information leakage during execution. Figure shows the implementation of function check_bit , which may be part of a naive implementation of authenticating a user-provided password ( pub ) compared to a stored password ( key ). Here, u8 denotes an unsigned 8-bit value. Function check_bit takes two values as input, pub and key , and compares them. If the values are equal, the function returns one, otherwise, the function returns zero. We assume that one of the