WCU / Cybersecurity
~/CSC 472/Class 02/KP 15
Class 02 · KP 15 / 23

Why Overwriting Saved RIP Hijacks Control

  • call foo stores the legitimate return address on the stack.
  • Inside foo, a buffer overflow overwrites that stored address with an attacker-chosen value X.
  • foo finishes and executes ret.
  • ret pops X into RIP: the CPU now executes at X — shellcode, a libc function, or a ROP chain.
Key Takeaway

The CPU has no idea the return address was tampered with. Control-flow integrity defenses (stack canaries, CFI, shadow stacks) exist precisely to detect this.