Address space layout randomization
The conceptWhy the same app sits at a different memory address every launch
Each time a program starts, the operating system puts its stack, heap and libraries at random addresses. This is address space layout randomization (ASLR). Open a browser twice and its C library lands somewhere new.
It blocks attackers who exploit memory bugs. A buffer overflow can overwrite a saved address and redirect the program, but only to an address the attacker knows. ASLR keeps that address secret.
The strength of ASLR is measured in bits of entropy, meaning how many random bits pick the starting address. Each extra bit doubles the number of places the attacker has to guess from.
What it’s forEstimates an attacker's chance of guessing a randomized address when the layout stays the same between tries.
P(success) ≈ k / 2ⁿ
- n
- bits of randomness in the starting address
- 2ⁿ
- number of possible starting addresses
- k
- number of different guesses the attacker gets
What it givesThe chance that one of the attacker's guesses hits the real address.
- n = 8 bits gives 2⁸ = 256 possible positions
- k = 16 guesses gives 16 / 256 = 1/16
- That is a 6.25% chance; each extra bit halves it