Skip to main content
QUICK REVIEW

[Paper Review] Cryptographically Enforced Control Flow Integrity

Ali José Mashtizadeh, Andrea Bittau|arXiv (Cornell University)|Aug 7, 2014
Security and Verification in ComputingComputer Science7 references18 citations
TL;DR

This paper introduces Cryptographically Enforced Control Flow Integrity (CCFI), a fine-grained, practical defense that uses message authentication codes (MACs) on control-flow elements—such as return addresses and function pointers—to prevent control flow hijacking. By leveraging hardware-accelerated AES-NI instructions and storing secret keys in dedicated registers, CCFI detects tampering with control data even under a powerful adversary model, achieving 3–18% performance overhead on real-world software stacks.

ABSTRACT

Recent Pwn2Own competitions have demonstrated the continued effectiveness of control hijacking attacks despite deployed countermeasures including stack canaries and ASLR. A powerful defense called Control flow Integrity (CFI) offers a principled approach to preventing such attacks. However, prior CFI implementations use static analysis and must limit protection to remain practical. These limitations have enabled attacks against all known CFI systems, as demonstrated in recent work. This paper presents a cryptographic approach to control flow integrity (CCFI) that is both fine-grain and practical: using message authentication codes (MAC) to protect control flow elements such as return addresses, function pointers, and vtable pointers. MACs on these elements prevent even powerful attackers with random read/write access to memory from tampering with program control flow. We implemented CCFI in Clang/LLVM, taking advantage of recently available cryptographic CPU instructions. We evaluate our system on several large software packages (including nginx, Apache and memcache) as well as all their dependencies. The cost of protection ranges from a 3-18% decrease in request rate.

Motivation & Objective

  • Address the fundamental vulnerability of control flow hijacking in software, which undermines traditional defenses like stack canaries and ASLR.
  • Overcome the limitations of prior Control Flow Integrity (CFI) systems that rely on imprecise static analysis and coarse-grained pointer grouping.
  • Develop a practical, fine-grained CFI mechanism that resists sophisticated attacks, including those with arbitrary memory read/write access.
  • Enable runtime-based pointer classification (e.g., by memory address) to avoid the scalability and compatibility issues of static analysis.
  • Integrate cryptographic checks into a standard compiler toolchain (Clang/LLVM) to support real-world deployment with minimal code changes.

Proposed method

  • Apply message authentication codes (MACs) to all control-flow-critical data—return addresses, function pointers, vtable pointers—each time they are stored in memory.
  • Store the MAC alongside the control-flow data and validate it upon every load to detect tampering.
  • Use a secret key stored in dedicated CPU registers to prevent key leakage via memory disclosure vulnerabilities.
  • Incorporate memory address and pointer type (e.g., return vs. function pointer) into the MAC input to prevent pointer swapping attacks.
  • Leverage hardware-accelerated AES-NI instructions to compute MACs in only 40 cycles, minimizing performance overhead.
  • Randomize memory allocations to reduce predictability and make replay attacks on pointers less feasible.

Experimental results

Research questions

  • RQ1Can cryptographic primitives be used to enforce fine-grained control flow integrity without relying on static analysis?
  • RQ2Can hardware-accelerated MACs provide sufficient performance to make cryptographic CFI practical for production software?
  • RQ3Can CCFI prevent all known control flow hijacking attacks, including those that bypass traditional CFI systems?
  • RQ4How does classifying pointers by runtime attributes (e.g., memory address) improve security over compile-time static classification?
  • RQ5To what extent can CCFI be integrated into existing software stacks with minimal code changes?

Key findings

  • CCFI successfully prevents all known control flow hijacking attacks under a powerful adversary model that includes arbitrary memory read/write access.
  • The system achieves 3–18% performance overhead on real-world software, including nginx, Apache, memcached, and their dependencies, with only minor code changes required.
  • Only two packages (libapr and Nginx) required manual code modifications for MAC computation compatibility.
  • The use of address-based classification in MACs prevents pointer swapping attacks that compromise existing CFI systems.
  • Hardware-accelerated AES-NI enables efficient MAC computation (40 cycles), eliminating the need to omit or simplify checks for performance.
  • CCFI is compatible with existing CFI systems and can be extended to support additional classification criteria, such as type or compile-time grouping.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.