Cybersecurity glossary

What is Memory Corruption?

Learn what memory corruption is, how buffer overflows and use-after-free bugs undermine program integrity, what attackers achieve with exploits, and which secure coding and mitigation controls help.

Application securityUpdated July 20, 2026
Also known asMemory safety violationMemory corruption vulnerability

Definition

Memory corruption is a class of software flaws in which a program writes to or uses memory in unintended ways—such as buffer overflows, use-after-free, or out-of-bounds access—breaking integrity of data or control flow and often enabling crashes or code execution.

Why memory corruption matters

Software stores code and data in the same finite memory space. When a program writes past an array, reuses freed objects, or confuses object types, it can overwrite values the developer never meant to expose—return addresses, function pointers, security flags, or neighboring objects.

Memory corruption is the umbrella term for those mistakes. On modern systems it remains a primary path to remote code execution in browsers, operating systems, and native libraries that sit behind web applications.

Common memory corruption classes

Buffer overflow

More data is written into a buffer than it can hold, overwriting adjacent memory.

Use-after-free

Memory is freed, then accessed again, often letting attackers control what occupies that space.

Out-of-bounds read

Reads past valid bounds leak secrets or aid further exploitation.

Type confusion

A value is treated as the wrong type, causing invalid field access and corruption.

How exploitation typically progresses

1

Reach a vulnerable parser

Attackers send crafted files, packets, images, or protocol messages to native code.

2

Trigger corruption

Overflow, free/reuse, or type confusion alters memory state.

3

Gain useful primitives

Controlled read/write or instruction-pointer influence is established.

4

Bypass mitigations

ASLR, DEP/NX, and CFG/CFI may require information leaks and chained techniques.

5

Execute attacker code or goals

Shellcode, ROP, or logic corruption achieves code execution or privilege goals.

6

Persist or pivot

The foothold expands into the broader system or user session.

Mitigations and their limits

ControlWhat it helpsLimit
ASLRRandomizes address layoutsWeakened by info leaks
DEP/NXBlocks execute on data pagesBypassed with ROP/JOP
Stack canariesDetect some stack overflowsNot all corruption paths
SandboxingContains blast radiusSandbox escapes exist
Memory-safe languagesEliminates many bug classesUnsafe FFI still risky

Practical prevention checklist

  • Prefer memory-safe languages for new components that parse untrusted input.
  • Enable compiler and OS hardening flags by default in build pipelines.
  • Fuzz file and protocol parsers continuously; treat crashes as security bugs.
  • Sandbox codecs, converters, and third-party native modules.
  • Keep browsers, TLS libraries, VPN clients, and image processors patched promptly.
  • Avoid unsafe C APIs (for example, unbounded string copies) in legacy code.
  • Restrict who can upload or process complex file formats on high-value systems.
  • Assume public-facing native parsers will be targeted; design containment first.

The practical takeaway

Memory corruption breaks the contract between a program and its memory, creating crashes—and sometimes attacker-controlled execution. Mitigations raise cost; safer languages and rigorous testing remove entire bug classes.

If your stack parses untrusted bytes in C/C++, treat memory safety as a first-class product risk equal to web injection flaws.

Related security terms

Frequently asked questions

What is memory corruption in simple terms?

Memory corruption happens when software messes up how it uses RAM—writing past a buffer, freeing memory and using it again, or reading the wrong region. Attackers can turn those mistakes into crashes or takeovers.

What are common types of memory corruption?

Buffer overflows/underflows, use-after-free, double-free, type confusion, and out-of-bounds reads/writes are among the most common.

Which languages are most affected?

Memory-unsafe languages such as C and C++ are classic sources. Memory-safe languages reduce entire classes of bugs but can still call unsafe native code.

Do DEP, ASLR, and Control Flow Integrity stop all exploits?

They raise cost and block many simple attacks, but skilled exploit chains can bypass mitigations. Fixing bugs and using safer languages remain essential.

Is a crash always exploitable?

No. Some corruptions only cause denial of service. Others become reliable code execution with enough attacker control. Treat crashes in parsers as serious until analyzed.

How do teams prevent memory corruption?

Prefer memory-safe languages where practical, use safe APIs, enable compiler hardening, fuzz parsers, and apply sandboxing around risky components.

Where do these bugs show up on the web?

Browsers, image/PDF codecs, VPN clients, TLS libraries, and native modules behind web apps are frequent targets—even when the web tier itself is managed code.

References

Explore authoritative guidance and frameworks related to memory corruption.

Explore every security definition

Return to the glossary to search by term, alias, starting letter, or security category.

Browse glossary