Can the heap overwrite the stack?
If the stack grows into the heap, the typically C compiler will silently start to overwrite the heap’s data structures. On a modern OS, there will be one or more virtual memory guard pages which prevent the stack from growing indefinitely.
What conditions cause buffer overflow?
A buffer overflow (or buffer overrun) occurs when the volume of data exceeds the storage capacity of the memory buffer. As a result, the program attempting to write the data to the buffer overwrites adjacent memory locations.
Is buffer overflow and stack overflow the same thing?
Buffer overflow usually stands for anytime a memory buffer is accessed beyond it’s bounds whether stack or heap. A stack overflow means the stack has exceed it’s allocated limit and on most machines/OS is running over heap.
Can a buffer overflow be exploited on the heap?
In general, exploiting a buffer overflow on the heap is more challenging than exploiting an overflow on the stack. However, many successful exploits have involved heap overflows. There are two ways in which heap overflows are exploited: by modifying data and by modifying objects.
How to make the stack and heap non executable?
I read a book about buffer overflow, and it suggest the next to deal with: Making the stack (and heap) non-executable provides a high degree of protection against many types of buffer overflow attacks for existing programs. But I don’t understand how we can do it – where the execute would take place, if not on the heap or on the stack?
How are nonexecutable stacks used to prevent buffer overflow?
Nonexecutable stacks are a runtime solution to buffer overflows that are designed to prevent executable code from running in the stack segment. Many operating systems can be configured to use nonexecutable stacks. Nonexecutable stacks are often represented as a panacea in securing against buffer overflow vulnerabilities.
How is DEP used to exploit stack overflows?
Historically, buffer overflows where exploited to overwrite the return address in the stack, so as to make execution jump into the very data which has been used to overflow the buffer. The canary tries to detect that before jumping, and DEP is used to make the stack space non-executable.