Skip to main content

Overview

The House of Force is a classic heap exploitation technique that exploits the Top Chunk (also called the Wilderness) to make malloc return a nearly-arbitrary pointer. By overwriting the top chunk’s size field with a very large value, an attacker can control where the next allocation will be placed.
Patch Status: This technique was patched in glibc 2.29 with additional top chunk size validation checks.

Glibc Version Compatibility

Patch commit: 30a17d8c95fbfb15c52d1115803b63aaa73a285c
Ret2 Wargames Practice: Try this technique hands-on at House of Force Interactive Challenge

What This Technique Achieves

The House of Force enables:
  • Arbitrary memory allocation: Force malloc to return a pointer to any memory location
  • GOT overwrite: Overwrite Global Offset Table entries (requires RELRO disabled)
  • Data section control: Modify global variables or function pointers
  • Integer overflow exploitation: Use integer overflow to reach target addresses

Prerequisites and Constraints

This technique requires:
  1. Heap overflow: Ability to overwrite the top chunk’s size field
  2. Allocation control: Ability to control malloc size parameter
  3. Target address knowledge: Must know the address you want to hit
  4. No RELRO or partial RELRO: For GOT overwrites (or target stack/heap)
  5. Glibc < 2.29: Technique is patched in newer versions

How It Works

1

Allocate initial chunk

Make a normal allocation to have a heap chunk before the top chunk.
2

Overflow into top chunk

Use a vulnerability to overwrite the top chunk’s size with -1 (0xFFFFFFFFFFFFFFFF).
3

Calculate evil size

Calculate the size needed to move the top chunk to your target location.
4

Allocate evil size

Make a large allocation that will move the top chunk via integer overflow.
5

Allocate at target

The next allocation will be served from the new top chunk location.

Complete Source Code

Technical Deep Dive

The Top Chunk

The top chunk (wilderness) is special:
  • It’s always the last chunk in the heap
  • It grows when more memory is needed
  • Its size determines available heap space
  • When allocated from, it splits off a chunk and shrinks

Integer Overflow Exploitation

The magic happens with integer overflow:

Size Calculation Formula

The evil_size formula accounts for:
  • Chunk metadata (2 * sizeof(long) = 16 bytes on x64)
  • Alignment requirements
  • The distance between old top and target

The Patch (glibc 2.29)

Glibc 2.29 added this check:
This prevents setting the top chunk size to an impossibly large value.

CTF Challenges

Challenge: Recipe management system with heap overflowExploitation:
  • Used heap overflow to corrupt top chunk size
  • Calculated evil_size to target GOT entries
  • Overwrote free@GOT with system address
  • Got shell by freeing chunk containing “/bin/sh”
Writeup: CTF Writeup
Challenge: Cloud storage service with controlled allocationsExploitation:
  • Corrupted top chunk via off-by-one overflow
  • Used House of Force to allocate on stack
  • Overwrote saved return pointer
  • Achieved RCE
Writeup: CTF Writeup

Modern Alternative

House of Tangerine

Successor to House of Force: Works on glibc 2.26+ by exploiting sysmalloc’s _int_free call on the top chunk. Uses tcache poisoning instead of direct top chunk allocation.

Common Pitfalls

Calculation Errors: The most common mistake is getting the evil_size calculation wrong. Remember to account for both the chunk header and alignment.
ASLR Without Leak: You need to know absolute addresses. With ASLR, you need an information leak to know where to target.
Size Too Small: If evil_size is too small, malloc might call mmap() instead of using the top chunk, bypassing your exploit.

See Also