integer overflow

term

programmingsecurity

An arithmetic result too large for its type, so the value silently wraps around instead of growing.

Add one to the maximum signed 32-bit integer and you land on the most negative one, which is only a curiosity until the wrapped value is used as a size. The dangerous pattern is a length calculation that overflows to something tiny, passes a sanity check because it now looks small, and is then used to allocate a buffer that the real data overruns, which is how integer overflows become memory-corruption bugs. Ariane 5 famously destroyed itself on a related conversion error. Mitigations are checked arithmetic, wider types, and treating any size arithmetic on untrusted input as suspect. It is CWE-190.

Also known as: integer wraparound, CWE-190

All glossary entries