Lably
Skip to content

Heap overflow

Software anomaly

  • 2 min read
  • 2 chapters

Related on Lably

Through Execution (computing), Linked list and Operating system

For example, on older versions of Linux, two buffers allocated next to each other on the heap could result in the first buffer overwriting the second buffer's metadata. By setting the in-use bit to zero of the second buffer and setting the length to a small negative value which allows null bytes to be copied, when the program calls free() on the first buffer it will attempt to merge these two buffers into a single buffer. When this happens, the buffer that is assumed to be freed will be expected to hold two pointers FD and BK in the first 8 bytes of the formerly allocated buffer. BK gets written into FD and can be used to overwrite a pointer.

Consequences

An accidental overflow may result in data corruption or unexpected behavior by any process that accesses the affected memory area. On operating systems without memory protection, this could be any process on the system.

For example, a Microsoft JPEG GDI+ buffer overflow vulnerability could allow remote execution of code on the affected machine.

iOS jailbreaking often uses heap overflows to gain arbitrary code execution.

Sign in to keep reading

One more chapter is free with a Lably account.

More in Computing and communication