Buffer Overflow

Also known as:BOF

Buffer Overflow: Writing beyond the bounds of a memory buffer, overwriting adjacent data. It is the oldest and still most consequential form of memory corruptionMemory CorruptionUnintentional or targeted alteration of storage structures with security implications. and the foundation of many exploit chains.

How it works and where it fits

A buffer is a memory region of fixed size. When a program writes more data than the buffer holds, the excess bytes land in the memory behind it. On the stack that is typically saved registers, the stack canary, and the return address; on the heap it is allocator metadata or adjacent objects. Whoever controls the overwritten values often controls the program’s next jump. The root cause is a missing or incorrect length check, classically in strcpy, sprintf, or a read with an oversized length argument.

Practical security relevance

Modern systems defend in layers: stack canariesStack CanaryRandom guard value placed before the return address whose modification reveals a stack overflow. detect an overwritten return address, non-executable memory prevents shellcode on the stack, and ASLRAddress Space Layout RandomizationProtection mechanism that randomly arranges memory addresses, thereby making exploits more difficult. makes target addresses unpredictable. None of these fixes the bug — they only raise the cost. As soon as an additional information leak discloses the canary or the base address, the overflow works again. The actual remedy lies in memory-safe languages or in rigorous bounds checks at every copy boundary.

  • Memory CorruptionMemory CorruptionUnintentional or targeted alteration of storage structures with security implications.: Unintentional or targeted alteration of storage structures with security implications.
  • Binary ExploitationBinary ExploitationExploitation of memory or logic errors in compiled applications.: Exploitation of memory or logic errors in compiled applications.
  • Stack CanaryStack CanaryRandom guard value placed before the return address whose modification reveals a stack overflow.: Random guard value placed before the return address whose modification reveals a stack overflow.
  • Secure CodingSecure CodingProgramming practices aimed at avoiding common vulnerabilities and misconfigurations.: Programming practices aimed at avoiding common vulnerabilities and misconfigurations.