Explaining Heap Based Buffer Overflow to a beginner

Viewed 35

I hope you're well. I'm trying to get my head around the 'title' and how it works. Can anyone possibly explain in simple terms?

Thanks again everyone.

1 Answers

I hope this helps you:

First of all, the heap is a memory structure used to manage dynamic memory.

In the case of the heap based buffer overflow,

  • programmers often use the heap to allocate memory whose size is not known at compile time, where the amount of memory required is too large to fit on the stack or the memory is intended to be used across function calls. Heap-based attacks flood the memory space reserved for a program or process. Heap-based vulnerabilities are difficult to exploit, so they are rarer.
  • it generally means that the buffer was allocated using a routine such as malloc()
  • a chunk of memory is allocated to the heap and data is written to this memory without any bound checking being done on the data

I tried to find the easiest example and I found the following:

#define BUFSIZE 256 int main(int argc, char **argv) { char *buf; buf = (char *)malloc(sizeof(char)*BUFSIZE); strcpy(buf, argv[1]); }

Related