# Heap

[Tell me more](https://0xabe.io/ctf/exploit/2016/04/24/BlazeCTF-dmail.html)

Using a double-free, an arbitrary address can be introduced in the free list.

TODO: Learn about tcache poisoning, which is related to this.

## Integer Overflows and `malloc()`

[Tell me more](https://undeadly.org/cgi?action=article\&sid=20060330071917)

There's a pretty common pattern used to allocate an array of `n` objects of type `T`: `malloc(sizeof(T) * n)`&#x20;

A *very* large `n` can cause an overflow of the `size_t` passed to `malloc()`. An attacker who controls `n` can cause a smaller memory area to be allocated, leading to a buffer overflow when the application tries to use that shiny new buffer.

## Attacks

### (glibc 2.29) House of Corrosion&#x20;

[Tell me more](https://github.com/CptGibbon/House-of-Corrosion)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://luftenshjaltar.gitbook.io/ctf/binary/heap.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
