CVE-2015-1593 – Linux ASLR integer overflow: Reducing stack entropy by four
An integer overflow in the Linux kernel's stack randomisation code caused the stack address entropy on x86_64 to be reduced by a factor of four. An attacker who needs to guess the stack location, for example in a brute-force attack, would need four times fewer attempts.
hmarco.org
Published on hmarco.org
A bug in Linux ASLR implementation for versions prior to 3.19-rc3 has been found. The issue is that the stack for processes is not properly randomized on some 64 bit architectures due to an integer overflow.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely an integer overflow: a variable used to hold the randomised stack offset was declared as a 32-bit unsigned integer, but shifting a 22-bit mask left by 12 bits requires at least 34 bits, so the top two bits were lost.
Impact
The stack entropy is reduced from 2^30 to 2^28, so an attacker performing brute-force or trial-and-error attacks to guess the stack location needs four times fewer attempts; the issue affects only the x86_64 architecture.
What the attacker needed
Linux kernel before 3.19-rc3; x86_64 architecture
The fix
The bug was fixed by changing the types of the variables in randomize_stack_top() and stack_maxrandom_size() to unsigned long so the shifted value is not truncated.
How it was found
- Run a loop that repeatedly prints the memory map and filters for the stack line.
- Observe the upper bytes of the stack addresses.
- If the addresses consistently start with 7FFF, the system is vulnerable; if they vary between 7FFC and 7FFD, it is not.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Address Space Layout Randomisation (ASLR) is a defence that places parts of a program, such as the stack, at unpredictable memory addresses so attackers cannot easily guess where to aim. In this bug, a calculation mistake in the Linux kernel meant the stack was placed in a much smaller range of possible addresses than intended. This made it easier for an attacker to guess the stack location by trying many times.
What is Crypto?
Encryption, signatures, randomness or certificate checks that do not protect what they claim to.