All Techniques Reference
This page provides a comprehensive reference of all heap exploitation techniques in how2heap, organized by category. Each technique includes its description, glibc version compatibility, patch information, and references to real-world CTF challenges.Techniques marked with ⏩ have interactive browser-based debugging support via Ret2 Wargames.
Foundational Techniques
These techniques demonstrate basic heap allocator behavior and are essential for understanding more advanced exploits.first_fit.c - First-Fit Allocation Behavior
first_fit.c - First-Fit Allocation Behavior
Description: Demonstrates glibc malloc’s first-fit algorithm for selecting free chunks.Glibc Version: All versionsType: Educational demonstrationKey Concept: The allocator will reuse the first free chunk that fits the requested size, which can be exploited in use-after-free situations.Source:
first_fit.ccalc_tcache_idx.c - Tcache Index Calculation
calc_tcache_idx.c - Tcache Index Calculation
Description: Demonstrates glibc’s tcache index calculation and provides a calculator for determining which tcache bin a given size will use.Glibc Version: All versionsType: Educational demonstrationFormula:
IDX = (CHUNKSIZE - MINSIZE + MALLOC_ALIGNMENT - 1) / MALLOC_ALIGNMENTSource: calc_tcache_idx.cFastbin Techniques
Exploits targeting the fastbin freelist mechanism, primarily for small allocations (< 128 bytes on 64-bit systems).fastbin_dup.c
Tricking malloc into returning an already-allocated heap pointer by abusing the fastbin freelist.
- Version: Latest
- Debug: ⏩ Browser Debug
fastbin_dup_into_stack.c
Tricking malloc into returning a nearly-arbitrary pointer by abusing the fastbin freelist.
- Version: Latest
- Debug: ⏩ Browser Debug
- CTF: 9447-search-engine, 0ctf 2017-babyheap
fastbin_dup_consolidate.c
Tricking malloc into returning an already-allocated heap pointer by putting a pointer on both fastbin freelist and the top chunk.
- Version: Latest
- Debug: ⏩ Browser Debug
- CTF: Hitcon 2016 SleepyHolder
fastbin_reverse_into_tcache.c
Exploiting the overwrite of a freed chunk in the fastbin to write a large value into an arbitrary address.
- Version: >= 2.26
- Debug: ⏩ Browser Debug
Tcache Techniques
Modern exploitation techniques targeting the thread-local cache introduced in glibc 2.26.tcache_poisoning.c
Tricking malloc into returning a completely arbitrary pointer by abusing the tcache freelist.
- Version: >= 2.26
- Requirement: Heap leak required on and after 2.32 (safe-linking)
- Patch: Safe-linking patch
- Debug: ⏩ Browser Debug
tcache_dup.c (obsolete)
Tricking malloc into returning an already-allocated heap pointer by abusing the tcache freelist.
- Version: 2.26 - 2.28 (obsolete)
- Status: Patched in glibc 2.29
- Patch: Double-free check
- Note: This technique is obsolete. See house_of_botcake for a modern alternative.
tcache_house_of_spirit.c
Frees a fake chunk to get malloc to return a nearly-arbitrary pointer (tcache variant).
- Version: >= 2.26
- Debug: ⏩ Browser Debug
house_of_botcake.c
Bypass double free restriction on tcache. Make tcache_dup great again.
- Version: >= 2.26
- Debug: ⏩ Browser Debug
tcache_stashing_unlink_attack.c
Exploiting the overwrite of a freed chunk on small bin freelist to trick malloc into returning an arbitrary pointer.
- Version: >= 2.26
- Debug: ⏩ Browser Debug
- CTF: Hitcon 2019 one punch man
tcache_metadata_poisoning.c
Trick the tcache into providing arbitrary pointers by manipulating the tcache metadata struct.
- Version: >= 2.26
tcache_relative_write.c
Arbitrary decimal value and chunk pointer writing in heap by out-of-bounds tcache metadata writing.
- Version: >= 2.30
House Techniques
Classic and modern “House of X” exploitation techniques, each providing different primitives.- Classic Houses
- Modern Houses
house_of_spirit.c
Frees a fake fastbin chunk to get malloc to return a nearly-arbitrary pointer.
- Version: Latest
- Debug: ⏩ Browser Debug
- CTF: hack.lu CTF 2014-OREO
house_of_lore.c
Tricking malloc into returning a nearly-arbitrary pointer by abusing the smallbin freelist.
- Version: Latest
- Debug: ⏩ Browser Debug
house_of_force.c
Exploiting the Top Chunk (Wilderness) header to get malloc to return a nearly-arbitrary pointer.
- Version: < 2.29
- Patch: Top chunk size check
- Debug: ⏩ Browser Debug
- CTF: Boston Key Party 2016-cookbook, BCTF 2016-bcloud
house_of_einherjar.c
Exploiting a single null byte overflow to trick malloc into returning a controlled pointer.
- Version: Latest
- Debug: ⏩ Browser Debug
- CTF: Seccon 2016-tinypad
house_of_orange.c
Exploiting the Top Chunk (Wilderness) to gain arbitrary code execution.
- Version: < 2.26
- Patch: abort() changes
- Debug: ⏩ Browser Debug
- CTF: Hitcon 2016 houseoforange
Bin & Chunk Manipulation
Techniques that manipulate bin freelists and chunk metadata to achieve overlapping allocations or arbitrary writes.unsafe_unlink.c
Exploiting free on a corrupted chunk to get arbitrary write.
- Version: Latest
- Debug: ⏩ Browser Debug
- CTF: HITCON CTF 2014-stkof, Insomni’hack 2017-Wheel of Robots
poison_null_byte.c
Exploiting a single null byte overflow.
- Version: Latest
- Debug: ⏩ Browser Debug
- CTF: PlaidCTF 2015-plaiddb, BalsnCTF 2019-PlainNote
overlapping_chunks.c
Exploit the overwrite of a freed chunk size in the unsorted bin to make a new allocation overlap with an existing chunk.
- Version: < 2.29
- Patch: Size validation
- Debug: ⏩ Browser Debug
- CTF: hack.lu CTF 2015-bookstore, Nuit du Hack 2016-night-deamonic-heap
overlapping_chunks_2.c
Exploit the overwrite of an in use chunk size to make a new allocation overlap with an existing chunk.
- Version: < 2.29
- Patch: Size validation
- Debug: ⏩ Browser Debug
- Note: Variant of overlapping_chunks targeting in-use chunks. See main overlapping_chunks page for details.
mmap_overlapping_chunks.c
Exploit an in use mmap chunk to make a new allocation overlap with a current mmap chunk.
- Version: Latest
unsorted_bin_into_stack.c
Exploiting the overwrite of a freed chunk on unsorted bin freelist to return a nearly-arbitrary pointer.
- Version: < 2.29
- Patch: Unsorted bin checks
- Debug: ⏩ Browser Debug
unsorted_bin_attack.c
Exploiting the overwrite of a freed chunk on unsorted bin freelist to write a large value into arbitrary address.
- Version: < 2.29
- Patch: Unsorted bin checks
- Debug: ⏩ Browser Debug
- CTF: 0ctf 2016-zerostorage
large_bin_attack.c
Exploiting the overwrite of a freed chunk on large bin freelist to write a large value into arbitrary address.
- Version: Latest
- Debug: ⏩ Browser Debug
- CTF: 0ctf 2018-heapstorm2
Advanced Techniques
Sophisticated exploitation methods including safe-linking bypasses and advanced primitives.decrypt_safe_linking.c
Decrypt the poisoned value in linked list to recover the actual pointer.
- Version: >= 2.32
- Debug: ⏩ Browser Debug
- Requirement: Safe-linking introduced in glibc 2.32
safe_link_double_protect.c
Leakless bypass for PROTECT_PTR by protecting a pointer twice, allowing for arbitrary pointer linking in t-cache.
- Version: >= 2.32
- CTF: 37c3 Potluck - Tamagoyaki
sysmalloc_int_free.c
Demonstrating freeing the nearly arbitrary sized Top Chunk (Wilderness) using malloc (sysmalloc
_int_free()).- Version: Latest
Complete Technique Index
Here’s the complete table from the original repository with all techniques:This table is kept up-to-date with the main repository and includes version-specific information for each technique.
| Technique | Version | Patch | CTF Challenges | Debug |
|---|---|---|---|---|
| first_fit.c | All | - | - | - |
| calc_tcache_idx.c | All | - | - | - |
| fastbin_dup.c | Latest | - | - | ⏩ |
| fastbin_dup_into_stack.c | Latest | - | 9447-search-engine, 0ctf 2017-babyheap | ⏩ |
| fastbin_dup_consolidate.c | Latest | - | Hitcon 2016 SleepyHolder | ⏩ |
| unsafe_unlink.c | Latest | - | HITCON CTF 2014-stkof, Insomni’hack 2017-Wheel of Robots | ⏩ |
| house_of_spirit.c | Latest | - | hack.lu CTF 2014-OREO | ⏩ |
| poison_null_byte.c | Latest | - | PlaidCTF 2015-plaiddb, BalsnCTF 2019-PlainNote | ⏩ |
| house_of_lore.c | Latest | - | - | ⏩ |
| overlapping_chunks.c | < 2.29 | Link | hack.lu CTF 2015-bookstore, Nuit du Hack 2016 | ⏩ |
| overlapping_chunks_2.c | < 2.29 | Link | - | ⏩ |
| mmap_overlapping_chunks.c | Latest | - | - | - |
| house_of_force.c | < 2.29 | Link | Boston Key Party 2016-cookbook, BCTF 2016-bcloud | ⏩ |
| unsorted_bin_into_stack.c | < 2.29 | Link | - | ⏩ |
| unsorted_bin_attack.c | < 2.29 | Link | 0ctf 2016-zerostorage | ⏩ |
| large_bin_attack.c | Latest | - | 0ctf 2018-heapstorm2 | ⏩ |
| house_of_einherjar.c | Latest | - | Seccon 2016-tinypad | ⏩ |
| house_of_water.c | Latest | - | 37c3 Potluck - Tamagoyaki | - |
| sysmalloc_int_free.c | Latest | - | - | - |
| house_of_orange.c | < 2.26 | Link | Hitcon 2016 houseoforange | ⏩ |
| house_of_tangerine.c | >= 2.26 | - | PicoCTF 2024 - high frequency troubles | - |
| house_of_roman.c | < 2.29 | Link | - | ⏩ |
| tcache_poisoning.c | >= 2.26 | Link | - | ⏩ |
| tcache_house_of_spirit.c | >= 2.26 | - | - | ⏩ |
| house_of_botcake.c | >= 2.26 | - | - | ⏩ |
| tcache_stashing_unlink_attack.c | >= 2.26 | - | Hitcon 2019 one punch man | ⏩ |
| fastbin_reverse_into_tcache.c | >= 2.26 | - | - | ⏩ |
| house_of_mind_fastbin.c | Latest | - | - | ⏩ |
| house_of_storm.c | < 2.29 | - | - | ⏩ |
| house_of_gods.c | < 2.27 | - | - | ⏩ |
| decrypt_safe_linking.c | >= 2.32 | - | - | ⏩ |
| safe_link_double_protect.c | >= 2.32 | - | 37c3 Potluck - Tamagoyaki | - |
| tcache_dup.c (obsolete) | 2.26 - 2.28 | Link | - | - |
| tcache_metadata_poisoning.c | >= 2.26 | - | - | - |
| house_of_io.c | 2.31 - 2.33 | - | - | - |
| tcache_relative_write.c | >= 2.30 | - | - | - |
Version Evolution
Many techniques have multiple implementations for different glibc versions. The repository maintains these in version-specific directories:Next Steps
By glibc Version
View techniques organized by glibc version
Glossary
Learn key heap exploitation terminology
Heap Basics
Understand heap internals before diving into techniques
Setup Guide
Set up your environment for testing techniques
