Memory safety defenses
Algorithms
- AddressSanitizer
Puts poisoned redzones around objects and a quarantine for freed memory, and checks each access against shadow memory to find overflows and use after free.
1 languagescore - Baggy bounds checking
Pads each allocation to a power of two and stores its log size in a compact table, so that bounds checks need one lookup.
1 languagesadvanced - Jones-Kelly bounds checking
Keeps a table of live objects and checks that each pointer arithmetic result stays in the object the operand points to, or one past its end.
1 languagesadvanced - Lock and key temporal checking
Gives each allocation a unique key and lock, copies the key with each pointer, and checks that the lock still holds the key at each access.
1 languagesadvanced - SoftBound
Keeps base and bound for each pointer in a disjoint table indexed by the address where the pointer is stored, for spatial safety in C with no change to memory layout.
1 languagesadvanced - Dangling pointer nullification
Tracks which heap pointers refer to each object and sets them to a null value when the object is freed, so a use after free hits the null page.
1 languagesresearch
Data structures
- Fat pointer
A pointer that carries the base and bound of its object, so that each dereference can be checked against them.
1 languagescore - Shadow memory
A scaled copy of the address space that holds metadata for each byte or word, found from the address by a shift and an add.
1 languagescore - Shadow stack
A protected second stack that keeps a copy of each return address and is compared with the normal stack on return.
1 languagescore
Techniques
- Data execution prevention
Marks each page either writable or executable but never both, so that injected data cannot run as code.
intro - Stack canary
Places a secret value before the return address and checks it before the function returns, to detect a linear stack overflow.
intro - Stack smashing
Overflows a stack buffer to overwrite the saved return address, so that the function returns into code the attacker chose.
intro - Address space layout randomization
Places code, stack, heap and libraries at random addresses at load time, so that an attacker cannot predict the target of a jump.
core - Control-flow integrity
Checks at each indirect branch that the target is allowed by a control flow graph computed in advance, so hijacked flow stops.
1 languagescore - Return-oriented programming
Builds arbitrary computation by chaining short instruction sequences that end in a return, found in existing code.
core - Return-to-libc attack
Hijacks control by returning into existing library functions with chosen arguments, which defeats non-executable memory.
core - Software fault isolation
Rewrites untrusted machine code so that every store and jump is masked or checked to stay inside its own region of memory.
1 languagescore - ASLR derandomization by brute force
Guesses the random offset of a forking server by repeated probes, showing that 16 bits of entropy fall in minutes.
advanced - Code-pointer integrity
Keeps code pointers and the pointers that lead to them in an isolated safe region with full memory safety, at low cost.
advanced - Memory tagging
Gives each granule of memory and each pointer a small tag and lets the hardware fault when the tags of an access differ.
advanced - Control-flow bending
Attacks programs under fully precise static CFI by steering flow along allowed edges, often through functions such as memcpy and printf.
research - Data-oriented programming
Builds Turing-complete attacks by corrupting only data, chaining gadgets along legitimate control flow, which control-flow defenses miss.
research
Concepts
- Buffer overflow
An access past the end or before the start of a buffer, which reads or overwrites nearby memory that belongs to other data.
intro
Definitions
- Memory safety
A program is memory safe if every access goes to a live object through a pointer derived from it and stays within its bounds.
intro
Models
- CHERI capability model
A processor model in which pointers are unforgeable capabilities with bounds and permissions, checked by hardware on every access.
research