Overview
The House of Lore is a sophisticated heap exploitation technique that abuses the smallbin freelist to force malloc to return a nearly-arbitrary pointer. This technique is particularly interesting because it bypasses the hardening checks introduced in modern glibc versions.This is an advanced exploitation technique that requires understanding of glibc’s bin management and double-linked list structures.
Glibc Version Compatibility
| Version | Status | Notes |
|---|---|---|
| glibc 2.23 | ✅ Working | Original technique |
| glibc 2.26+ | ✅ Working | Requires tcache bypass |
| glibc 2.35+ | ✅ Working | Must bypass double-linked list checks |
| Latest | ✅ Working | Demonstrated on Ubuntu 22.04 |
Ret2 Wargames Practice: Try this technique hands-on at House of Lore Interactive Challenge
What This Technique Achieves
The House of Lore enables:- Stack allocation: Force malloc to return a pointer to the stack
- Arbitrary pointer allocation: Get malloc to return nearly any address
- Control flow hijacking: Overwrite return addresses or function pointers on the stack
- Bypass modern hardening: Works even with glibc’s double-linked list corruption checks
Prerequisites and Constraints
How It Works
Allocate the victim chunk
Allocate a chunk in smallbin range (>= 0x100 bytes) that will later be corrupted.
Create fake chunks on stack
Set up a chain of fake chunks with proper fd/bk pointers to bypass corruption checks.
Complete Source Code
Technical Deep Dive
Smallbin Corruption Checks
Glibc introduced hardening to detect smallbin corruption:- Set
stack_buffer_1->fd = victim_chunksobck->fd == victim - When we corrupt
victim->bk = stack_buffer_1, the check passes
The Allocation Chain
When we allocate from the corrupted smallbin:Smallbin-to-Tcache Mechanism
On glibc 2.26+, when allocating from smallbin, chunks are first moved to tcache:Why Two Fake Chunks?
We need two fake chunks because:- First fake chunk (stack_buffer_1): This is what we’ll get from malloc
- Second fake chunk (stack_buffer_2): This passes the double-linked list check for stack_buffer_1
stack_buffer_1->bk->fd == stack_buffer_1
Common Pitfalls
Exploitation Strategies
Stack-Based Exploitation
- Create fake chunks on the stack
- Use House of Lore to get a stack pointer from malloc
- Write shellcode pointer or overwrite return address
- Jump over stack canary to avoid detection
Heap Feng Shui
- Shape the heap to place victim chunk near target
- Use overflow to corrupt victim->bk
- Get allocation at target location
- Overwrite sensitive data structures
Mitigations
This technique remains unpatched but faces several mitigations:- Tcache: Makes exploitation more complex by requiring tcache bypass
- Double-linked list checks: Requires more sophisticated fake chunk setup
- Metadata validation: Some implementations add additional checks
- Safe linking (glibc 2.32+): Doesn’t affect smallbin but makes related techniques harder
Related Techniques
Unsafe Unlink
Related technique exploiting double-linked list manipulation
Tcache Stashing Unlink
Modern variant combining tcache and smallbin exploitation
