Explore our new Cybersecurity Terms Glossary, explained by our experts.

View the Glossary View the Glossary
PRIVIA

Cybersecurity Terms Glossary

What Is a Buffer Overflow?

A buffer overflow occurs when a program writes more data into a memory buffer than it can hold, corrupting adjacent memory and sometimes handing control to an attacker.

Illustration for the cybersecurity term Buffer Overflow
Home / Blog / Cybersecurity Terms / What Is a Buffer Overflow?
17 November 2026

What Is a Buffer Overflow?

What Is a Buffer Overflow?

A buffer overflow happens when a program writes more data into a fixed-size block of memory than was allocated for it, spilling into adjacent memory. Depending on what gets overwritten, the result ranges from a crash to full remote code execution. It is one of the oldest vulnerability classes in computing and, in languages such as C and C++, still one of the most damaging.

What Happens in Memory

Programs hold data in buffers—arrays of a fixed length. C does not check array bounds automatically, so a function such as strcpy() will copy however many bytes it is given:

void greet(const char *name) {
    char buf[16];
    strcpy(buf, name);   /* no length check */
    puts(buf);
}

Pass in a 100-character name and the extra 84 bytes overwrite whatever sits next to buf on the stack. On many architectures that includes the saved return address. If an attacker controls those bytes, they control where the function “returns” to—and therefore what code runs next.

Stack, Heap, and Related Flaws

MITRE’s weakness list files the core flaws under CWE-787 (Out-of-bounds Write) and CWE-120 (Classic Buffer Overflow), and out-of-bounds writes have been among the very top entries of the CWE Top 25 Most Dangerous Software Weaknesses in recent years.

Incidents That Shaped the Field

YearIncidentOverflow involved
1988Morris wormStack overflow in the Unix fingerd service
2001Code RedOverflow in an indexing service extension for Microsoft IIS
2003SQL SlammerOverflow in the SQL Server Resolution Service, spreading worldwide within minutes
2017WannaCryEternalBlue (CVE-2017-0144), an SMBv1 memory corruption flaw; the outbreak disrupted NHS trusts across England

Mitigations Built Into Modern Systems

Exploiting an overflow today is far harder than in 1996, thanks to layered protections in compilers and operating systems:

Attackers respond by chaining an information leak, which defeats ASLR, with ROP gadgets that sidestep DEP. Mitigations raise the cost of exploitation; they do not remove the bug.

Prevention Starts in the Code

The durable fix is not to write the bug in the first place. Microsoft and the Chromium project have both reported that around 70% of their serious security bugs are memory-safety issues. In December 2023 the NCSC joined CISA, the NSA, and other Five Eyes agencies in publishing “The Case for Memory Safe Roadmaps”, urging vendors to plan a move to memory-safe languages such as Rust, Go, C#, and Java. For existing C and C++ code:

MITRE ATT&CK captures how these bugs are used in practice: T1190 Exploit Public-Facing Application for internet-facing services and T1203 Exploitation for Client Execution for documents and browsers. Successful exploitation often leads straight to privilege escalation when the vulnerable process runs as root or SYSTEM.

Overflows in firmware, embedded devices, and legacy services often survive simply because nobody has tested them. Our infrastructure security testing looks for exactly those exposed, unpatched services before an attacker does.

FAQ – Frequently Asked Questions

Are Buffer Overflows Still a Problem in 2026?

Yes. Modern mitigations make exploitation harder, but overflows keep appearing in VPN appliances, firewalls, routers, browsers, and embedded firmware, much of it written in C or C++. Several edge-device vulnerabilities exploited by ransomware groups and state actors in recent years were memory corruption bugs. Until large codebases move to memory-safe languages, overflows will remain a regular source of critical CVEs.

Can Buffer Overflows Happen in Python or Java?

Code written purely in memory-safe languages such as Python, Java, C#, Go, or safe Rust is protected by bounds checking, so a classic overflow raises an exception instead of corrupting memory. However, these runtimes and many popular libraries contain native C or C++ components, and an overflow in that native code can still be exploited through your application. Keeping interpreters and native dependencies patched therefore still matters.

How Do I Know if My Software Is Vulnerable?

For third-party products, track vendor advisories and CVEs and scan your estate for affected versions. For in-house C or C++ code, combine static analysis, compiler warnings, AddressSanitizer test builds, and fuzzing, then commission a code review or penetration test for high-risk components such as parsers and network services. Binary analysis can also check whether compiled programs were built with canaries, ASLR, and DEP enabled.

What Is the Difference Between a Buffer Overflow and a Memory Leak?

A buffer overflow writes or reads outside the boundaries of allocated memory, corrupting neighbouring data or exposing it, and can lead to code execution. A memory leak is memory that a program allocates and never releases, so usage grows until performance degrades or the process crashes. Leaks are mainly a reliability problem, although attackers can sometimes exploit them to exhaust resources and cause denial of service.

Related Terms

You May Be Interested In These

What Is Impacket?

Cybersecurity Terms

17 November 2026

What Is Impacket?

Read More
What Is Key Management and Key Rotation?

Cybersecurity Terms

17 November 2026

What Is Key Management and Key Rotation?

Read More
What Is a Bug Bounty Programme?

Cybersecurity Terms

17 November 2026

What Is a Bug Bounty Programme?

Read More