zappz

All topics

buffer overflow

1 article

A buffer overflow is a software flaw in which a program writes more data into a block of memory than the block can hold. The excess spills into neighbouring memory.

Programs set aside fixed-size regions, called buffers, to hold input such as a name or a network message. Languages like C and C++ do not automatically check that data fits before copying it. If the programmer forgets the check, a long enough input runs past the end of the buffer and overwrites whatever sits next to it. On the stack, that neighbour can be the return address that tells the processor where to continue after a function finishes. An attacker who controls the input can replace that address and steer the program toward instructions of their choosing. Overflows in the heap, the memory used for longer-lived data, can be abused in similar ways.

Defences work at several levels. Careful code checks lengths before copying and uses safer library functions. Compilers can place a guard value, known as a canary, next to the return address to detect tampering. Operating systems randomise memory layout and mark data areas as non-executable. Memory-safe languages such as Rust, Java and Python prevent this class of error by design.

The flaw matters because it turns a simple mistake into full control of a machine. Well known worms and break-ins have relied on it, and it still appears in operating systems, routers and embedded devices written in older languages. A single unchecked copy can expose every user of a widely deployed program.

  1. buffer overflowWhat Is a Buffer Overflow Attack? How Extra Bytes Take OverA buffer overflow attack sends a program more data than it has room for, so the extra bytes overwrite nearby memory and can hand control to an attacker. · 7 min read

Related topics

All topics