A buffer overflow is an unexpected behavior that exists in certain programming languages. It constitutes one of the principal collections of vulnerabilities in existence. A large percentage of possible remote exploits are of the overflow variety. If executed properly, an overflow vulnerability will allow an attacker to run arbitrary code on the victim's machine with the equivalent rights of whichever process was overflowed. This is often used to provide a remote shell onto the victim machine, which can be used for further exploitation. A buffer overflow is an unexpected behavior that exists in certain programming languages. This chapter elucidates in detail why these problems exist, how to spot when an overflow vulnerability is present, and how to write an exploit to take advantage of it. It also explains how stacks operate, how modern compliers and computer architecture deal with functions. It also illustrates some advanced techniques for special situations that are used to make attack code more portable and usable.