House of Rabbit

Requirements

  1. Ability to modify fast bin fd pointer or size: This means you can change the forward pointer of a chunk in the fastbin or its size.

  2. Ability to trigger malloc_consolidate: This can be done by either allocating a large chunk or merging the top chunk, which forces the heap to consolidate chunks.

Goals

  1. Create overlapping chunks: To have one chunk overlap with another, allowing for further heap manipulations.

  2. Forge fake chunks: To trick the allocator into treating a fake chunk as a legitimate chunk during heap operations.

Steps of the attack

POC 1: Modify the size of a fast bin chunk

Objective: Create an overlapping chunk by manipulating the size of a fastbin chunk.

  • Step 1: Allocate Chunks

We allocate two chunks of 0x40 bytes each. These chunks will be placed in the fast bin list once freed.

  • Step 2: Free Chunks

We free both chunks, adding them to the fastbin list.

  • Step 3: Modify Chunk Size

We change the size metadata of chunk1 to 0xa1. This is a crucial step to trick the allocator during consolidation.

  • Step 4: Trigger malloc_consolidate

Allocating a large chunk triggers the malloc_consolidate function, merging small chunks in the fast bin. The manipulated size of chunk1 causes it to overlap with chunk2.

After consolidation, chunk1 overlaps with chunk2, allowing for further exploitation.

POC 2: Modify the fd pointer

Objective: Create a fake chunk by manipulating the fast bin fd pointer.

  • Step 1: Allocate Chunks

Explanation: We allocate two chunks, one smaller and one larger, to set up the heap for the fake chunk.

  • Step 2: Create fake chunk

We write fake chunk metadata into chunk2 to simulate smaller chunks.

  • Step 3: Free chunk1

Explanation: We free chunk1, adding it to the fastbin list.

  • Step 4: Modify fd of chunk1

Explanation: We change the forward pointer (fd) of chunk1 to point to our fake chunk inside chunk2.

  • Step 5: Trigger malloc_consolidate

Allocating a large chunk again triggers malloc_consolidate, which processes the fake chunk.

The fake chunk becomes part of the fastbin list, making it a legitimate chunk for further exploitation.

Summary

The House of Rabbit technique involves either modifying the size of a fast bin chunk to create overlapping chunks or manipulating the fd pointer to create fake chunks. This allows attackers to forge legitimate chunks in the heap, enabling various forms of exploitation. Understanding and practicing these steps will enhance your heap exploitation skills.

Last updated