Why is it more difficult to perform a heap based buffer overflow than a stack based? (regarding x86 architecture)
I thought it could be the fact that heaps are allocating memory dynamically. But is there more than this?
Why is it more difficult to perform a heap based buffer overflow than a stack based? (regarding x86 architecture)
I thought it could be the fact that heaps are allocating memory dynamically. But is there more than this?
They do share the same physical memory, however, the stack frame contains return addresses.
Return addresses store the address of the code in the calling function/procedure/method, so that the called function/procedure/method knows where to go back to when it is done. Mechanically, the "return" statement issues instructions to the processor to load the return address from the stack frame, then unload the stack frame and jump to that loaded return address. (The call operation effectively does the reverse: capture current address as return address and push that onto the stack along with a new frame.)
One problematic security issue is hijacking the processor program counter, which tells it what instructions it is going to execute next!
If you overwrite the return address in the stack frame, you can make the "return" code branch to a location of your choosing instead of where it should go (back to the caller).