House of Cinder: a use-after-free to RCE chain on glibc 2.44
A use-after-free in a note-taking program allows reading and writing freed heap chunks, which the author exploits to leak addresses and corrupt allocator metadata, ultimately achieving code execution by forging a FILE structure that is triggered at program exit.
medium.com
Published on medium.com
Pwn
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
This is a heap-exploitation write-up rather than a web finding. The target is glibc 2.44, released 2026-07-25, on x86-64, and the goal is a single use-after-free driven through tcache metadata into control flow at exit(). The technique is named House of Cinder, and the authors are Vxmp and malloc-consolidate.

we both r dumb at this, trust
The demo target is a small note-keeper binary (vuln.c) with a menu of add, delete, edit, view and exit. The bug is in delete(): it frees the note but never clears the slot, so edit() and view() keep operating on a dangling pointer. That gives a read-after-free for leaks and a write-after-free for metadata corruption on an attacker-sized chunk. This is stage ① (Ember) and it is the only bug in the chain.
The motivation is that by 2.44 most classic Houses no longer work. __malloc_hook and __free_hook were removed in 2.34. Safe-linking (2.32) mangles tcache and fastbin fd pointers. IO_validate_vtable (2.24) restricts FILE vtables. The tcache was substantially rewritten in 2.42, a change most existing writeups predate. House of Force is gone too, removed by the 2.29 top-chunk check. The question the authors ask is therefore: given one realistic bug, what is the shortest path to code execution on the current allocator, and which mitigations are met along the way?
The original design routed the _IO_list_all plant through a largebin attack. On 2.44 that did not survive as a direct plant because the bz#24216 nextsize check aborts it, so tcache poisoning does the write instead. The largebin attack is still a live write primitive, and the authors keep it in the post because exactly why it cannot plant _IO_list_all on 2.44 is the instructive part, and because it is the engine behind House of Banana and Apple when the target's current value cooperates with the check.

What's dead and what lives on glibc 2.44

this image was rendered with markdown (when will medium support tables)
Setup
Threat model as stated:
- Target is glibc 2.44, x86-64, with standard mitigations on: ASLR, NX, full RELRO. The demo binary is built with
-no-pie -fno-stack-protector. - Bug: a use-after-free giving read-after-free (leaks) and write-after-free (metadata corruption) on an attacker-sized chunk.
- Goal: a shell at normal process exit, with a libc leak.
The vulnerable function, in full:
static void delete(void) { int i = pick_index(); if (i < 0 || notes[i] == NULL) { puts("bad index"); return; } free(notes[i]); }
The reproducible environment is a Docker image that clones the glibc-2.44 tag, configures with --disable-werror --enable-debug=yes, installs to /opt/glibc-2.44, and installs pwntools and one_gadget. The Makefile links the demo against that loader and library with -O0 -g -no-pie -fno-stack-protector -Wall, -Wl,--dynamic-linker=$(LD) and -Wl,-rpath=$(LIB).
Finding it
The starting point is the tcache bookkeeping change. Pre-2.42 the structure was:
typedef struct tcache_perthread_struct { char counts[TCACHE_MAX_BINS]; tcache_entry *entries[TCACHE_MAX_BINS];} tcache_perthread_struct;
On glibc 2.44 (malloc/malloc.c:2707-2724) it is:
typedef struct tcache_perthread_struct { uint16_t num_slots[TCACHE_MAX_BINS]; tcache_entry *entries[TCACHE_MAX_BINS];} tcache_perthread_struct;
Three consequences bite an exploit:
num_slotscounts down. It is the number of remaining free slots, not a used count.tcache_put_ndoes--num_slots[idx],tcache_get_ndoes++num_slots[idx], and it is initialised tomp_.tcache_count(malloc.c:3049). If you forge atcache_perthread_struct, a zero means full, not empty.- Bins grew but the default ceiling did not.
TCACHE_SMALL_BINS = 64,TCACHE_LARGE_BINS = 12,TCACHE_MAX_BINS = 76(malloc.c:288-290), and with a tunabletcache_max_bytescan reach 4 MB. By default the large tcache bins are inert:mp_.tcache_max_bytes = MAX_TCACHE_SMALL_SIZE + 1(malloc.c:1663) andMAX_TCACHE_SMALL_SIZE = tidx2csize(63) = 63*0x10 + 0x20 = 0x410, so the ceiling is0x411, exactly the classic0x410-chunk boundary. The free path gates onsize < mp_.tcache_max_bytes(malloc.c:3151), so a0x430chunk is not cached and reaches the unsorted bin / largebin with no draining, just like pre-2.42. The 4 MB behaviour only appears if someone raisesglibc.malloc.tcache_max_bytes(malloc.c:4772-4778). The authors verified on the live 2.44 build that a freed0x430chunk lands in the unsorted bin. tcacheis never NULL. A new__tcache_dummyzero-struct (malloc.c:2726-2770) is pointed at until a real tcache is allocated, so the old "is tcache initialised yet" tricks do not apply.
The free path also moved: the tcache-fill logic now lives in __libc_free, not _int_free (malloc.c:3150-3176):
tcache_entry *e = (tcache_entry *) chunk2mem (p);if (__glibc_unlikely (e->key == tcache_key)) return tcache_double_free_verify (e);if (tc_idx < TCACHE_SMALL_BINS) { if (tcache->num_slots[tc_idx] != 0) return tcache_put (p, tc_idx);}
Safe-linking is byte-for-byte the 2.32 macro (malloc.c:316-327):
#define PROTECT_PTR(pos, ptr) \ ((__typeof (ptr)) ((((size_t) pos) >> 12) ^ ((size_t) ptr)))#define REVEAL_PTR(ptr) PROTECT_PTR (&ptr, ptr)
Only the chain next is mangled; the entries[] base is not. A lone freed tcache chunk therefore has next = (&next >> 12) ^ NULL = &next >> 12. Reading it through the UAF recovers the heap base with heap = leak << 12, and that one read neutralises safe-linking for the rest of the chain.
The libc leak is the classic one: a lone chunk freed into the unsorted bin has fd = bk = unsorted-bin head, which lives inside main_arena. Every stale writeup hardcodes that head at main_arena + 0x60 (+96). On 2.44 that constant is wrong. malloc_state was reorganised, and reading the field offsets straight out of the built libc's DWARF gives:
offsetof(struct malloc_state, top) = 0x08offsetof(struct malloc_state, last_remainder) = 0x10offsetof(struct malloc_state, bins) = 0x18
bin_at(av, 1) is &bins[0] - 0x10, so the unsorted-bin head is at 0x18 - 0x10 = main_arena + 0x8, not +0x60. The PoC therefore does libc.address = unsorted_leak - (main_arena_sym + 0x8). Confirmed on the live build: the leaked fd equals &main_arena + 0x8 across runs, and that slot in turn points back at the freed chunk. Anything that still subtracts 0x60 lands 0x58 low and every subsequent libc address is wrong. This is a layout change independent of --enable-debug; it is baked into the struct the allocator compiles against.
Exploitation
Step 1: leaks through the UAF
With the heap base known, poisoning is the familiar dance, adjusted for 2.42 bookkeeping:
- free a chunk into a small tcache bin,
- UAF-overwrite its
nextwithPROTECT_PTR(&chunk, TARGET), - allocate twice; the second allocation returns
TARGET.
Two 2.44 guardrails must be respected. Alignment: tcache_get_n aborts with "malloc(): unaligned tcache chunk detected" (misaligned_mem, malloc.c:2856) unless TARGET is 16-byte aligned. The key: the double-free check compares e->key == tcache_key, so corrupt the key field if you are recycling a chunk that still carries it.
The forged _IO_FILE_plus, _IO_wide_data and wide vtable are assembled in a plain chunk the exploit owns (forge, at a deterministic heap_base + 0x7e0). Then TARGET = _IO_list_all and the second poisoned allocation writes &forge into it. _IO_list_all is 16-byte aligned, so the alignment guardrail is satisfied. That single write is the plant: on the live build it is what makes exit() dispatch the forged FILE. Building the FILE in a chunk fully controlled by the attacker, rather than in a chunk the attack hands over, keeps fp's _flags writable instead of colliding with a chunk header.
Step 2: why the largebin attack does not plant on 2.44
The unsorted to largebin insertion in _int_malloc (malloc.c:3756-3817) still contains the classic write primitive, but on 2.44 the bz#24216 nextsize check guards it in both insertion branches. The "smaller than the smallest in the bin" branch, the one a two-chunk setup hits, is:
fwd = bck; bck = bck->bk;if (__glibc_unlikely (fwd->fd->bk_nextsize->fd_nextsize != fwd->fd)) malloc_printerr ("malloc(): largebin double linked list corrupted (nextsize)");victim->fd_nextsize = fwd->fd;victim->bk_nextsize = fwd->fd->bk_nextsize;fwd->fd->bk_nextsize = victim->bk_nextsize->fd_nextsize = victim;
The classic plant sets L1->bk_nextsize = _IO_list_all - 0x20 so the final line writes &L2 into _IO_list_all. But the check runs first: with L1->bk_nextsize = _IO_list_all - 0x20, it evaluates (_IO_list_all - 0x20)->fd_nextsize, i.e. *(_IO_list_all), and aborts unless that already equals L1. _IO_list_all points at a real libc FILE (&_IO_2_1_stdout_), never at the heap chunk, so the check fails. Confirmed on the live 2.44 build: the exact two-chunk setup aborts with
malloc(): largebin double linked list corrupted (nextsize)
This is not a 2.44 regression. It is the post-2.30 reality that a single-chunk largebin write can only land &victim where the target's current contents cooperate with the nextsize check, and _IO_list_all does not cooperate. The largebin attack stays in the toolbox as a write primitive (it still powers House of Banana against _rtld_global, and House-of-Apple variants where the target is attacker-staged), but it is the wrong tool for this plant. The plant is done with tcache poisoning, which writes an unconstrained value and lets _IO_list_all point at a fully controlled chunk. fd_nextsize sits at +0x20 in a large chunk, which is why the classic target is target - 0x20, kept here for the record. The 0x430-chunk sizing needs no "above tcache_max_bytes" trick either: the default tcache ceiling is still 0x410, so those chunks reach a real largebin on their own.
Step 3: House of Apple 2 on 2.44
malloc-consolidate verified this from the source code.
IO_validate_vtable (libio/libioP.h:1041) requires the FILE's vtable to lie inside one relro array:
static inline const struct _IO_jump_t *IO_validate_vtable (const struct _IO_jump_t *vtable) { uintptr_t offset = (uintptr_t) vtable - (uintptr_t) &__io_vtables; if (__glibc_unlikely (offset >= IO_VTABLES_LEN)) _IO_vtable_check (); return vtable;}
On 2.44 all libio vtables were consolidated into that single __io_vtables[] array, and _IO_wfile_jumps is an alias into it (libio/vtables.c:561-567). Setting the FILE's outer vtable to the real _IO_wfile_jumps therefore passes the check. House of Apple 2 never fights the outer check; it uses a legitimate vtable on purpose.
The gap is the unchecked nested vtable. The wide-char dispatch macros (libioP.h) are not validated:
#define _IO_WIDE_JUMPS(THIS) \ _IO_CAST_FIELD_ACCESS ((THIS), struct _IO_FILE, _wide_data)->_wide_vtable#define _IO_WIDE_JUMPS_FUNC(THIS) _IO_WIDE_JUMPS (THIS)#define WJUMP0(FUNC, THIS) (_IO_WIDE_JUMPS_FUNC (THIS)->FUNC) (THIS)#define _IO_WDOALLOCATE(FP) WJUMP0 (__doallocate, FP)
Where the narrow path _IO_JUMPS_FUNC runs IO_validate_vtable, _IO_WIDE_JUMPS_FUNC is a bare dereference of fp->_wide_data->_wide_vtable. Control _wide_data and you control the call.
The call path from exit() is exit() to __run_exit_handlers to _IO_cleanup to _IO_flush_all, which walks _IO_list_all (genops.c:709-755):
for (fp = (FILE *) _IO_list_all; fp != NULL; fp = fp->_chain) { if ((fp->_flags2 & _IO_FLAGS2_NOCLOSE) == 0) if (((fp->_mode <= 0 && fp->_IO_write_ptr > fp->_IO_write_base) || ...) && _IO_OVERFLOW (fp, EOF) == EOF) }
_IO_OVERFLOW goes through the validated outer vtable, which is fine because it is _IO_wfile_jumps, whose __overflow is _IO_wfile_overflow. That drops into the wide path:
_IO_wfile_overflow(fp) -> _IO_wdoallocbuf(fp) if !(fp->_flags & _IO_UNBUFFERED 0x2) _IO_WDOALLOCATE(fp)
That final indirect call is unchecked. Put one_gadget (or system) at _wide_vtable + 0x68, and fp, the forged FILE, is passed in rdi. On the live 2.44 build no one_gadget's constraints hold at this site, so Cinder uses system.
The forged FILE, with offsets on 2.44 verified from source:
_flags @0x00 = " /bin/sh\0"_IO_write_base@0x20 = 0_IO_write_ptr @0x28 = 1_wide_data @0xa0 = &fake_wide_data_mode @0xc0 = 0vtable @0xd8 = _IO_wfile_jumps
fake_wide_data._IO_buf_base @0x30 = 0fake_wide_data._IO_write_base = 0fake_wide_data._wide_vtable @0xe0 = &fake_wide_vtablefake_wide_vtable[0x68] (__doallocate) = system # one_gadget if one holds
With system, _flags holds " /bin/sh" and rdi = fp, so system(fp) == system(" /bin/sh\0..."). There are no register constraints to satisfy. The two leading spaces keep _flags' low bits clear for the FSOP path above, and system skips them harmlessly. The _IO_FILE_plus, _IO_wide_data and _IO_jump_t offsets are identical to the historic layout on 2.44; a _short_backupbuf[1] field was added but is layout-neutral because it fits the bitfield padding. The wide gadget is at +0x68 (__doallocate), exactly as in every prior House-of-Apple-2 writeup.
Step 4: the full chain
① UAF via delete() without nulling the pointer free a 0x428 chunk -> unsorted bin -> view() -> libc base free a 0x58 chunk -> tcache -> view() -> heap base (<<12)② tcache poison -> assemble fake _IO_FILE_plus + _IO_wide_data in a known 16-byte-aligned heap chunk, then poison a second tcache next so an alloc is served at _IO_list_all and the write stores &fake_file there -> *(_IO_list_all) = &fake_file③ largebin attack (bk_nextsize = _IO_list_all - 0x20) is a live write *primitive*, but NOT the plant: the bz#24216 nextsize check aborts a direct _IO_list_all largebin write (§3.4), so Spark's tcache poison does the write instead④ menu option 5 -> return 0 -> exit() -> _IO_cleanup -> _IO_flush_all -> _IO_OVERFLOW(fake_file) -> _IO_wfile_overflow -> _IO_wdoallocbuf -> _IO_WDOALLOCATE -> fake->_wide_data->_wide_vtable[0x68](fake) == system(" /bin/sh") ==> shell
The exploit script in the appendix follows that chain. It defines add, delete, edit and leak8 helpers against the menu, plus a protect helper that computes the safe-linked pointer:
def protect(pos, ptr): return (pos >> 12) ^ ptr
It allocates a 0x28 guard chunk and frees it. It then allocates a 0x428 chunk, frees it, and reads the unsorted-bin leak to set libc.address = main_arena_leak - (libc.sym.main_arena + 8). It then allocates a 0x428 chunk and a 0x68 chunk, frees the 0x428 chunk for the libc leak, frees the 0x68 chunk, and reads the tcache next to get heap_base = leak8(3) << 12. The forged FILE is staged at forge = heap_base + 0x7e0, with wide_data = forge + 0x100, wide_vtable = forge + 0x200 and lock = forge + 0x300, written through edit on the 0x4f8 chunk. The payload sets _flags to b" /bin/sh\x00", _IO_write_base to 0, _IO_write_ptr to 1, _wide_data to wide_data, _mode to 0, the vtable to _IO_wfile_jumps, the wide-data fields, and wide_vtable[0x68] to system. Two 0x58 chunks are allocated, both freed, and the second is edited with the protected pointer to _IO_list_all:
edit(5, p64(protect(poisonA, IO_list_all)))
Two more allocations follow, the second carrying p64(forge), which lands &forge in _IO_list_all. The script then selects menu option 5 and sends echo CINDER_SHELL_$(id -u)_OK to confirm the shell.
Root cause
The defect is the missing notes[i] = NULL after free(notes[i]) in delete(), which leaves a dangling pointer that edit() and view() still accept. Everything after that is allocator state: the UAF gives both the leaks and the metadata write, and the write is turned into control flow through the tcache and the FILE machinery.
The existing defences did not stop it because each one is bypassed rather than broken. Safe-linking is defeated by reading the mangled next of a lone tcache chunk and shifting it left by 12 to recover the heap base. The vtable check is satisfied by pointing the outer vtable at the legitimate _IO_wfile_jumps, and the unchecked wide dispatch is what actually gets called. The largebin nextsize check does stop the direct _IO_list_all plant, which is why the write is done with tcache poisoning instead. The __malloc_hook and __free_hook removal is irrelevant because the chain never needed them.
Impact
Under the stated threat model, an attacker with the use-after-free gets a shell at normal process exit, with a libc leak, on glibc 2.44 x86-64 with ASLR, NX and full RELRO enabled. The demo binary is built without PIE and without a stack protector, and the exploit relies on a deterministic heap layout (heap_base + 0x7e0 for the forged FILE). The report does not describe a remote or real-world deployment of the bug; it is a technique demonstration against the demo binary.
Fix
The report does not describe a patch to glibc. The bug being exploited is in the demo program, and the obvious correction there is to clear the slot after freeing it so that edit() and view() reject the dangling index. On the allocator side, the report documents the 2.44 behaviour as it stands: the nextsize check already blocks the direct largebin plant, while the unchecked wide vtable dispatch remains the path used by House of Apple 2.
Variants to test
- A freed chunk of
0x430or larger on 2.44: if it lands in the unsorted bin rather than a tcache bin, the defaulttcache_max_bytesceiling of0x411is behaving as described. - A lone freed tcache chunk read through a UAF: if
nextshifted left by 12 gives a plausible heap base, safe-linking is neutralised for the rest of the chain. - An unsorted-bin leak on 2.44: if the leaked
fdequals&main_arena + 0x8and points back at the freed chunk, themalloc_statelayout is the one described here; subtracting0x60instead lands0x58low. - The two-chunk largebin setup with
L1->bk_nextsize = _IO_list_all - 0x20: a positive result for the check is an abort withmalloc(): largebin double linked list corrupted (nextsize); the plant only works where the target's current contents equalL1. - A forged FILE with the outer vtable set to
_IO_wfile_jumpsand_wide_vtable[0x68]set tosystem: ifexit()reaches_IO_WDOALLOCATEandrdiis the forged FILE, the wide dispatch is unchecked as described. - A poisoned tcache
nextaimed at a target that is not 16-byte aligned: a positive result is the abortmalloc(): unaligned tcache chunk detected. - A forged
tcache_perthread_structwithnum_slotsset to zero: if the bin is treated as full rather than empty, the counting direction is confirmed.
What happened, in plain words
This is a story about a small program that keeps notes, and about a bug in it that lets an attacker take over the whole program. The program is not a website and not a phone app. It is a command-line program that runs on Linux, the operating system that powers most servers. The bug is called a use-after-free, and the article shows how one such bug can be turned into running an attacker's own command, in this case a shell, which is a prompt where you can type commands and the computer obeys.
The article is written by two people, Vxmp and malloc-consolidate, and it is aimed at people who already know a lot about how memory works inside a program. This version is for someone who does not. So before we get to the trick, we need to explain a few ideas from zero: what memory is, what an allocator is, what a heap is, what a use-after-free is, and what a shell is.
Here is the short version of the whole story, so you know where we are going. A program asks the operating system for small blocks of memory while it runs. It keeps track of those blocks in a list. The note-keeper program has a delete button that gives a block back to the system but forgets to remove it from the list. So the program still thinks the block is its own, and the user can still read from it and write to it. That is the use-after-free. The attacker uses the leftover read to learn where important things live in memory, and the leftover write to plant a fake object. When the program shuts down, it looks at that fake object and calls a function the attacker chose. The function is system, which runs a command. The command is /bin/sh, which starts a shell. Game over.
The rest of this article walks through that in the same order as the technical write-up: the context, the setup, the discovery of the bug, the exploitation in four steps, the root cause, the impact, the fix, and some variants to test. Every code block is copied exactly as it appears in the write-up, and after each one there is a plain-words explanation of what it does.

we both r dumb at this, trust
Context
This is a heap-exploitation write-up, not a web finding. That sentence needs unpacking. Heap exploitation is the craft of abusing the part of a program's memory called the heap. A web finding is a bug in a website, like a login form that lets you in without a password. This is not that. This is about memory inside a running program on a Linux machine.
The target is glibc 2.44, released on 2026-07-25, on x86-64. glibc is the GNU C Library, the standard set of building blocks that almost every program on Linux uses, including the part that hands out memory. Version 2.44 is a specific release of it. x86-64 is the family of processors used in most laptops and servers. The goal is a single use-after-free driven through tcache metadata into control flow at exit(). We will explain each of those words as they come up, but in one sentence: one bug, used to trick the memory manager into running the attacker's code when the program exits.
The technique is named House of Cinder, and the authors are Vxmp and malloc-consolidate. The name is a tradition in this field: people give memorable names to families of tricks, like "House of Force" or "House of Apple". It is a bit like naming a chess opening.
The demo target is a small note-keeper binary (vuln.c) with a menu of add, delete, edit, view and exit. A binary is a compiled program, the file you actually run. The note-keeper is a toy program written for the demonstration. It shows a menu, you type a number, and it does one of five things: add a note, delete a note, edit a note, view a note, or exit.
The bug is in delete(): it frees the note but never clears the slot, so edit() and view() keep operating on a dangling pointer. A pointer is a number that says where something lives in memory, like a house address. A dangling pointer is an address that used to be valid but now points at something that has been given back, like a house that has been demolished but whose address is still written in your address book. If you go there, you might find a new building, or rubble, or someone else's furniture. The program does not check, so it happily reads and writes there.
That gives a read-after-free for leaks and a write-after-free for metadata corruption on an attacker-sized chunk. A leak, in this context, means reading a value out of memory that the program did not intend to show you, usually an address. An address is valuable because it tells you where things are, which is the first thing you need to attack them. Metadata is the bookkeeping information the memory manager keeps about each block, like the size of the block and a pointer to the next free block. Corrupting it means changing that bookkeeping so the manager does what you want. A chunk is one block of memory handed out by the allocator. Attacker-sized means the attacker chooses how big it is, because the program lets you type the size.
This is stage ① (Ember) and it is the only bug in the chain. The authors number the stages and give them names, like chapters in a book. Ember is the first stage, the bug itself. Everything after it is not a new bug, just clever use of this one.
The motivation is that by 2.44 most classic Houses no longer work. Over the years, the defenders have closed the old tricks one by one, and the article lists them:
__malloc_hookand__free_hookwere removed in 2.34. These were special function pointers that the memory manager called on every allocation and free. If you could overwrite them, you got code execution for free. They were removed because they were too dangerous.- Safe-linking (2.32) mangles tcache and fastbin
fdpointers. Safe-linking is a defence that scrambles the pointers stored in free lists, so an attacker who overwrites one cannot simply point it anywhere. Mangles means scrambles. We will see exactly how later. IO_validate_vtable(2.24) restricts FILE vtables. A vtable is a table of function pointers, a list of "when this happens, call that function". FILE is the internal object glibc uses to represent an open file or stream. The check makes sure the vtable points into a known, read-only list, so an attacker cannot swap in their own.- The tcache was substantially rewritten in 2.42, a change most existing writeups predate. The tcache is a small, fast cache of recently freed chunks. Rewriting it changed the rules of several tricks, and older articles describe the old rules.
- House of Force is gone too, removed by the 2.29 top-chunk check. House of Force was a trick that let an attacker ask for a huge allocation and wrap around memory. The top-chunk check stopped it.
The question the authors ask is therefore: given one realistic bug, what is the shortest path to code execution on the current allocator, and which mitigations are met along the way? A mitigation is a defence. The allocator is the part of glibc that hands out and takes back memory. The question is: with all these defences in place, what is the shortest route from one bug to running your own code, and which defences do you bump into on the way?
The original design routed the _IO_list_all plant through a largebin attack. _IO_list_all is a global variable in glibc that holds a pointer to a linked list of all open FILE objects. When the program exits, glibc walks that list and flushes each FILE, which means calling functions on it. If you can make _IO_list_all point at a fake FILE you control, you control what gets called. That is called a plant: you plant a fake object where the program will later pick it up. A largebin attack is one specific trick for writing a value to an address, using the largebin, which is a data structure the allocator uses for big free chunks.
On 2.44 that did not survive as a direct plant because the bz#24216 nextsize check aborts it, so tcache poisoning does the write instead. bz#24216 is a bug report number in the glibc bug tracker. The check added because of it stops the largebin trick from writing where it used to. Aborts means the program deliberately crashes with an error message instead of continuing. So the authors switched to tcache poisoning, which is a different way of getting the allocator to write a value of your choosing to an address of your choosing.
The largebin attack is still a live write primitive, and the authors keep it in the post because exactly why it cannot plant _IO_list_all on 2.44 is the instructive part, and because it is the engine behind House of Banana and Apple when the target's current value cooperates with the check. A write primitive is a reliable way to write a chosen value somewhere. House of Banana and House of Apple are other named techniques that use the same largebin write. Cooperates with the check means the value already at the target address happens to match what the check expects, which is rare but sometimes true.

What's dead and what lives on glibc 2.44

this image was rendered with markdown (when will medium support tables)
This section is a table, rendered as an image, summarising which old tricks still work and which do not on glibc 2.44. The caption is a joke about the publishing platform not supporting tables.
Setup
The threat model as stated is a list of assumptions about the attacker and the target. A threat model is like the rules of a game: what the attacker can do, what the defender has, and what counts as a win.
- Target is glibc 2.44, x86-64, with standard mitigations on: ASLR, NX, full RELRO. The demo binary is built with
-no-pie -fno-stack-protector. - Bug: a use-after-free giving read-after-free (leaks) and write-after-free (metadata corruption) on an attacker-sized chunk.
- Goal: a shell at normal process exit, with a libc leak.
Let us explain the defences named here, because they matter later.
ASLR stands for Address Space Layout Randomisation. Every time a program starts, the operating system puts its code, its libraries and its heap at random addresses. This means an attacker cannot hardcode an address; they have to leak one first. That is why the leaks matter so much.
NX stands for No-eXecute. It marks memory as either writable or executable, not both. So an attacker cannot simply write their own machine code into memory and jump to it. They have to reuse existing code instead.
RELRO stands for RELocation Read-Only. It makes certain tables of function pointers read-only after the program starts, so an attacker cannot overwrite them. Full RELRO is the strongest version.
-no-pie means the demo binary is not position-independent, so its own code sits at a fixed address. -fno-stack-protector means the compiler did not add a canary, a random value that detects stack buffer overflows. These two flags make the demo easier to exploit, which is fine because the point is to demonstrate the technique, not to build a hardened target.
A shell at normal process exit means the attacker does not need to crash the program or trigger a special path. They just let the program exit normally, and the exit path runs their code. A libc leak means they know where glibc is loaded in memory, which they need to find functions like system.
The vulnerable function, in full:
static void delete(void) { int i = pick_index(); if (i < 0 || notes[i] == NULL) { puts("bad index"); return; } free(notes[i]); }
Line by line:
static void delete(void) {starts a function calleddeletethat takes no arguments and returns nothing.staticmeans it is only visible inside this file.int i = pick_index();asks the user which note to delete, and stores the answer ini.if (i < 0 || notes[i] == NULL) { puts("bad index"); return; }checks that the index is valid and that the slot is not empty. If either check fails, it prints "bad index" and returns without doing anything.free(notes[i]);gives the memory block back to the allocator. This is the crucial line. After it, the block is no longer owned by the program, but the pointernotes[i]still holds its address.}closes the function.
The missing line is notes[i] = NULL; after the free. If that line were there, the slot would be marked empty, and edit() and view() would refuse to touch it. Because it is missing, the slot still looks valid, and the program will happily read and write freed memory.
The reproducible environment is a Docker image that clones the glibc-2.44 tag, configures with --disable-werror --enable-debug=yes, installs to /opt/glibc-2.44, and installs pwntools and one_gadget. Docker is a tool that packages a program and everything it needs into a container, so anyone can reproduce the same setup. Cloning a tag means downloading a specific version of the source code from a version control system. --enable-debug=yes builds glibc with extra debugging information, which helps when you are studying it. pwntools is a Python library for writing exploits. one_gadget is a tool that finds short sequences in a library that, if jumped to, run a shell.
The Makefile links the demo against that loader and library with -O0 -g -no-pie -fno-stack-protector -Wall, -Wl,--dynamic-linker=$(LD) and -Wl,-rpath=$(LIB). A Makefile is a recipe for building a program. The loader is the small program that loads a binary and its libraries into memory. Linking against a specific loader and library means the demo uses the glibc 2.44 you just built, not the one installed on your system. -O0 turns off optimisation, which keeps the code easy to read. -g includes debugging symbols. -Wall turns on all compiler warnings.
Finding it
The starting point is the tcache bookkeeping change. The tcache is a per-thread cache of freed chunks. When a program frees a small chunk, glibc does not immediately put it back into the general pool; it puts it in the tcache, a short list of recently freed chunks, so that the next allocation of the same size can be served instantly. Each size class has its own list, called a bin. A bin is just a list of free chunks of a certain size.
Pre-2.42 the structure was:
typedef struct tcache_perthread_struct { char counts[TCACHE_MAX_BINS]; tcache_entry *entries[TCACHE_MAX_BINS];} tcache_perthread_struct;
Line by line:
typedef struct tcache_perthread_struct {starts the definition of a structure, a bundle of related fields stored together in memory.typedefgives it a name you can use later.char counts[TCACHE_MAX_BINS];is an array of small numbers, one per bin, counting how many chunks are in each bin.charis one byte, enough for a count up to 255.tcache_entry *entries[TCACHE_MAX_BINS];is an array of pointers, one per bin, each pointing at the first free chunk in that bin.tcache_entryis the type of a free chunk.} tcache_perthread_struct;closes the definition.
On glibc 2.44 (malloc/malloc.c:2707-2724) it is:
typedef struct tcache_perthread_struct { uint16_t num_slots[TCACHE_MAX_BINS]; tcache_entry *entries[TCACHE_MAX_BINS];} tcache_perthread_struct;
Line by line:
typedef struct tcache_perthread_struct {starts the same structure again.uint16_t num_slots[TCACHE_MAX_BINS];replaces the oldcountsarray.uint16_tis an unsigned 16-bit integer, so it can hold a number up to 65535. The name changed fromcountstonum_slots, and that name change is a clue: it now counts free slots, not used chunks.tcache_entry *entries[TCACHE_MAX_BINS];is the same array of pointers as before.} tcache_perthread_struct;closes it.
Three consequences bite an exploit:
num_slotscounts down. It is the number of remaining free slots, not a used count.tcache_put_ndoes--num_slots[idx],tcache_get_ndoes++num_slots[idx], and it is initialised tomp_.tcache_count(malloc.c:3049). If you forge atcache_perthread_struct, a zero means full, not empty.- Bins grew but the default ceiling did not.
TCACHE_SMALL_BINS = 64,TCACHE_LARGE_BINS = 12,TCACHE_MAX_BINS = 76(malloc.c:288-290), and with a tunabletcache_max_bytescan reach 4 MB. By default the large tcache bins are inert:mp_.tcache_max_bytes = MAX_TCACHE_SMALL_SIZE + 1(malloc.c:1663) andMAX_TCACHE_SMALL_SIZE = tidx2csize(63) = 63*0x10 + 0x20 = 0x410, so the ceiling is0x411, exactly the classic0x410-chunk boundary. The free path gates onsize < mp_.tcache_max_bytes(malloc.c:3151), so a0x430chunk is not cached and reaches the unsorted bin / largebin with no draining, just like pre-2.42. The 4 MB behaviour only appears if someone raisesglibc.malloc.tcache_max_bytes(malloc.c:4772-4778). The authors verified on the live 2.44 build that a freed0x430chunk lands in the unsorted bin. tcacheis never NULL. A new__tcache_dummyzero-struct (malloc.c:2726-2770) is pointed at until a real tcache is allocated, so the old "is tcache initialised yet" tricks do not apply.
Let us unpack those three points, because they are the heart of the discovery.
Point 1: the counter now counts down. Imagine a car park with 7 spaces. The old counter said "7 cars parked". The new counter says "7 spaces free". When a car parks, the new counter goes down to 6. When a car leaves, it goes up to 7. If you forge this structure, you have to remember the direction. A zero in the new counter means the car park is full, not empty. Getting this backwards is a classic mistake, and the authors are warning the reader about it.
Point 2: the bins grew, but the default ceiling did not. The tcache now has 76 bins instead of the old number, and if someone changes a setting called tcache_max_bytes, it can cache chunks up to 4 MB. But by default, the ceiling is 0x411 bytes. 0x410 is hexadecimal for 1040. The calculation 63*0x10 + 0x20 = 0x410 is the size of the largest small bin. So a chunk of 0x430 bytes is just above the ceiling and is not cached; it goes into the unsorted bin, which is the general pool of free chunks before they are sorted into size-specific bins. The unsorted bin is where the libc leak comes from, as we will see. The authors verified this on the live build: a freed 0x430 chunk lands in the unsorted bin. The 4 MB behaviour only appears if someone raises the setting, which is not the default.
Point 3: the tcache is never NULL. In older glibc, the tcache was created lazily, so at the very start of a program it did not exist yet, and some tricks relied on that. Now there is a dummy zero-struct that the pointer points at until a real tcache is allocated, so the pointer is never NULL. The old tricks do not apply.
The free path also moved: the tcache-fill logic now lives in __libc_free, not _int_free (malloc.c:3150-3176):
tcache_entry *e = (tcache_entry *) chunk2mem (p);if (__glibc_unlikely (e->key == tcache_key)) return tcache_double_free_verify (e);if (tc_idx < TCACHE_SMALL_BINS) { if (tcache->num_slots[tc_idx] != 0) return tcache_put (p, tc_idx);}
Line by line:
tcache_entry *e = (tcache_entry *) chunk2mem (p);converts the pointer to the chunk into a pointer to the usable memory inside it.chunk2memis a helper that skips the chunk header.eis now a pointer to the user data area.if (__glibc_unlikely (e->key == tcache_key))checks whether the chunk'skeyfield matches a global value.__glibc_unlikelyis a hint to the compiler that this is rarely true, which helps performance. Thekeyfield is used to detect double frees.return tcache_double_free_verify (e);if the key matches, it calls a function to verify whether this is a double free, and returns its result. A double free is freeing the same chunk twice, which is a bug attackers like to trigger.if (tc_idx < TCACHE_SMALL_BINS) {checks whether the chunk's size class is one of the small bins that the tcache handles.if (tcache->num_slots[tc_idx] != 0)checks whether there is at least one free slot in that bin. Remember, the counter counts down, so non-zero means there is room.return tcache_put (p, tc_idx);puts the chunk into the tcache and returns.}closes the block.
The important change is that this logic now lives in __libc_free, the public free function, rather than _int_free, the internal one. This matters for exploit writers because it changes which code path runs and when.
Safe-linking is byte-for-byte the 2.32 macro (malloc.c:316-327):
#define PROTECT_PTR(pos, ptr) \ ((__typeof (ptr)) ((((size_t) pos) >> 12) ^ ((size_t) ptr)))#define REVEAL_PTR(ptr) PROTECT_PTR (&ptr, ptr)
Line by line:
#define PROTECT_PTR(pos, ptr) \starts a macro, a piece of text that the compiler substitutes wherever it is used. It takes two arguments:pos, the address where the pointer is stored, andptr, the pointer value itself.((__typeof (ptr)) ((((size_t) pos) >> 12) ^ ((size_t) ptr)))is the body. It takespos, shifts it right by 12 bits, and XORs the result withptr. XOR is a bitwise operation: it returns 1 where the bits differ and 0 where they match. Shifting right by 12 is the same as dividing by 4096, which is the size of a memory page. The result is a scrambled pointer.#define REVEAL_PTR(ptr) PROTECT_PTR (&ptr, ptr)defines the reverse operation, using the address of the pointer itself aspos.
Only the chain next is mangled; the entries[] base is not. A lone freed tcache chunk therefore has next = (&next >> 12) ^ NULL = &next >> 12. Reading it through the UAF recovers the heap base with heap = leak << 12, and that one read neutralises safe-linking for the rest of the chain.
Let us walk through that. When a chunk is freed into the tcache, its next field is set to point at the previous head of the bin. If the bin was empty, next is NULL. Safe-linking scrambles that pointer by XORing it with the address of the field itself, shifted right by 12. If the pointer was NULL, the scrambled value is just the address of the field shifted right by 12. That is a value derived from the heap address. If you can read it through the use-after-free, you can shift it left by 12 and recover the heap base. The heap base is the starting address of the heap, and once you know it, you know where everything in the heap is. That is why one read neutralises safe-linking: you can now compute the scrambled form of any pointer you want to write, because you know the address of the field and the target.
The libc leak is the classic one: a lone chunk freed into the unsorted bin has fd = bk = unsorted-bin head, which lives inside main_arena. fd and bk are the forward and backward pointers of a doubly linked list. The unsorted bin is a doubly linked list of free chunks. Its head is a field inside main_arena, a global structure in glibc that holds the state of the allocator. If you free a chunk into the unsorted bin and it is the only one there, its fd and bk both point at the head, which is inside glibc. Reading that pointer through the use-after-free gives you a glibc address, and from that you can compute the base address of glibc. That is the libc leak.
Every stale writeup hardcodes that head at main_arena + 0x60 (+96). On 2.44 that constant is wrong. malloc_state was reorganised, and reading the field offsets straight out of the built libc's DWARF gives:
offsetof(struct malloc_state, top) = 0x08offsetof(struct malloc_state, last_remainder) = 0x10offsetof(struct malloc_state, bins) = 0x18
Line by line:
offsetof(struct malloc_state, top) = 0x08says thetopfield is 8 bytes from the start of the structure.topis the pointer to the top chunk, the remaining free memory at the end of the heap.offsetof(struct malloc_state, last_remainder) = 0x10sayslast_remainderis 16 bytes from the start. It is a leftover chunk from a previous split.offsetof(struct malloc_state, bins) = 0x18says thebinsarray starts 24 bytes from the start. The bins are the lists of free chunks.
DWARF is a standard format for debugging information embedded in compiled programs. Reading the offsets from it means looking at the actual built library rather than guessing.
bin_at(av, 1) is &bins[0] - 0x10, so the unsorted-bin head is at 0x18 - 0x10 = main_arena + 0x8, not +0x60. The PoC therefore does libc.address = unsorted_leak - (main_arena_sym + 0x8). Confirmed on the live build: the leaked fd equals &main_arena + 0x8 across runs, and that slot in turn points back at the freed chunk. Anything that still subtracts 0x60 lands 0x58 low and every subsequent libc address is wrong. This is a layout change independent of --enable-debug; it is baked into the struct the allocator compiles against.
In plain words: the old articles say the unsorted-bin head is 96 bytes into main_arena. On 2.44 it is 8 bytes in. If you use the old number, every address you compute is off by 0x58, and your exploit fails in confusing ways. The authors checked this on the live build, and it is a real change in the structure layout, not an artefact of building with debug information.
Exploitation
Step 1: leaks through the UAF
With the heap base known, poisoning is the familiar dance, adjusted for 2.42 bookkeeping:
- free a chunk into a small tcache bin,
- UAF-overwrite its
nextwithPROTECT_PTR(&chunk, TARGET), - allocate twice; the second allocation returns
TARGET.
Let us explain tcache poisoning from zero. The tcache is a linked list of free chunks. Each free chunk has a next pointer to the next free chunk. When you allocate, the allocator takes the chunk at the head of the list and makes the next chunk the new head. If you can overwrite the next pointer of a free chunk, you can make the list point anywhere. Then the first allocation returns the real chunk, and the second allocation returns whatever address you put in next. That is an arbitrary allocation: you get a chunk at an address of your choosing. If you then write to that chunk, you have an arbitrary write: you can write a value of your choosing to an address of your choosing. That is the most powerful primitive in memory exploitation.
Safe-linking makes this harder because the next pointer is scrambled. But you know the heap base, so you can compute the scrambled form of any pointer using PROTECT_PTR. That is what step 2 does.
Two 2.44 guardrails must be respected. Alignment: tcache_get_n aborts with "malloc(): unaligned tcache chunk detected" (misaligned_mem, malloc.c:2856) unless TARGET is 16-byte aligned. Alignment means the address is a multiple of 16. Many processors and data structures require this, and glibc now checks it. If you aim at an address that is not a multiple of 16, the program aborts. The key: the double-free check compares e->key == tcache_key, so corrupt the key field if you are recycling a chunk that still carries it. The key field is a marker glibc writes into a freed chunk to detect double frees. If you free a chunk, then free it again, the key is still there and glibc notices. If you want to recycle a chunk that still has the key, you have to overwrite the key field first.
The forged _IO_FILE_plus, _IO_wide_data and wide vtable are assembled in a plain chunk the exploit owns (forge, at a deterministic heap_base + 0x7e0). Then TARGET = _IO_list_all and the second poisoned allocation writes &forge into it. _IO_list_all is 16-byte aligned, so the alignment guardrail is satisfied. That single write is the plant: on the live build it is what makes exit() dispatch the forged FILE. Building the FILE in a chunk fully controlled by the attacker, rather than in a chunk the attack hands over, keeps fp's _flags writable instead of colliding with a chunk header.
Let us unpack the fake objects. _IO_FILE_plus is the full internal representation of a FILE in glibc: the basic _IO_FILE structure plus a pointer to its vtable. _IO_wide_data is a companion structure used for wide-character streams. A wide vtable is a table of function pointers for wide-character operations. The authors build all three in a chunk they control, at a known offset from the heap base. Then they use tcache poisoning to write the address of that chunk into _IO_list_all. When the program exits, glibc walks _IO_list_all and treats the forged chunk as a real FILE. The detail about _flags is subtle: if the fake FILE were built inside a chunk that still had a chunk header in front of it, the _flags field would overlap the header and might not be writable. Building it in a plain chunk avoids that.
Step 2: why the largebin attack does not plant on 2.44
The unsorted to largebin insertion in _int_malloc (malloc.c:3756-3817) still contains the classic write primitive, but on 2.44 the bz#24216 nextsize check guards it in both insertion branches. The "smaller than the smallest in the bin" branch, the one a two-chunk setup hits, is:
fwd = bck; bck = bck->bk;if (__glibc_unlikely (fwd->fd->bk_nextsize->fd_nextsize != fwd->fd)) malloc_printerr ("malloc(): largebin double linked list corrupted (nextsize)");victim->fd_nextsize = fwd->fd;victim->bk_nextsize = fwd->fd->bk_nextsize;fwd->fd->bk_nextsize = victim->bk_nextsize->fd_nextsize = victim;
Line by line:
fwd = bck; bck = bck->bk;sets up two pointers.bckis the bin's head, andbkis its backward pointer. This is walking the doubly linked list.if (__glibc_unlikely (fwd->fd->bk_nextsize->fd_nextsize != fwd->fd))is the check. It follows a chain of pointers: fromfwdto its forward neighbour, to that neighbour'sbk_nextsize, to that one'sfd_nextsize, and compares the result withfwd. If they do not match, the list is inconsistent.malloc_printerr ("malloc(): largebin double linked list corrupted (nextsize)");prints an error and aborts the program. This is the check that stops the classic attack.victim->fd_nextsize = fwd->fd;sets the victim's forward nextsize pointer.victim->bk_nextsize = fwd->fd->bk_nextsize;sets the victim's backward nextsize pointer.fwd->fd->bk_nextsize = victim->bk_nextsize->fd_nextsize = victim;is the write primitive. It writesvictiminto two places at once. In the classic attack, one of those places is the target address.
The classic plant sets L1->bk_nextsize = _IO_list_all - 0x20 so the final line writes &L2 into _IO_list_all. But the check runs first: with L1->bk_nextsize = _IO_list_all - 0x20, it evaluates (_IO_list_all - 0x20)->fd_nextsize, i.e. *(_IO_list_all), and aborts unless that already equals L1. _IO_list_all points at a real libc FILE (&_IO_2_1_stdout_), never at the heap chunk, so the check fails. Confirmed on the live 2.44 build: the exact two-chunk setup aborts with
malloc(): largebin double linked list corrupted (nextsize)
This is not a 2.44 regression. It is the post-2.30 reality that a single-chunk largebin write can only land &victim where the target's current contents cooperate with the nextsize check, and _IO_list_all does not cooperate. The largebin attack stays in the toolbox as a write primitive (it still powers House of Banana against _rtld_global, and House-of-Apple variants where the target is attacker-staged), but it is the wrong tool for this plant. The plant is done with tcache poisoning, which writes an unconstrained value and lets _IO_list_all point at a fully controlled chunk. fd_nextsize sits at +0x20 in a large chunk, which is why the classic target is target - 0x20, kept here for the record. The 0x430-chunk sizing needs no "above tcache_max_bytes" trick either: the default tcache ceiling is still 0x410, so those chunks reach a real largebin on their own.
In plain words: the largebin attack is a clever way to write a value, but it comes with a safety check. The check looks at what is already at the target address and refuses to proceed unless it matches. _IO_list_all already points at a real FILE, not at the attacker's chunk, so the check fails and the program aborts. This is not new in 2.44; it has been true since 2.30. The largebin attack is still useful against other targets where the existing value happens to match, such as _rtld_global, which is used by House of Banana. But for this particular plant, tcache poisoning is the right tool because it writes an unconstrained value: you can write anything anywhere, no check on the old contents.
Step 3: House of Apple 2 on 2.44
malloc-consolidate verified this from the source code. That means one of the authors read the actual glibc source and confirmed the behaviour, rather than relying on older articles.
IO_validate_vtable (libio/libioP.h:1041) requires the FILE's vtable to lie inside one relro array:
static inline const struct _IO_jump_t *IO_validate_vtable (const struct _IO_jump_t *vtable) { uintptr_t offset = (uintptr_t) vtable - (uintptr_t) &__io_vtables; if (__glibc_unlikely (offset >= IO_VTABLES_LEN)) _IO_vtable_check (); return vtable;}
Line by line:
static inline const struct _IO_jump_t *IO_validate_vtable (const struct _IO_jump_t *vtable) {defines a function that takes a vtable pointer and returns a validated vtable pointer.static inlinemeans it is meant to be inlined into the caller for speed.uintptr_t offset = (uintptr_t) vtable - (uintptr_t) &__io_vtables;computes the distance between the given vtable and the start of the global array__io_vtables.uintptr_tis an integer type big enough to hold a pointer.if (__glibc_unlikely (offset >= IO_VTABLES_LEN))checks whether the vtable is outside the array.IO_VTABLES_LENis the length of the array._IO_vtable_check ();if it is outside, calls a function that will abort the program.return vtable;otherwise returns the vtable unchanged.}closes the function.
On 2.44 all libio vtables were consolidated into that single __io_vtables[] array, and _IO_wfile_jumps is an alias into it (libio/vtables.c:561-567). So setting the FILE's outer vtable to the real _IO_wfile_jumps therefore passes the check. House of Apple 2 never fights the outer check; it uses a legitimate vtable on purpose.
This is the key insight. The defence checks the outer vtable, the one directly attached to the FILE. If you point it at a real, legitimate vtable, the check passes. You are not trying to sneak a fake vtable past the check. You are using a real one, and then exploiting a different, unchecked path inside it.
The gap is the unchecked nested vtable. The wide-char dispatch macros (libioP.h) are not validated:
#define _IO_WIDE_JUMPS(THIS) \ _IO_CAST_FIELD_ACCESS ((THIS), struct _IO_FILE, _wide_data)->_wide_vtable#define _IO_WIDE_JUMPS_FUNC(THIS) _IO_WIDE_JUMPS (THIS)#define WJUMP0(FUNC, THIS) (_IO_WIDE_JUMPS_FUNC (THIS)->FUNC) (THIS)#define _IO_WDOALLOCATE(FP) WJUMP0 (__doallocate, FP)
Line by line:
#define _IO_WIDE_JUMPS(THIS) \starts a macro that takes a FILE pointer calledTHIS._IO_CAST_FIELD_ACCESS ((THIS), struct _IO_FILE, _wide_data)->_wide_vtableaccesses the_wide_datafield of the FILE, then the_wide_vtablefield inside it. No validation.#define _IO_WIDE_JUMPS_FUNC(THIS) _IO_WIDE_JUMPS (THIS)is a convenience alias.#define WJUMP0(FUNC, THIS) (_IO_WIDE_JUMPS_FUNC (THIS)->FUNC) (THIS)calls the function namedFUNCfrom the wide vtable, passingTHISas the argument.#define _IO_WDOALLOCATE(FP) WJUMP0 (__doallocate, FP)calls the__doallocateentry of the wide vtable.
Where the narrow path _IO_JUMPS_FUNC runs IO_validate_vtable, _IO_WIDE_JUMPS_FUNC is a bare dereference of fp->_wide_data->_wide_vtable. Control _wide_data and you control the call. In plain words: the outer vtable is checked, but the inner wide vtable is not. If you control the _wide_data pointer, you control where the inner vtable is, and therefore what function gets called.
The call path from exit() is exit() to __run_exit_handlers to _IO_cleanup to _IO_flush_all, which walks _IO_list_all (genops.c:709-755):
for (fp = (FILE *) _IO_list_all; fp != NULL; fp = fp->_chain) { if ((fp->_flags2 & _IO_FLAGS2_NOCLOSE) == 0) if (((fp->_mode <= 0 && fp->_IO_write_ptr > fp->_IO_write_base) || ...) && _IO_OVERFLOW (fp, EOF) == EOF) }
Line by line:
for (fp = (FILE *) _IO_list_all; fp != NULL; fp = fp->_chain) {starts a loop over the linked list of FILEs.fpis the current FILE, starting at_IO_list_all, and each iteration moves tofp->_chain, the next FILE in the list.if ((fp->_flags2 & _IO_FLAGS2_NOCLOSE) == 0)checks a flag. If the NOCLOSE flag is not set, it proceeds.if (((fp->_mode <= 0 && fp->_IO_write_ptr > fp->_IO_write_base) || ...)checks whether the FILE has pending output._modeis the stream mode, and_IO_write_ptr > _IO_write_basemeans there is data waiting to be written.&& _IO_OVERFLOW (fp, EOF) == EOF)calls_IO_OVERFLOW, which flushes the FILE.EOFis the end-of-file constant.}closes the loop.
_IO_OVERFLOW goes through the validated outer vtable, which is fine because it is _IO_wfile_jumps, whose __overflow is _IO_wfile_overflow. That drops into the wide path:
_IO_wfile_overflow(fp) -> _IO_wdoallocbuf(fp) if !(fp->_flags & _IO_UNBUFFERED 0x2) _IO_WDOALLOCATE(fp)
Line by line:
_IO_wfile_overflow(fp)is the function called by the outer vtable.-> _IO_wdoallocbuf(fp)calls a helper that allocates a buffer for wide characters.if !(fp->_flags & _IO_UNBUFFERED 0x2)checks whether the FILE is unbuffered. If it is not, it proceeds._IO_WDOALLOCATE(fp)calls the wide allocate function, which goes through the unchecked wide vtable.
That final indirect call is unchecked. Put one_gadget (or system) at _wide_vtable + 0x68, and fp, the forged FILE, is passed in rdi. On the live 2.44 build no one_gadget's constraints hold at this site, so Cinder uses system.
An indirect call is a call to a function whose address is stored in a variable, rather than written directly in the code. rdi is a register, one of the small, fast storage locations inside the processor. On x86-64, the first argument to a function is passed in rdi. So if the function called is system, and rdi holds the forged FILE, then system receives the forged FILE as its argument. If the first bytes of the forged FILE are the string /bin/sh, then system runs /bin/sh, which is the shell. A one_gadget is a short sequence of instructions already in glibc that, if jumped to, runs a shell. It is convenient because you do not need to pass arguments. But one_gadget comes with constraints: the registers must hold certain values. On this build, none of the one_gadgets' constraints hold at this call site, so the authors use system instead, which has no such constraints.
The forged FILE, with offsets on 2.44 verified from source:
_flags @0x00 = " /bin/sh\0"_IO_write_base@0x20 = 0_IO_write_ptr @0x28 = 1_wide_data @0xa0 = &fake_wide_data_mode @0xc0 = 0vtable @0xd8 = _IO_wfile_jumps
Line by line:
_flags @0x00 = " /bin/sh\0"sets the first field of the FILE to the string/bin/shwith two leading spaces and a null terminator. The null terminator marks the end of the string. The two spaces are there to keep the low bits of_flagsclear, which matters for the FSOP path. FSOP stands for File Stream Oriented Programming, the general technique of abusing FILE structures._IO_write_base @0x20 = 0sets the start of the write buffer to zero._IO_write_ptr @0x28 = 1sets the write pointer to one, which is greater than the base, so the check for pending output passes._wide_data @0xa0 = &fake_wide_datapoints the FILE at the fake wide data structure._mode @0xc0 = 0sets the mode to zero, which is less than or equal to zero, so the check passes.vtable @0xd8 = _IO_wfile_jumpspoints the outer vtable at the real, legitimate_IO_wfile_jumps, so the outer check passes.
fake_wide_data._IO_buf_base @0x30 = 0fake_wide_data._IO_write_base = 0fake_wide_data._wide_vtable @0xe0 = &fake_wide_vtablefake_wide_vtable[0x68] (__doallocate) = system # one_gadget if one holds
Line by line:
fake_wide_data._IO_buf_base @0x30 = 0sets the wide buffer base to zero.fake_wide_data._IO_write_base = 0sets the wide write base to zero.fake_wide_data._wide_vtable @0xe0 = &fake_wide_vtablepoints the wide data at the fake wide vtable.fake_wide_vtable[0x68] (__doallocate) = systemputs the address ofsystemat offset0x68in the fake wide vtable, which is the slot for__doallocate. The comment notes that a one_gadget could go here instead if one's constraints held.
With system, _flags holds " /bin/sh" and rdi = fp, so system(fp) == system(" /bin/sh\0..."). There are no register constraints to satisfy. The two leading spaces keep _flags' low bits clear for the FSOP path above, and system skips them harmlessly. The _IO_FILE_plus, _IO_wide_data and _IO_jump_t offsets are identical to the historic layout on 2.44; a _short_backupbuf[1] field was added but is layout-neutral because it fits the bitfield padding. The wide gadget is at +0x68 (__doallocate), exactly as in every prior House-of-Apple-2 writeup.
In plain words: the fake FILE is a carefully arranged block of bytes. The first bytes spell /bin/sh, so when system is called with a pointer to the FILE, it sees a command. The rest of the fields are set so that the checks along the way pass, and so that the final unchecked call goes to system. The offsets are the same as in older versions, so the technique is portable.
Step 4: the full chain
① UAF via delete() without nulling the pointer free a 0x428 chunk -> unsorted bin -> view() -> libc base free a 0x58 chunk -> tcache -> view() -> heap base (<<12)② tcache poison -> assemble fake _IO_FILE_plus + _IO_wide_data in a known 16-byte-aligned heap chunk, then poison a second tcache next so an alloc is served at _IO_list_all and the write stores &fake_file there -> *(_IO_list_all) = &fake_file③ largebin attack (bk_nextsize = _IO_list_all - 0x20) is a live write *primitive*, but NOT the plant: the bz#24216 nextsize check aborts a direct _IO_list_all largebin write (§3.4), so Spark's tcache poison does the write instead④ menu option 5 -> return 0 -> exit() -> _IO_cleanup -> _IO_flush_all -> _IO_OVERFLOW(fake_file) -> _IO_wfile_overflow -> _IO_wdoallocbuf -> _IO_WDOALLOCATE -> fake->_wide_data->_wide_vtable[0x68](fake) == system(" /bin/sh") ==> shell
Line by line:
① UAF via delete() without nulling the pointeris the first stage, the bug itself. The delete function frees the note but does not clear the pointer.free a 0x428 chunk -> unsorted bin -> view() -> libc basefrees a chunk of size0x428, which is above the tcache ceiling, so it goes into the unsorted bin. Viewing it through the use-after-free leaks a glibc address, giving the libc base.free a 0x58 chunk -> tcache -> view() -> heap base (<<12)frees a small chunk into the tcache. Viewing it leaks the scramblednextpointer, which shifted left by 12 gives the heap base.② tcache poison -> assemble fake _IO_FILE_plus + _IO_wide_datais the second stage. The fake objects are built in a chunk the attacker controls.in a known 16-byte-aligned heap chunk, then poison a second tcache next so an alloc is served at _IO_list_all and the write stores &fake_file there -> *(_IO_list_all) = &fake_fileuses tcache poisoning to make an allocation return the address of_IO_list_all, then writes the address of the fake FILE there.③ largebin attack (bk_nextsize = _IO_list_all - 0x20) is a live write *primitive*, but NOT the plantexplains why the largebin attack is not used for the plant: the nextsize check aborts it.the bz#24216 nextsize check aborts a direct _IO_list_all largebin write (§3.4), so Spark's tcache poison does the write insteadsays the tcache poisoning does the write. Spark is the name of this stage.④ menu option 5 -> return 0 -> exit()is the trigger. The user chooses exit from the menu, the program returns frommain, and the C runtime callsexit().-> _IO_cleanup -> _IO_flush_all -> _IO_OVERFLOW(fake_file)is the chain of functions that runs during exit. It walks the FILE list and calls_IO_OVERFLOWon the fake FILE.-> _IO_wfile_overflow -> _IO_wdoallocbuf -> _IO_WDOALLOCATEis the path through the wide-character code, ending in the unchecked call.-> fake->_wide_data->_wide_vtable[0x68](fake) == system(" /bin/sh") ==> shellis the final call. The unchecked wide vtable slot holdssystem, and the argument is the fake FILE, whose first bytes are/bin/sh. The result is a shell.
The exploit script in the appendix follows that chain. It defines add, delete, edit and leak8 helpers against the menu, plus a protect helper that computes the safe-linked pointer:
def protect(pos, ptr): return (pos >> 12) ^ ptr
Line by line:
def protect(pos, ptr):defines a function that takes the address where the pointer will be stored (pos) and the pointer value (ptr).return (pos >> 12) ^ ptrshiftsposright by 12 and XORs it withptr, which is exactly the safe-linking formula. The result is the scrambled pointer to write.
It allocates a 0x28 guard chunk and frees it. It then allocates a 0x428 chunk, frees it, and reads the unsorted-bin leak to set libc.address = main_arena_leak - (libc.sym.main_arena + 8). A guard chunk is a small allocation used to keep things in place or to trigger a particular allocator behaviour. The subtraction converts the leaked address into the base address of glibc, using the corrected offset of 8 instead of the old 0x60.
It then allocates a 0x428 chunk and a 0x68 chunk, frees the 0x428 chunk for the libc leak, frees the 0x68 chunk, and reads the tcache next to get heap_base = leak8(3) << 12. The 0x428 chunk goes into the unsorted bin and provides the libc leak. The 0x68 chunk goes into the tcache and provides the heap leak. Shifting left by 12 undoes the safe-linking shift.
The forged FILE is staged at forge = heap_base + 0x7e0, with wide_data = forge + 0x100, wide_vtable = forge + 0x200 and lock = forge + 0x300, written through edit on the 0x4f8 chunk. These are fixed offsets from the heap base, so the layout is deterministic. The 0x4f8 chunk is large enough to hold the whole fake FILE and its companion structures.
The payload sets _flags to b" /bin/sh\x00", _IO_write_base to 0, _IO_write_ptr to 1, _wide_data to wide_data, _mode to 0, the vtable to _IO_wfile_jumps, the wide-data fields, and wide_vtable[0x68] to system. This is the same layout as the table above, written out as bytes.
Two 0x58 chunks are allocated, both freed, and the second is edited with the protected pointer to _IO_list_all:
edit(5, p64(protect(poisonA, IO_list_all)))
Line by line:
edit(5, ...)edits note number 5, which is one of the freed chunks.p64(...)packs a 64-bit integer into 8 bytes, the format the program expects.protect(poisonA, IO_list_all)computes the safe-linked form of the address_IO_list_all, usingpoisonAas the address where the pointer will be stored.
This overwrites the next pointer of the freed chunk so that the tcache list now points at _IO_list_all.
Two more allocations follow, the second carrying p64(forge), which lands &forge in _IO_list_all. The first allocation returns the real chunk, and the second returns _IO_list_all, so writing to it writes to _IO_list_all. The value written is the address of the forged FILE. The script then selects menu option 5 and sends echo CINDER_SHELL_$(id -u)_OK to confirm the shell. id -u prints the user ID, so the output confirms which user the shell is running as.
Root cause
The defect is the missing notes[i] = NULL after free(notes[i]) in delete(), which leaves a dangling pointer that edit() and view() still accept. Everything after that is allocator state: the UAF gives both the leaks and the metadata write, and the write is turned into control flow through the tcache and the FILE machinery.
In plain words: the root cause is one missing line. The rest is not a new bug, just a consequence. The use-after-free gives the attacker both the ability to read freed memory and the ability to write to it. The read gives addresses. The write gives control of the allocator's bookkeeping. The bookkeeping gives an arbitrary write. The arbitrary write gives control of the FILE list. The FILE list gives a function call. The function call gives a shell.
The existing defences did not stop it because each one is bypassed rather than broken. Safe-linking is defeated by reading the mangled next of a lone tcache chunk and shifting it left by 12 to recover the heap base. The vtable check is satisfied by pointing the outer vtable at the legitimate _IO_wfile_jumps, and the unchecked wide dispatch is what actually gets called. The largebin nextsize check does stop the direct _IO_list_all plant, which is why the write is done with tcache poisoning instead. The __malloc_hook and __free_hook removal is irrelevant because the chain never needed them.
This is an important lesson: defences are not a wall, they are a series of obstacles. Each one closes a path, but the attacker looks for another path. The vtable check is bypassed by using a real vtable. Safe-linking is bypassed by leaking the key. The nextsize check is bypassed by using a different write primitive. The removal of the hooks is irrelevant because the attacker found a different target.
Impact
Under the stated threat model, an attacker with the use-after-free gets a shell at normal process exit, with a libc leak, on glibc 2.44 x86-64 with ASLR, NX and full RELRO enabled. The demo binary is built without PIE and without a stack protector, and the exploit relies on a deterministic heap layout (heap_base + 0x7e0 for the forged FILE). The report does not describe a remote or real-world deployment of the bug; it is a technique demonstration against the demo binary.
In plain words: the impact is full control of the program. The attacker can run any command as the user running the program. The defences that are enabled do not stop it. But the demonstration is against a toy program, not a real service. The report does not claim that any real product is vulnerable. It is a proof of concept, a demonstration that the technique works on the current version of glibc.
Fix
The report does not describe a patch to glibc. The bug being exploited is in the demo program, and the obvious correction there is to clear the slot after freeing it so that edit() and view() reject the dangling index. On the allocator side, the report documents the 2.44 behaviour as it stands: the nextsize check already blocks the direct largebin plant, while the unchecked wide vtable dispatch remains the path used by House of Apple 2.
In plain words: the fix for the demo is one line, notes[i] = NULL; after the free. The report does not propose a fix for glibc itself. It documents the current behaviour: one defence (the nextsize check) works, and another (the wide vtable dispatch) is still unchecked.
Variants to test
Here are several things a reader can try, to confirm the behaviour described. These are like experiments: if you see the expected result, you know your understanding is correct.
- A freed chunk of
0x430or larger on 2.44: if it lands in the unsorted bin rather than a tcache bin, the defaulttcache_max_bytesceiling of0x411is behaving as described. - A lone freed tcache chunk read through a UAF: if
nextshifted left by 12 gives a plausible heap base, safe-linking is neutralised for the rest of the chain. - An unsorted-bin leak on 2.44: if the leaked
fdequals&main_arena + 0x8and points back at the freed chunk, themalloc_statelayout is the one described here; subtracting0x60instead lands0x58low. - The two-chunk largebin setup with
L1->bk_nextsize = _IO_list_all - 0x20: a positive result for the check is an abort withmalloc(): largebin double linked list corrupted (nextsize); the plant only works where the target's current contents equalL1. - A forged FILE with the outer vtable set to
_IO_wfile_jumpsand_wide_vtable[0x68]set tosystem: ifexit()reaches_IO_WDOALLOCATEandrdiis the forged FILE, the wide dispatch is unchecked as described. - A poisoned tcache
nextaimed at a target that is not 16-byte aligned: a positive result is the abortmalloc(): unaligned tcache chunk detected. - A forged
tcache_perthread_structwithnum_slotsset to zero: if the bin is treated as full rather than empty, the counting direction is confirmed.
Each of these is a small experiment. You change one thing, run the program, and see whether the result matches the prediction. If it does, you have confirmed that your mental model of glibc 2.44 is correct. If it does not, you have learned something new, and you should investigate why.
Glossary
- Allocator: the part of a program that hands out memory blocks when asked and takes them back when freed.
- ASLR (Address Space Layout Randomisation): a defence that places code, libraries and the heap at random addresses each time a program starts.
- Bin: a list of free memory chunks of a certain size class.
- Binary: a compiled program, the file you run.
- Chunk: one block of memory handed out by the allocator.
- Code execution: making a program run instructions the attacker chose.
- Dangling pointer: a pointer that still holds the address of memory that has already been freed.
- Docker: a tool that packages a program and its dependencies into a container for reproducibility.
- Double free: freeing the same memory chunk twice, a bug attackers like to trigger.
- DWARF: a standard format for debugging information embedded in compiled programs.
- Fastbin: a list of small free chunks, faster than the general bins.
- fd / bk: the forward and backward pointers of a doubly linked list.
- FILE: glibc's internal object representing an open file or stream.
- FSOP (File Stream Oriented Programming): a family of techniques that abuse FILE structures to gain code execution.
- Full RELRO: the strongest form of RELRO, making function pointer tables read-only after startup.
- glibc: the GNU C Library, the standard library used by most programs on Linux.
- Heap: the area of memory where a program's dynamically allocated blocks live.
- Heap base: the starting address of the heap.
- House of Apple / Banana / Cinder / Force: named families of exploitation techniques.
- Indirect call: a call to a function whose address is stored in a variable rather than written directly in the code.
- Largebin: a bin for large free chunks.
- Largebin attack: a technique that abuses the largebin insertion code to write a value to a chosen address.
- Leak: reading a value from memory that the program did not intend to reveal, usually an address.
- libc: the C library, usually glibc on Linux.
- Libc base: the starting address of glibc in memory.
- Loader: the small program that loads a binary and its libraries into memory.
- main_arena: a global structure in glibc holding the state of the allocator.
- Makefile: a recipe for building a program.
- Metadata: bookkeeping information the allocator keeps about each chunk.
- Mitigation: a defence against exploitation.
- NX (No-eXecute): a defence that marks memory as either writable or executable, not both.
- one_gadget: a short sequence of instructions already in a library that, if jumped to, runs a shell.
- PIE (Position-Independent Executable): a binary that can be loaded at any address.
- Plant: to place a fake object where the program will later pick it up.
- Pointer: a number that says where something lives in memory.
- Primitive: a reliable operation an attacker can perform, such as an arbitrary write.
- pwntools: a Python library for writing exploits.
- rdi: the register that holds the first argument to a function on x86-64.
- Register: a small, fast storage location inside the processor.
- Safe-linking: a defence that scrambles pointers stored in free lists.
- Shell: a prompt where you can type commands and the computer obeys.
- Stack protector: a defence that detects stack buffer overflows using a random canary value.
- tcache: a small, fast per-thread cache of recently freed chunks.
- tcache poisoning: overwriting a free chunk's
nextpointer so that a later allocation returns an address of the attacker's choosing. - Threat model: the assumptions about what an attacker can do and what the defender has.
- Top chunk: the remaining free memory at the end of the heap.
- Unsorted bin: the general pool of free chunks before they are sorted into size-specific bins.
- Use-after-free (UAF): using memory after it has been freed.
- vtable: a table of function pointers.
- Write primitive: a reliable way to write a chosen value to a chosen address.
- x86-64: the family of processors used in most laptops and servers.
- XOR: a bitwise operation that returns 1 where bits differ and 0 where they match.