Overview
The House of Storm is an advanced heap exploitation technique that combines manipulation of both unsorted bin and large bin chunks to force malloc to return an arbitrary memory address as a valid chunk. The technique writes a fake size value to a user-chosen address, then leverages this to pull the fake chunk from the unsorted bin.Glibc Version Compatibility
For glibc 2.26-2.28, the tcache must be full for this technique to work.Requirements
- UAF on Unsorted Bin Chunk: Ability to write to a freed unsorted bin chunk
- UAF on Large Bin Chunk: Ability to write to a freed large bin chunk
- Address Knowledge: Known address of target memory location
- Heap Leak: Known upper bits of heap addresses
- Size Constraints: Target location must allow specific size values
What It Achieves
The House of Storm enables:- Arbitrary Chunk Return: Force malloc to return arbitrary memory as a chunk
- Write-Where Primitive: Leverage large bin to write size values
- Controlled Allocation: Allocate chunks at controlled addresses
- Memory Corruption: Gain read/write access to arbitrary memory
Technical Details
Two-Stage Attack
Setup Bins
Create one chunk in the unsorted bin (larger) and one in the large bin (smaller). The unsorted bin chunk MUST be larger than the large bin chunk but in the same size range.
Calculate Target Size
Use the upper bytes of a heap address as the fake chunk size. The chunk size comes from the naturally occurring bytes at the target location when a heap pointer is placed there.
Write Fake Size
Use the large bin’s
bk_nextsize write primitive to write a heap pointer at a misaligned offset, creating a valid size value at the target location.Redirect Unsorted Bin
Overwrite the unsorted bin chunk’s
bk pointer to point to the target location (which now has a valid size).Source Code
Walkthrough
Step 1: Understanding the Size Calculation
Step 1: Understanding the Size Calculation
The clever part of House of Storm is using heap addresses as size values:This size is deterministic based on the heap base address and can be calculated with a heap leak.
Step 2: Large Bin Write Primitive
Step 2: Large Bin Write Primitive
The large bin write occurs in the By controlling
malloc_consolidate process:victim->bk_nextsize, we control WHERE the write occurs. The value written is victim (the unsorted bin chunk address).The misalignment trick:Step 3: Unsorted Bin Processing
Step 3: Unsorted Bin Processing
When we allocate size 0x5544, malloc processes the unsorted bin:
- Checks first chunk (size 0x4f0) - too small, skip
- Follows
bkpointer to fake chunk - Reads fake chunk size (0x5544) - MATCHES REQUEST!
- Validates size (must be > 0x20 and < system_mem)
- Unlinks fake chunk from unsorted bin
- Returns fake chunk to user
arena_for_chunk is bypassed by ensuring:- Either mmap bit (0x2) is set in size, OR
- Non-main arena bit (0x4) is NOT set
Tcache Considerations
Tcache Considerations
For glibc 2.27-2.28 with tcache:If the allocation size falls in tcache range (< 0x410), we must fill tcache first. Otherwise, malloc will use “tcache stashing” which interferes with the attack.Filling tcache:Now the 8th allocation bypasses tcache and uses bins.
Visual Representation
Success Rate and Constraints
CTF Challenges
No specific challenges listed, but applicable to:- CTF challenges on glibc 2.26-2.28
- Scenarios with multiple UAF vulnerabilities
- Challenges requiring arbitrary read/write primitives
References
- Ret2 Wargames Interactive Demo
- [Large Bin Attack/techniques/bins/large-bin-attack)
- [Unsorted Bin Attack/techniques/bins/unsorted-bin-attack)
Related Techniques
- House of Force - Another arbitrary allocation technique
- [Large Bin Attack/techniques/bins/large-bin-attack) - The write primitive used here
- [Unsorted Bin Attack/techniques/bins/unsorted-bin-attack) - The redirection primitive
