EVOPEDIA

← all systems · see it in The System

Buffer overflow

In programming and information security, a buffer overflow or buffer overrun is a bug whereby a program writes data to a buffer beyond the buffer's allocated memory, overwriting adjacent memory locations (src:wp:buffer-overflow). Walked as the fault together with its life as the security literature describes it: why some languages allow it (C, C++) and others do not, its history from the 1972 Anderson report through the Morris worm (1988), 1996 and the worms of 2001-2003, the defences and the arms race around them, how common it remains, and the move to memory-safe languages and hardware.

Properties published scienceour proposal

Sourced fields, and our own readings.

born atOctober 1972 (the Computer Security Technology Planning Study); first documented hostile use 1988
born precisionyear
boundaryInside: the buffer, the write past its end, the adjacent memory it changes, and the run-time outcome; together with the record of the fault (its kinds, counts and history) and the defences and uses that exist because of it. Outside: the program, language, compiler, operating system and hardware it occurs in (partners), and the attackers and worms that use it.
nested levelA kind of memory-safety error (spatial), itself a kind of software vulnerability when exploitable; occurs in software running in computer memory.
scaletechnological

Measures (41) published science

characteristic clock: Slammer doubling time8.5 s
Slammer: share of vulnerable hosts infected in 10 minutes>90 %
Slammer: hosts infected>=75,000 hosts
Code-Red v2: hosts infected>359,000 in 14 h hosts
Slammer worm size376 bytes
Code-Red peak infection rate>2,000 hosts per minute
Code-Red: disclosure to patch8 days
Code-Red: patched share of infected hosts before and after the 1 August re-spread32 -> 64 %
Code-Red epidemic cost (estimate)>2.6 billion USD
Morris worm: machines infected (usually reported)~6,000 (contested: a guess per Graham; Stoll counted 2,000 in 15 h) machines
Morris worm: economic impact (Stoll's estimate for the GAO)100,000 - 10,000,000 USD
ASLR derandomization time on 32-bit (Apache, PaX)216 (average) s
canary check: instructions added per function call7 instructions
canary micro-benchmark overhead per call (1998)125 (empty function, worst case); 69-80 (one-argument functions) %
shadow stack overhead (unprotected, LLVM)5 % (SPEC2006)
SoftBound spatial-safety overhead67 % (average)
SoftBound+CETS full memory-safety overhead116 % (SPEC CPU average)
adoption threshold for a defence's run-time overhead~10 (some say 5) %
AddressSanitizer CPU overhead1.5x-3x ratio
memory-safety share of Microsoft CVEs per year~70 %
memory tagging: detection probability with 4-bit tags15/16 (~94%) probability
memory-safety share of Chromium severe bugs70 % (2020)
memory-safety share cited by CISAroughly 2/3 of software vulnerabilities
memory-safety share of Android vulnerabilities76 (2019); 24 (2024, extrapolated); <20 (2025) %
memory-safety vulnerability density, Rust in Android0.2 (estimate) per million lines
memory-safety vulnerability density, C/C++ in Android~1,000 (historical) per million lines
Rust vs C++ rollback rate (medium and large changes)~4x lower for Rust ratio
Rust memory-safety bugs studied (all CVEs to 2020-12-31)186 (all but one compiler bug need unsafe code) bugs
CWE Top 25 2025: rank of CWE-787 Out-of-bounds Write5 (score 12.68; 12 KEV CVEs; down 3) rank
CWE Top 25 2025: rank of CWE-120 classic buffer overflow11 (score 6.96); stack-based CWE-121 14th, heap-based CWE-122 16th rank
CHERI: share of 2019 MSRC memory-safety issues deterministically mitigated (assessment)at least two thirds (theoretical, combined with other mitigations) share
bug density in executable code (reliability studies)up to 75 bugs per 1000 lines
first description to first documented hostile use1972 -> 1988 (16 years)
NX patch to published bypassa few months (June 1997 patch)
spatial share of in-the-wild memory-safety exploits (Project Zero, a decade)40 %
hardened libc++ bounds checks: average performance impact0.30 % (Google services)
hardened libc++: bugs found>1,000 found; 1,000-2,000 a year prevented (projected) bugs
hardened libc++: reduction in baseline segfault rate30 %
average vulnerability lifetime assumed in Google's simulation2.5 (model input; code doubling every 6 years; 10-year transition)
Slammer: patch to wormabout 6 months (24 July 2002 bulletin to 25 January 2003 outbreak; our count from the two dates)
Code-Red: vendor bulletin to patch for all Windows 2000 builds18 June to 21 August 2001 dates

Open contentions (5) open contention

Where sources or readings disagree. Both stay on the map.

Cross-scale patterns seen here (24) our proposal

Shapes that recur when the same kind of problem is solved at different scales, and how each shows in Buffer overflow. Each links to every other system that shows it.

Valence: what it trades, and with whom (12) published science

Each exchange with a neighbour, read from both sides: who gains, who pays, and what carries it.

Partners and parts published science

Built from / builds (3)

Sits inside / holds (2)

expressed by (21)

floor filled by (23)

represents (1)

Kinds (5)

Notes published science

Layers

The ways it takes in its world, where they meet, and how it acts back, each from L1 (where it meets the world) up.

buffer overflow as software-security researchers describe it: input bytes and the memory laid out to hold them, up to the fix, the defence or the attack (reader's view)

  1. L1: The program's memory and the data that reaches it: memory laid out as adjacent regions (stack, heap), and input bytes arriving from files, the network or other programs
  2. L2: The buffer: a region set aside with a fixed size, the program assuming inputs will fit
  3. L3: The write past the end: a copy or loop writes more than the buffer holds; nothing checks (in C and C++ the result is undefined behaviour)
  4. L4: Adjacent memory overwritten: neighbouring objects, heap bookkeeping, return addresses; one error can raise more
  5. L5: The run-time outcome: erratic behaviour, wrong results, a crash, a leak, or control taken; or the write caught by a canary, tag, capability or guard page and the program stopped
  6. L6: Known, classed and counted: found by fuzzing, sanitizers and analysis, recorded as CVEs and CWE kinds, tallied by vendors as memory safety (spatial and temporal); spatial flaws, overflows among them, are 40% of in-the-wild memory-safety exploits (Project Zero)
  7. L7: Action back on the world: code fixed, defences deployed, languages and hardware changed, roadmaps set; or the overflow used to take machines

the boardroom (shared floors)

  1. L4: The out-of-bounds write and what it changes: adjacent objects, heap bookkeeping or saved return addresses corrupted (a spatial memory error); one error can corrupt pointers that raise more
  2. L5: The run-time outcome: undefined behaviour realised as erratic behaviour, wrong results or a crash; information leaked; program state or control flow taken over; or the write caught by a check and the program stopped; control flow is not the only target: data-only attacks change a flag or a length and pass straight by defences that guard control flow (the main reason the field says mitigations are not memory safety)
  3. L6: Known, classed and counted: found in testing or in the wild, reported, triaged, recorded as CVE and CWE kinds, tallied as shares of all vulnerabilities, and told as the field's history (1972, 1988, 1996, 2001, 2003)
  4. L7: Action back on the world: the code fixed; defences deployed by compilers, operating systems and hardware; new code written in memory-safe languages; roadmaps and policy; or the overflow used to take machines (worms, privilege escalation)

way in: Attack research that answers each defence

  1. L1: A defence deployed: the non-executable stack (June 1997), canaries (1998), ASLR (July 2001)
  2. L2: A way around it described: months after the NX patch, code reuse that needs no injected code (return-into-libc); derandomization of 32-bit ASLR in about 216 s
  3. L3: Generalised: existing code fragments chained (return-oriented programming); information leaks defeat randomization and canaries
  4. L4: All deployed protections defeated in real exploits (2013)

way in: Incidents, reports and vendor tallies

  1. L1: Incidents seen in the wild and measured: Code-Red traced by a network telescope (359,000 hosts in 14 hours)
  2. L2: Reported and discussed in public: CERT/CC (1988), Bugtraq (November 1993)
  3. L3: Triaged by the vendor's response centre (MSRC has triaged every reported Microsoft vulnerability since 2004) and classed by root cause
  4. L4: Given a CVE record and a CWE kind (CWE-120 classic buffer overflow, -121 stack, -122 heap, -787 out-of-bounds write)
  5. L5: Aggregated into shares and ranks, each counting memory safety as a whole (spatial and temporal), not overflows alone: ~70% of Microsoft's CVEs, 70% of Chromium's severe bugs (half of them use-after-free), roughly 2/3 (CISA); the nearest figures to overflows themselves: spatial flaws 40% of in-the-wild memory-safety exploits over a decade (Project Zero), out-of-bounds write 5th of 25 and classic buffer overflow 11th (CWE 2025)

way in: Input bytes: data larger than the buffer

  1. L1: Bytes from files, the network or other programs; often malformed, sometimes crafted ('crafted' files)
  2. L2: Read into a fixed-size buffer by a network service or parser (fingerd 1988; IIS 2001; SQL Server 2003, a single packet)
  3. L3: Length not checked against the space set aside: the copy runs on past the end

way in: Run-time checks that watch the buffer's edge

  1. L1: Metadata set beside or with each buffer: a canary word next to the return address (1998), memory tags on 16- or 64-byte granules, capability bounds, guard pages around allocations
  2. L2: Checked at a defined moment: at function return (canary), on every load and store (tags, capabilities), on touching a guard page
  3. L3: Mismatch detected: with 4-bit tags a bug is caught with probability 15/16; capabilities turn most unsafe accesses into length exceptions
  4. L4: Signal or fault delivered: the program ends in a fail-safe state instead of yielding control

way in: Size arithmetic: integer errors feeding the index

  1. L1: Sizes and indexes held in fixed-width integers
  2. L2: Integer overflow, truncation or a signedness error gives a wrong size or index
  3. L3: An index the attacker controls, with the bounds check missing or incomplete, points anywhere

way in: Testing that makes overflows show

  1. L1: Generated test inputs (fuzzing), edge cases, and code read by static analysers
  2. L2: Builds instrumented to catch bad accesses during testing (AddressSanitizer: redzones, shadow memory, 1.5x-3x CPU)
  3. L3: Overflow triggered and reported in development; ASan has found tens of thousands of bugs
  4. L4: Patched before release; useful for code in development, less for unmaintained legacy code

way in: The copying code as written

  1. L1: Source code written in C, C++ or assembly by programmers working in a performance-oriented style
  2. L2: Calls to library functions without bounds checks (gets, scanf, strcpy) or loops that move a pointer without a bound
  3. L3: A pointer incremented or decremented past its object: overflow or underflow

way in: The language's rules about memory

  1. L1: The language definition: C and C++ allow pointer arithmetic on direct memory addresses with no provision for bounds checking
  2. L2: Writing an array beyond its bounds is undefined behaviour in the C/C++ standards
  3. L3: The compiled program checks nothing at run time unless asked (C++ at() checks, plain access does not); a hardened standard library adds bounds checks to standard C++ data structures (hardened libc++, 2024, 0.30% average cost) though C++ does not become fully memory-safe; memory-safe languages check or prove bounds (Java, Rust's borrow checker)

way in: What a defence costs: the performance budget

  1. L1: The machine's time and memory, shared between the program and its checks
  2. L2: Instructions added per call or per access: a canary costs a fixed 7 instructions
  3. L3: Measured per call: 125% on an empty function (the worst case), 69-80% on one-argument functions (1998)
  4. L4: Measured on benchmarks: shadow stack about 5%, SoftBound 67%, SoftBound+CETS 116%, ASan 1.5x-3x; hardware enforcement negligible
  5. L5: Compared with compatibility and robustness: performance and especially compatibility are the main barriers
  6. L6: The adoption threshold: above roughly 10% overhead, defences do not tend to be adopted in production (some say 5%)

way in: What lies next door: the memory layout

  1. L1: The memory layout of a program, often well defined
  2. L2: Neighbours of the buffer: adjacent objects, heap bookkeeping, saved return addresses
  3. L3: Region-specific: heap exploitation depends on the heap manager, stack exploitation on the calling convention

way out: Build bounds into the hardware

  1. L1: Memory tagged or bounded: an assessment found CHERI would deterministically have mitigated at least two thirds of MSRC's 2019 memory-safety issues
  2. L4: Checks on every access in hardware, with negligible overhead
  3. L6: Instruction-set extensions: capabilities replace plain pointers; tags in pointer top bits
  4. L7: Vendors and researchers decide to put checks in silicon: memory tagging (SPARC ADI, Arm), CHERI capabilities, hardware shadow stacks (Intel CET)

way out: Crash: the process ended

  1. L1: The process terminated; for a remote service, a denial of service
  2. L3: The operating system raises a segmentation fault
  3. L5: Erratic behaviour or a detected violation

way out: Deploy defences in compilers and operating systems

  1. L1: Memory pages marked writable or executable, not both; addresses randomized
  2. L3: Binaries built with checks and loaded at random addresses
  3. L5: Compiler and kernel features: StackGuard and ProPolice gcc patches, W^X, PaX, Exec Shield, Data Execution Prevention
  4. L7: Decision to harden: canaries, non-executable pages, layout randomization, chosen under the ~10% overhead budget

way out: Fix the code

  1. L1: The code on the machines changed, or not
  2. L3: Installed, slowly: patching rose from 32% to 64% only after the worm came back on 1 August
  3. L5: Patch released: Code-Red's IIS flaw patched eight days after disclosure (26 June 2001, per Moore et al.); the vendor bulletin is dated 18 June 2001 with patch downloads, and a patch for all Windows 2000 builds came 21 August (contention C-3825)
  4. L7: Decision to fix the flaw: replace an unchecked copy with a bounded one (strlcpy takes the buffer's capacity)

way out: Use: take the machine

  1. L1: Hosts infected: over 90% of vulnerable hosts in 10 minutes (Slammer); 359,000 in 14 hours (Code-Red)
  2. L3: Self-copying worms: Morris (1988), Code-Red (2001), Slammer (2003, 376 bytes, doubling every 8.5 s)
  3. L5: Privilege escalation through buffers in operating-system code
  4. L7: An attacker's or worm author's aim: control of hosts (and, for console owners, running their own software)

way out: Write new code in memory-safe languages

  1. L1: Fewer overflows in the shipped code: Android's memory-safety share 76% (2019), 24% (2024), under 20% (2025)
  2. L3: Compiler-enforced bounds and borrowing; memory-safety bugs need unsafe code
  3. L5: New code in Rust, Java, Kotlin; old C/C++ left to age, since vulnerabilities decay with code age
  4. L7: Roadmaps and decisions: governments urge manufacturers to prioritize memory safe languages and publish roadmaps (December 2023, February 2024)

Sources (32) published science

Buffer overflow (Wikipedia, rev 1374582723, 2026-09-12, via Wikimedia Enterprise)
Szekeres L, Payer M, Wei T, Song D. SoK: Eternal War in Memory. IEEE S&P 2013. doi:10.1109/sp.2013.13 (behind its links)
Moore, Shannon, Brown 2002, Code-Red: a case study on the spread and victims of an Internet worm (IMW) (behind its links)
Vander Stoep J, Rebert A (Google). Eliminating Memory Safety Vulnerabilities at the Source. Google Security Blog, September 2024 (behind its links)
Rebert A, Shavrick M, Yasuda K. Retrofitting spatial safety to hundreds of millions of lines of C++. Google Security Blog, 15 November 2024 (read in full from the page; charts not read as text) (behind its links)
MITRE. 2025 CWE Top 25 Most Dangerous Software Weaknesses (the ranking table, read from the page; methodology page not read) (behind its links)
Memory safety (Wikipedia, via Wikimedia Enterprise) (behind its links)
Serebryany K, Stepanov E, Shlyapnikov A, Tsyrklevich V, Vyukov D. Memory Tagging and how it improves C/C++ memory safety. arXiv:1802.09517 (2018) (behind its links)
van der Veen V, dutt-Sharma N, Cavallaro L, Bos H. Memory Errors: The Past, the Present, and the Future. RAID 2012 (LNCS 7462), open technical report IR-CS-73. doi:10.1007/978-3-642-33338-5_5 (behind its links)
Moore D et al. The Spread of the Sapphire/Slammer Worm (CAIDA technical page, 2003; read in full from the page itself, 2026-11-22) (behind its links)
Morris worm (Wikipedia, via Wikimedia Enterprise snapshot) (behind its links)
Shacham H, Page M, Pfaff B, Goh E-J, Modadugu N, Boneh D. On the effectiveness of address-space randomization. ACM CCS 2004. doi:10.1145/1030083.1030124 (behind its links)
Cowan C, Pu C, Maier D, et al. StackGuard: Automatic Adaptive Detection and Prevention of Buffer-Overflow Attacks. USENIX Security 1998 (OpenAlex W1655226010) (behind its links)
MSRC Team (Gavin Thomas). A proactive approach to more secure code. Microsoft Security Response Center blog, 16 July 2019 (read through the page-reading tool; the figure caption quoted as it returned it) (behind its links)
CISA, NSA, FBI and partners (Australia, Canada, New Zealand, UK). The Case for Memory Safe Roadmaps, December 2023: CISA press release (sections, through a tool summary; the guide's PDF was refused to a program fetch) (behind its links)
Vander Stoep J. Rust in Android: move fast and fix things. Google blog, 13 November 2025 (read in full from the page; charts not read as text) (behind its links)
Xu H et al. 2021. Memory-safety challenge considered solved? An in-depth study with all Rust CVEs. arXiv:2003.03296 (TOSEM) (behind its links)
Joly N, ElSherei S, Amar S. Security analysis of CHERI ISA. MSRC blog, 14 October 2020 (read in full from the page; the paper it summarises not read) (behind its links)
Microsoft Security Bulletin MS02-039, Buffer Overruns in SQL Server 2000 Resolution Service Could Enable Code Execution (published 24 July 2002; read in full) (behind its links)
Microsoft Security Bulletin MS01-033, Unchecked Buffer in Index Server ISAPI Extension Could Enable Web Server Compromise (published 18 June 2001; revisions to 4 Nov 2003; read in full) (behind its links)
White House ONCD. Back to the Building Blocks: A Path Toward Secure and Measurable Software, 26 February 2024: fact sheet (read in full from the page; the technical report itself not read) (behind its links)
Watson RNM et al. CHERI: A Hybrid Capability-System Architecture for Scalable Software Compartmentalization. IEEE S&P 2015. doi:10.1109/sp.2015.9 (sections: abstract, introduction, tcpdump case) (behind its links)
Integer overflow (Wikipedia, via Wikimedia Enterprise) (behind its links)
Cowan C, Wagle P, Pu C, Beattie S, Walpole J. Buffer overflows: attacks and defenses for the vulnerability of the decade. DISCEX 2000. doi:10.1109/discex.2000.821514 (behind its links)
Anderson JP (1972) Computer Security Technology Planning Study, Vol. I (ESD-TR-73-51) (behind its links)
Spafford EH. The Internet worm program: an analysis. ACM SIGCOMM CCR 1989. doi:10.1145/66093.66095 (behind its links)
Burow N, Zhang X, Payer M. SoK: Shining Light on Shadow Stacks. IEEE S&P 2019. doi:10.1109/sp.2019.00076 (sections: abstract, introduction, Intel CET passage) (behind its links)
Moore, Paxson, Savage, Shannon, Staniford and Weaver, Inside the Slammer Worm, IEEE Security & Privacy 1(4), 2003 (doi:10.1109/MSECP.2003.1219056) (behind its links)
Hu L, Bao W, Shi P, Wang J, Lu M. Simulation of overland flow considering the influence of topographic depressions. Sci Rep 2020. doi:10.1038/s41598-020-63001-y (sections: introduction, results) (behind its links)
Ali G, English C. Phytoplankton blooms in Lake Winnipeg linked to selective water-gatekeeper connectivity. Sci Rep 2019. doi:10.1038/s41598-019-44717-y (sections: abstract, study area) (behind its links)
Reynolds J. RFC 1135, The Helminthiasis of the Internet, December 1989 (sections: 1.1 Infection, the fingerd and sendmail passages) (behind its links)
The Chromium Projects. Memory safety (behind its links)