National Cyber Warfare Foundation (NCWF)login

isoalloc for isolating heap allocations to blunt memory corruption exploits


0 user ratings
2026-11-03 07:33:03
milo
Red Team (CNA)
"isoalloc

isoalloc is a hardened malloc replacement for 64-bit Linux and MacOS that enforces spatial isolation between allocation types, aimed at developers and authorized security researchers hardening software against heap exploitation.








Toolstruct/isoalloc — isolation-based secure memory allocator in C11
CategoryHardened heap allocator / exploit mitigation library
Primary UseDrop-in malloc hardening via LD_PRELOAD or DYLD_INSERT_LIBRARIES, or direct API use for strict per-type isolation in C/C++ applications
Safe UseHardening your own software and studying heap exploitation defenses in authorized labs, defensive research, and sanctioned product security work
Telemetry NoteAs a defensive allocator, isoalloc intentionally aborts on anomalies such as double frees, wild frees, and unowned pointers, producing crash evidence defenders can use; compile-time flags like DEBUG, LEAK_DETECTOR, and MEM_USAGE report heap state at process exit

isoalloc (repo struct/isoalloc, Apache-2.0, written in C11) attacks the heap exploitation problem from a defensive angle that most allocators ignore: rather than trying to detect corruption after the fact, it structures the heap so that common exploitation primitives simply do not compose. The project describes itself as a secure and "fast(ish)" general purpose allocator that is a drop-in replacement for malloc on Linux and MacOS, loadable via LD_PRELOAD or DYLD_INSERT_LIBRARIES respectively. Its core security strategy is explicitly inspired by Chrome's PartitionAlloc: maintain spatial separation between objects of different sizes or types, so an overflow or use-after-free in one class of allocation cannot reliably reach interesting victims in another. For security engineers evaluating hardening options for their own C/C++ codebases, this is one of the more thoroughly documented open implementations of that idea.


The platform constraint is deliberate and worth understanding. isoalloc is designed and CI-tested for 64-bit Linux and MacOS only; the README states plainly that 32-bit targets are unsupported because the entropy available to mmap-based page allocations in a 32-bit process is far too low to provide meaningful security value. This is a design driven by address-space arithmetic: randomized placement of zones, bitmaps, and guard pages only buys real hardness when the search space is huge. Partial FreeBSD support exists but CI is described as often flaky, and minimal Solaris/Illumos support is available without LTO due to compiler backend limitations. Anyone planning a deployment should treat Linux x86-64 as the first-class target.


Internally, the architecture is zone-based and will feel familiar to anyone who has read arena implementations in mainstream allocators. A single iso_alloc_root structure holds pointers to a fixed number of iso_alloc_zone structures — "zones" — each of which manages user chunks of one specific size plus a bitmap that tracks their state. The mapping between bitmap entries and user chunks is called *bit slots*, with two bits of state per chunk: 00 for free, 10 for in use, 01 for used-then-freed, and 11 for a permanent canary chunk. Crucially, the pages backing user chunks and the pages backing the bitmap are allocated separately, and both are surrounded by guard pages mapped PROT_NONE. That separation means corrupting chunk data cannot directly reach the metadata that governs it, and vice versa — a structural break that heap exploits traditionally depend on.


Default zones are created in the constructor for sizes 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, and 8192 bytes, with additional zones created on demand when defaults are exhausted or larger sizes are requested. All zones are 4 MB regardless of chunk size, chunk sizes are multiples of 32 and always 8-byte aligned, and allocations larger than SMALL_SIZE_MAX go to "big zones" capped at 4 GB. A free bit slot cache of 255 entries accelerates allocation, and — notably from a security standpoint — that same cache doubles as a chunk quarantine or delayed-free mechanism, which erodes the reliability of use-after-free exploitation. Zones are also retired and replaced after a computed number of allocation/free cycles (ZONE_ALLOC_RETIRE * max_chunk_count_for_zone), which further denies attackers a stable, predictable heap layout over time.


The security properties list in the README is unusually detailed and reads like a direct checklist against known heap exploitation techniques. Zones cannot overflow or underflow into one another; double frees are checked on every iso_free call; every freed chunk gets a canary that is verified before the chunk is reused; and adjacent chunks' canaries are checked when a neighbor is freed. Canaries are unique — a 64-bit secret XOR'd with the chunk's own address — and the top byte is forced to 0x00 so an unbounded C string read cannot leak the canary byte by byte. That last detail signals a designer thinking like an attacker: it closes a classic side channel rather than just adding checks.


Pointer masking is another layer worth highlighting. With MASK_PTRS enabled (the default), the user_pages_start and bitmap_start pointers stored in zone metadata are XOR'd with a per-zone random secret between allocation and free operations, rendering them useless to an attacker who manages to read or corrupt zone metadata. This is a pragmatic response to the reality that metadata disclosure is often the first step in a heap attack chain. Randomized hints are passed to mmap so contiguous page ranges are not allocated, big zone metadata lives at a random offset from its base page, and options like BIG_ZONE_META_DATA_GUARD, BIG_ZONE_GUARD, and PROTECT_FREE_BIG_ZONES extend guard-page and PROT_NONE discipline to large allocations and their metadata.


Beyond the baseline, isoalloc ships a family of compile-time features that push it toward a sanitizer-adjacent detection tool. ALLOC_SANITY implements a GWP-ASAN-like sampled mode: a percentage of iso_alloc/malloc calls get a dedicated page surrounded by guards, with canary verification to catch use-after-free and linear overflows in both directions, including allocations deliberately placed at the end of the page to catch overflows specifically. UNINIT_READ_SANITY goes further on Linux, using the userfaultfd syscall to detect reads of uninitialized memory. There is explicit support for ASAN, MSAN, and UBSAN via Makefile flags (mutually exclusive, as usual), and the README claims isoalloc still catches issues Address Sanitizer misses — double, unaligned, and wild frees in particular. For authorized vulnerability research in lab environments, that combination makes the tool as much an instrumentation platform as an allocator.


Additional hardening knobs round out the model. SANITIZE_CHUNKS clears freed chunks with the constant 0xde, defeating residual-data reuse; iso_free_permanently retires a chunk forever; destroying a private zone overwrites it and marks it PROT_NONE to prevent use-after-free of the zone itself; RANDOMIZE_FREELIST shuffles free lists at zone creation; STRONG_SIZE_ISOLATION enforces a stricter size-isolation policy; MEMORY_TAGGING creates a 1-byte tag per chunk in private zones; and ARM_MTE adds support for the ARM v8.5a Memory Tagging Extension on capable hardware. Operational safety valves include ABORT_ON_NULL, ABORT_ON_UNOWNED_PTR (default on — freeing a pointer isoalloc does not own aborts), ABORT_NO_ENTROPY, and NO_ZERO_ALLOCATIONS, which returns a PROT_NONE page for zero-sized allocations instead of a usable pointer.


Performance and thread behavior involve real trade-offs that the README is honest about. Thread safety is achieved with a single global lock — a pthread mutex, or a C11 atomic_flag spinlock under USE_SPINLOCK — meaning every allocating thread contends on the same set of zones. A per-thread zone cache in TLS (default size 8, tunable via ZONE_CACHE_SZ) mitigates this as a FILO cache of recently used zones, though the README warns that an oversized cache can backfire when a thread's cache fills with same-size zones and forces slow-path iteration. The CPU_PIN feature restricts allocations from a zone to the CPU core that created it, adding a core-based isolation boundary at an acknowledged performance cost. The MEMCPY_SANITY and MEMSET_SANITY options hook memcpy/memset to check for out-of-bounds reads or writes whenever a source or destination points into an isoalloc chunk — a cheap, high-value guard for codebases with sloppy buffer handling.


Deployment is straightforward for authorized use on systems you control: make library builds the release library, make library_less_strict builds with ABORT_ON_UNOWNED_PTR=0 and is explicitly recommended when interposing via LD_PRELOAD on existing software, and make library_debug produces a debug build. When compiled with DEBUG, LEAK_DETECTOR, or MEM_USAGE, a destructor-time routine prints heap state, leak, and usage information — also reachable through the documented API. Note the interposition caveat: because arbitrary programs may legitimately free pointers from other allocators, the less strict variant exists precisely to avoid aborting on unowned pointers in mixed-allocation processes.


From a defensive monitoring perspective, isoalloc is itself a detection surface: its abort-on-anomaly behavior converts silent heap corruption into visible crashes, and FUZZ_MODE verifies all zones on every alloc/free, making it a strong harness for fuzzing your own code. UAF_PTR_PAGE samples iso_free calls to hunt for dangling references, and VERIFY_FREE_BIT_SLOTS checks the bit slot cache for duplicates on free. For defenders and authorized security teams, the practical value is twofold: harden production services where heap exploitation is a credible threat model, and use the sanitizer-style modes during development and sanctioned assessment to surface memory-safety bugs early — turning the allocator into part of the secure development lifecycle rather than just a runtime mitigation bolted on at the end.



Official project repository for struct/isoalloc.

Download Tool

Educational analysis for authorized security professionals. Use only in controlled, authorized environments.






Source: OffensiveSec
Source Link: https://www.offsecblog.com/2026/11/isoalloc-for-isolating-heap-allocations.html


Comments
new comment
Nobody has commented yet. Will you be the first?
 
Forum
Red Team (CNA)



Copyright 2012 through 2026 - National Cyber Warfare Foundation - All rights reserved worldwide.