CyberKit

D3FEND / Application Hardening

D3-CFI: Control Flow Integrity

Tactic: Harden. The harden tactic is used to increase the opportunity cost of computer network exploitation. Hardening differs from Detection in that it generally is conducted before a system is online and operational.

Definition

Enforcing legal control flow transfers during application process execution.

How it works

Control flow integrity (CFI) restricts the destinations of control flow transfer instructions---particularly indirect function branches such as indirect function calls, jumps, and returns---such that execution can only proceed along paths determined to be valid at compile-time or load-time. CFI is typically implemented by instrumenting a program during compilation or binary rewriting. A control flow graph is constructed that defines the legitimate targets for each indirect control flow transfer. At runtime, before an indirect branch is taken, a check is performed to ensure that the target address is a member of the allowed target set. If the check fails, a defensive response such as process termination or exception handling is triggered. Implementations vary in granularity and enforcement mechanism: - Compiler-based CFI inserts runtime checks that validate indirect call targets against type or signature-based constraints. - Operating system-assisted CFI maintains a bitmap or table of valid indirect call targets and verifies them at runtime before allowing execution to continue. - Hardware-assisted CFI enforces control flow integrity using architectural features such as shadow stacks and specific CPU instructions. By preventing execution from jumping to attacker-controlled or unintended code locations, CFI mitigates a wide range of exploitation techniques, including return-oriented programming (ROP), jump-oriented programming (JOP), and function pointer overwrite attacks.

D3-CFI on d3fend.mitre.org

MITRE D3FEND 1.4.0, published under the MIT License, copyright 2022 The MITRE Corporation.