Overview
The House of Force is a classic heap exploitation technique that exploits the Top Chunk (also called the Wilderness) to make malloc return a nearly-arbitrary pointer. By overwriting the top chunk’s size field with a very large value, an attacker can control where the next allocation will be placed.Glibc Version Compatibility
Patch commit: 30a17d8c95fbfb15c52d1115803b63aaa73a285c
Ret2 Wargames Practice: Try this technique hands-on at House of Force Interactive Challenge
What This Technique Achieves
The House of Force enables:- Arbitrary memory allocation: Force malloc to return a pointer to any memory location
- GOT overwrite: Overwrite Global Offset Table entries (requires RELRO disabled)
- Data section control: Modify global variables or function pointers
- Integer overflow exploitation: Use integer overflow to reach target addresses
Prerequisites and Constraints
How It Works
1
Allocate initial chunk
Make a normal allocation to have a heap chunk before the top chunk.
2
Overflow into top chunk
Use a vulnerability to overwrite the top chunk’s size with -1 (0xFFFFFFFFFFFFFFFF).
3
Calculate evil size
Calculate the size needed to move the top chunk to your target location.
4
Allocate evil size
Make a large allocation that will move the top chunk via integer overflow.
5
Allocate at target
The next allocation will be served from the new top chunk location.
Complete Source Code
Technical Deep Dive
The Top Chunk
The top chunk (wilderness) is special:- It’s always the last chunk in the heap
- It grows when more memory is needed
- Its size determines available heap space
- When allocated from, it splits off a chunk and shrinks
Integer Overflow Exploitation
The magic happens with integer overflow:Size Calculation Formula
The evil_size formula accounts for:- Chunk metadata (2 * sizeof(long) = 16 bytes on x64)
- Alignment requirements
- The distance between old top and target
The Patch (glibc 2.29)
Glibc 2.29 added this check:CTF Challenges
Boston Key Party 2016 - Cookbook
Boston Key Party 2016 - Cookbook
Challenge: Recipe management system with heap overflowExploitation:
- Used heap overflow to corrupt top chunk size
- Calculated evil_size to target GOT entries
- Overwrote free@GOT with system address
- Got shell by freeing chunk containing “/bin/sh”
BCTF 2016 - bcloud
BCTF 2016 - bcloud
Challenge: Cloud storage service with controlled allocationsExploitation:
- Corrupted top chunk via off-by-one overflow
- Used House of Force to allocate on stack
- Overwrote saved return pointer
- Achieved RCE
Modern Alternative
House of Tangerine
Successor to House of Force: Works on glibc 2.26+ by exploiting sysmalloc’s _int_free call on the top chunk. Uses tcache poisoning instead of direct top chunk allocation.
Common Pitfalls
See Also
- House of Tangerine - Modern alternative
- House of Orange - Related top chunk technique
- Top Chunk Management
- Heap Security Checks
