Skip to main content

Formal Hardware/Software Models for Cache Locking Enabling Fast and Secure Code

  • Conference paper
  • First Online:
Computer Security – ESORICS 2024 (ESORICS 2024)

Abstract

Constant-time programming is the de facto standard to protect security-sensitive software against cache-based timing attacks. This software countermeasure is effective but may incur a significant performance overhead and require a substantial rewrite of the code. In this work, we study a secure cache-locking hardware mechanism which eases the writing of secure code and has little execution overhead. To reason about the security of software, we propose a high-level leakage model such that accesses to locked memory addresses do not generate any observable leakage. To ensure the adequacy of this leakage model, we also propose a concrete hardware leakage model for a RISC-V microcontroller where the secure code may be interrupted, at any time, by some arbitrary malicious code. Using the Observational Non-Interference setting, we show formally that the security of the software model is preserved at the hardware level. We evaluate the effectiveness and performance of this mechanism, notably on block ciphers. We also propose and evaluate a new constant-time sorting algorithm.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Subscribe and save

Springer+ Basic
$34.99 /Month
  • Get 10 units per month
  • Download Article/Chapter or eBook
  • 1 Unit = 1 Article or 1 Chapter
  • Cancel anytime
Subscribe now

Buy Now

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Similar content being viewed by others

Notes

  1. 1.

    https://gitlab.inria.fr/scratchs-public/esorics2024-artefact.

  2. 2.

    https://gitlab.inria.fr/scratchs-public/esorics2024-artefact/-/blob/main/oni-formalisation/target_intf.v#L604.

  3. 3.

    https://www.bearssl.org/.

  4. 4.

    https://sorting.cr.yp.to.

References

  1. Agat, J.: Transforming out timing leaks. In: POPL. ACM (2000)

    Google Scholar 

  2. Almeida, J.B., Barbosa, M., Barthe, G., Dupressoir, F., Emmi, M.: Verifying constant-time implementations. In: USENIX Security Symposium, pp. 53–70. USENIX Association (2016)

    Google Scholar 

  3. Barthe, G., Betarte, G., Campo, J.D., Luna, C.: System-level non-interference of constant-time cryptography. Part I: model. J. Autom. Reason. 63, 1–51 (2019)

    Article  MathSciNet  Google Scholar 

  4. Barthe, G., Betarte, G., Campo, J.D., Luna, C., Pichardie, D.: System-level non-interference of constant-time cryptography. part II: verified static analysis and stealth memory. J. Autom. Reason. 64(8), 1685–1729 (2020)

    Article  MathSciNet  Google Scholar 

  5. Barthe, G., Betarte, G., Campo, J.D., Luna, C.D., Pichardie, D.: System-level Non-interference for Constant-time Cryptography. In: CCS, pp. 1267–1279. ACM (2014)

    Google Scholar 

  6. Barthe, G., et al.: Formal verification of a constant-time preserving C compiler. Proc. ACM Program. Lang. 4(POPL) (2019)

    Google Scholar 

  7. Barthe, G., Blazy, S., Hutin, R., Pichardie, D.: Secure compilation of constant-resource programs. In: CSF, pp. 1–12. IEEE (2021)

    Google Scholar 

  8. Barthe, G., Grégoire, B., Laporte, V.: Secure compilation of side- channel countermeasures: the case of cryptographic “Constant-Time”. In: CSF, pp. 328–343. IEEE Computer Society (2018)

    Google Scholar 

  9. Batcher, K.E.: Sorting networks and their applications. In: AFIPS Conference Proceedings, vol. 32. Thomson Book Company (1968)

    Google Scholar 

  10. Bernstein, D.J., Lange, T., Schwabe, P.: The security impact of a new cryptographic library. In: Hevia, A., Neven, G. (eds.) LATINCRYPT 2012. LNCS, vol. 7533, pp. 159–176. Springer, Heidelberg (2012). https://doi.org/10.1007/978-3-642-33481-8_9

    Chapter  Google Scholar 

  11. Blazy, S., Pichardie, D., Trieu, A.: Verifying constant-time implementations by abstract interpretation. J. Comput. Secur. 27(1), 137–163 (2019)

    Article  Google Scholar 

  12. Cauligi, S., et al.: FaCT: a DSL for timing-sensitive computation. In: PLDI, pp. 174–189. ACM (2019)

    Google Scholar 

  13. Dijkstra, E.W.: The Mathematics Behind the Banker’s Algorithm. Springer-Verlag, Heidelberg (1982). isbn: 0387906525

    Google Scholar 

  14. Domnitser, L., Jaleel, A., Loew, J., Abu-Ghazaleh, N.B., Ponomarev, D.: Non-monopolizable caches: low-complexity mitigation of cache side channel attacks. ACM Trans. Archit. Code Optim. 8(4), 35:1–35:21 (2012)

    Google Scholar 

  15. Doychev, G., Köpf, B., Mauborgne, L., Reineke, J.: CacheAudit: a tool for the static analysis of cache side channels. ACM Trans. Inf. Syst. Secur. 18(1), 4:1–4:32 (2015)

    Google Scholar 

  16. Gaudin, N., Cotret, P., Guy, G., Lapotre, V.: A fine-grained dynamic partitioning against cache-based timing attacks via cache locking. In: ISVLSI 2024 (2024)

    Google Scholar 

  17. Gaudin, N., et al.: Work in progress: thwarting timing attacks in microcontrollers using fine-grained hardware protections. In: EuroS &P Workshops, pp. 304–310. IEEE (2023)

    Google Scholar 

  18. Ge, Q., Yarom, Y., Heiser, G.: No security without time protection: we need a new hardware-software contract. In: APSys, pp. 1:1–1:9. ACM (2018)

    Google Scholar 

  19. Guarnieri, M., Köpf, B., Reineke, J., Vila, P.: Hardware-software contracts for secure speculation. In: SP, pp. 1868–1883. IEEE (2021)

    Google Scholar 

  20. Kim, T., Peinado, M., Mainar-Ruiz, G.: STEALTHMEM: system-level protection against cache-based side channel attacks in the cloud. In: USENIX Security Symposium, pp. 189–204. USENIX Association (2012)

    Google Scholar 

  21. Liu, C., Harris, A., Maas, M., Hicks, M.W., Tiwari, M., Shi, E.: GhostRider: a hardware-software system for memory trace oblivious computation. In: ASPLOS, pp. 87–101. ACM (2015)

    Google Scholar 

  22. Liu, C., Hicks, M., Shi, E.: Memory trace oblivious program execution. In: CSF, pp. 51–65. IEEE Computer Society (2013)

    Google Scholar 

  23. Miao, Y., Kandemir, M.T., Zhang, D., Zhang, Y., Tan, G., Wu, D.: Hardware support for constant-time programming. In: MICRO, pp. 856–870. ACM (2023)

    Google Scholar 

  24. Molnar, D., Piotrowski, M., Schultz, D., Wagner, D.: The program counter security model: automatic detection and removal of control-flow side channel attacks. In: Won, D.H., Kim, S. (eds.) ICISC 2005. LNCS, vol. 3935, pp. 156–168. Springer, Heidelberg (2006). https://doi.org/10.1007/11734727_14

    Chapter  Google Scholar 

  25. Mushtaq, M., Mukhtar, M.A., Lapotre, V., Bhatti, M.K., Gogniat, G.: Winter is here! a decade of cache-based side-channel attacks, detection & mitigation for RSA. Inf. Syst. 92, 101524 (2020)

    Article  Google Scholar 

  26. Stefanov, E., et al.: Path ORAM: an extremely simple oblivious RAM protocol. J. ACM 65(4), 18:1–18:26 (2018)

    Google Scholar 

  27. Tromer, E., Osvik, D.A., Shamir, A.: Efficient cache attacks on AES, and countermeasures. J. Cryptol. 23(1), 37–71 (2010)

    Article  MathSciNet  Google Scholar 

  28. Wang, Z., Lee, R.B.: New cache designs for thwarting software cachebased side channel attacks. In: ISCA, pp. 494–505. ACM (2007)

    Google Scholar 

  29. Yarom, Y., Falkner, K.: FLUSH+RELOAD: a high resolution, low noise, L3 cache side-channel attack. In: USENIX Security Symposium, pp. 719–732. USENIX Association (2014)

    Google Scholar 

Download references

Acknowledgment

This work is supported by the SCRATCHS project of the Cominlabs excellence laboratory (grant ANR-10-LABX-07-01) funded by the French National Research Agency.

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Jean-Loup Hatchikian-Houdot .

Editor information

Editors and Affiliations

Appendices

A Evaluation of Algorithms with Input Dependent Locks

The evaluation results for Histogram, Permuation, Heap-pop and Dijkstra can be found in Fig. 5, Fig. 6, Fig. 7 and Fig. 8.

B Semantics of Instructions

The semantics of instructions is given in Fig. 9.

Fig. 5.
figure 5

Histogram Overhead

Fig. 6.
figure 6

Permutation Overhead

Fig. 7.
figure 7

Heap-pop Overhead

Fig. 8.
figure 8

Dijkstra Overhead

C Proof of Theorem 1

Proof

To prove \( ONI (\psi ,H)\), we suppose that we have two derivations \(\alpha \xrightarrow [\textbf{H}]{t} ^{n} \beta \) and \(\alpha ' \xrightarrow [\textbf{H}]{t'} ^{n} \beta '\) and two inputs \((i,i')\) such that \(\alpha \in I_\textbf{H}(i)\) and \(\beta \in I_\textbf{H}(i')\) and \(\psi (\alpha , \alpha ')\). By the backward simulation, there is also a pair of software states \((a,a')\in I_\textbf{S}(i) \times I_\textbf{S}(i')\) such that \( a \approx \alpha \) and \(a' \approx \alpha '\). By definition of the lockstep 2-simulation we also have \(a \equiv _\textbf{S}a'\) and \(\alpha \equiv _\textbf{H}\alpha '\).

We need to prove that \(t=t'\) and that \(\beta \in \mathcal {F}(H) \iff \beta ' \in \mathcal {F}(H)\). The proof is by induction over the length of the derivation.

  • Base case. 0-step derivations generate the empty trace: the traces are equal. \( ONI \) gives us \(a\in \mathcal {F}(\textbf{S}) \iff a' \in \mathcal {F}(\textbf{S})\). We prove that \(\alpha \in \mathcal {F}(\textbf{H}) \iff \alpha ' \in \mathcal {F}(\textbf{H})\).

    • If \(a\in \mathcal {F}(\textbf{S})\), then \(a' \in \mathcal {F}(\textbf{S})\), and by the backward simulation, we get that \(\alpha \in \mathcal {F}(\textbf{H})\) and \(\alpha '\in \mathcal {F}(\textbf{H})\).

    • If \(a\notin \mathcal {F}\), there exist t, b, \(t'\) and \(b'\) such that \(a \xrightarrow [\textbf{S}]{t} b\) and \(a' \xrightarrow [\textbf{S}]{t'} {b'}\). By \( ONI \), \(t=t'\). The property follows by the lockstep 2-simulation.

  • Inductive case. Suppose that we have two derivations of length \(n+1\) of the form \( \alpha \xrightarrow [\textbf{H}]{\tau _1} ^{1} \beta _1 \xrightarrow [\textbf{H}]{\tau } ^{n} \beta \mathrm {~and~} \alpha ' \xrightarrow [\textbf{H}]{\tau _1'} ^{1} \beta '_1 \xrightarrow [\textbf{H}]{\tau '} ^{n} \beta ' \). We need to prove that \(\tau _1\cdot \tau = \tau _1' \cdot \tau '\) and \(\beta \in \mathcal {F}\iff \beta ' \in \mathcal {F}\). By the backward simulation, we can exhibit two software derivations \(a\xrightarrow [\textbf{S}]{t_1} ^{1} b_1\) and \(a'\xrightarrow [\textbf{S}]{t_1'} ^{1} b_1'\) for some \(t_1\), \(b_1\), \(t_1'\) and \(b_1'\) such that \(b_1 \approx \beta _1\) and \(b_1' \approx \beta _1'\). By \( ONI \), \(t_1 = t_1'\), and by the lockstep 2-simulation, \(\tau _1 = \tau _1'\). The property then follows by the induction hypothesis.   \(\square \)

Fig. 9.
figure 9

Program semantics

Rights and permissions

Reprints and permissions

Copyright information

© 2024 The Author(s), under exclusive license to Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Hatchikian-Houdot, JL., Wilke, P., Besson, F., Hiet, G. (2024). Formal Hardware/Software Models for Cache Locking Enabling Fast and Secure Code. In: Garcia-Alfaro, J., Kozik, R., Choraś, M., Katsikas, S. (eds) Computer Security – ESORICS 2024. ESORICS 2024. Lecture Notes in Computer Science, vol 14984. Springer, Cham. https://doi.org/10.1007/978-3-031-70896-1_8

Download citation

  • DOI: https://doi.org/10.1007/978-3-031-70896-1_8

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-031-70895-4

  • Online ISBN: 978-3-031-70896-1

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics