how2heap: glibc heap techniques with version bounds and the patches that closed them
A repository for learning various heap exploitation techniques.
At a glance
- What is it?
- An educational C repository of glibc heap exploitation demonstrations, organised one directory per libc release from 2.23 to 2.43, where each entry is scoped to the allocator version it was verified against and, where a fix exists, linked to the upstream commit that fixed the behaviour, with an obsolete directory for the ones that stopped reproducing.
- Who is it for?
- how2heap suits someone learning how a glibc allocator can be misused, on a Debian-based system where they can fetch the matching libc source and step through the behaviour in a debugger. If you need something that works against a current glibc, check the version column: several techniques are marked latest, while others apply only below 2.43 or below 2.29.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 9 days ago.
- What is it written in?
- Mainly C, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 15, 2026, and from our analysis. They are not legal advice.
Star history
- shellphish/how2heap8,980 ★ · +89
| Repository | 2026-09-22 | 2026-11-15 |
|---|---|---|
| shellphish/how2heap | 8.9k | 9k |
89 Stars in the last 54 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
Each technique names the allocator version and the fix that closed it
The technique table is the reason this repository is more than a pile of snippets, and two of its columns do the work. One records which glibc versions a technique applies to, and the other links to the specific upstream sourceware commit that patched the behaviour. The fastbin techniques are marked as applying below a 2.43 boundary and carry a patch reference. Unsafe unlink, house of spirit, poison null byte and house of lore are marked as current. The unsorted-bin and top-chunk techniques are marked below 2.29 and also carry patch links. That combination turns each entry into a dated claim rather than folklore: you can see not only whether something works but which release stopped it and where the fix landed, which is the difference between a technique you understand and one you have merely copied.
Sixteen allocator versions, plus a directory for what stopped working
The tree is organised by allocator version, one directory per glibc release, running from 2.23 through 2.43 with gaps at 2.25, 2.26, 2.28, 2.29 and 2.30. Because a technique lives in the directory of the libc it targets, the same technique appears in several directories, each copy adjusted for that version. Alongside those sits a directory of material that no longer reproduces, so a technique that worked years ago is retained rather than deleted, which is more useful than losing it. There is also a directory holding the machinery that fetches libc builds, and a separate file tracking changes in glibc itself. The consequence for a reader is that you can pick the directory matching the libc you actually have, and can still read the historical version of a technique rather than finding it gone.
The default build uses your system libc, not a pinned one
There is one setting on the makefile that changes what you are actually testing, and it is set the opposite way from what the front page implies. A variable for using the system libc is defined, and when it has not been set it is enabled, so the default build links against whatever allocator your distribution ships. The front page calls Ubuntu's libc releases the gold standard and says each technique is verified against them, which is true of the pinned builds rather than of your default build. The other targets let you build every technique for one named version, build all binaries, or run the tests for a version, and the help output gives a recent version as the example for each. So the consequence is that reproducing the documented results means turning the system-libc behaviour off, and the default is a convenience rather than the reference environment.
A warning about freeing non-heap pointers is switched off on purpose
The compile flags include a language standard, debugging symbols and two suppressed warnings, and the second of those is the interesting one. It disables the compiler warning that fires when a non-heap object is freed, which is exactly the operation that several techniques in this repository perform deliberately to corrupt allocator metadata. That single flag is the clearest statement of intent in the build configuration. The consequence for anyone reading a build log is that a clean compile here does not mean the same thing it means in another project: one class of diagnostic is off by design, so the absence of a warning is not evidence that the code is doing something safe. The other suppressed warning is -Wno-unused-result.
The container prepares an environment and then opens a shell
The Dockerfile is short and does not compile anything, which is easy to miss and changes how you use it. It starts from a long-term-support Ubuntu release, installs a toolchain along with patchelf, a Python interpreter and its package installer, installs one Python package, clones the repository at shallow depth, relaxes git's safe-directory check globally, sets the repository as the working directory, and ends with a `run bash` line. So the image is a prepared environment rather than a build artefact, and the compiling happens interactively after you enter it. The two dependencies worth understanding are patchelf, which is what makes it possible to bind a downloaded libc build to a locally compiled binary, and the Python interpreter, which exists for the download scripts rather than for anything you will write.
The list of supported versions is regenerated, not hand-maintained
Before any libc is fetched, a preparation rule does two things: it initialises the downloader submodule recursively, and it runs that project's own update script. Each per-version download rule then looks its version up in a list file, falls back to a second older list when the current one has no matching entry for the target architecture, removes any previously extracted copy, and runs a download script. The list of downloadable libc builds therefore comes from the downloader's update script, but the versions this repository targets are still a hand-written VERSIONS list in the makefile, from 2.23 to 2.43, each with its own glibc_ directory. The fallback branch exists because the downloader keeps two files, list and old_list, and a version with no match in the first is fetched from the second with the download_old script.
Three root programs teach the allocator before anything misuses it
Two files at the repository root exist to demonstrate correct behaviour rather than incorrect behaviour, and the base build target is exactly those two plus a third. One demonstrates the allocator's first-fit behaviour, which is the policy decision that decides where a freed chunk ends up and therefore the precondition for most of the techniques. Another demonstrates how the per-thread cache computes its index, which is the detail that the fastbin and tcache techniques depend on. The third is a playground program. The consequence is that there is a deliberate order here: the base target is separate from the technique builds, and the base programs are the ones you should read first, because almost every entry in the version directories is a deliberate violation of a rule established in one of those three files.
Editorial conclusion
how2heap suits someone learning how a glibc allocator can be misused, on a Debian-based system where they can fetch the matching libc source and step through the behaviour in a debugger. If you need something that works against a current glibc, check the version column: several techniques are marked latest, while others apply only below 2.43 or below 2.29. Before building, decide whether to link the system libc or let the makefile download pinned builds, read the version column for the specific technique, and start with the base examples before the technique directories.
Frequently asked questions
What is how2heap and what is it for?
An educational C repository of heap exploitation demonstrations against glibc, created after a hack meeting and published under the MIT licence. The aim is to show how the allocator can be misused, with each technique written as a small program that can be compiled, run and stepped through in a debugger.
How do I build and run the how2heap examples?
Clone the repository, then use the makefile targets: a base target builds the three root programs, a version target builds all techniques for one glibc release, and a test target runs the techniques for a version. The container image is an alternative route, since it prepares the toolchain and opens a shell in the repository rather than building anything itself.
Do the how2heap techniques still work on a current glibc?
Each technique is scoped to the glibc version it was verified against, and the table links to the upstream patch that changed the behaviour. Several are marked as current, while the fastbin techniques are marked as applying below a 2.43 boundary and others below 2.29. Techniques that stopped reproducing are kept in an obsolete directory.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/shellphish-how2heap)Star history chart for your README
[](https://hysenlabs.com/projects/shellphish-how2heap)Was this useful?