How it works · 21 of 34 Core
What are memory-safety bugs like buffer overflows?
Writing past the end of the box
Memory-safety bugs: In languages like C and C++, a program can write more data than the space it set aside, spilling into the memory next to it; if that neighbour holds "where to go next", an attacker's data decides what the program runs.
Loading the animation…
Say it like this A memory-safety bug is when a program writes more data than the space it set aside, spilling into the memory next door; if that neighbour holds where to go next, the attacker's data steers the program. Memory-safe languages check the size every time.
Under the hood — for builders
- Real example: the jug and the note, run here
- Eight bytes for a name sit right before eight bytes saying where to go next. The same 16-letter name, poured in by C and by Rust:
- How common: three counts
- Two big vendors count the same share, and Android shows what changes when new code moves to memory-safe languages:
- The family: four ways to spill
- "Memory-safety bug" covers several mistakes. Each still ends with data landing where it shouldn't:
- In our papers: spills before login
- The worst cases are spills an attacker can trigger before signing in, over the network:
- Ask a vendor
- Which parts that read network data are written in C or C++? Which C libraries do you ship, and how fast do you take their fixes?
- Watch out
- Rewriting everything is rarely the answer. Write new network-facing code in a memory-safe language (Rust, Go, Java) and fuzz the old C (D5).
- Sources
- Miller, Microsoft BlueHat IL 2019 · Chromium memory-safety page · Google Security Blog, Sep 2024 · our lwIP, MikroTik and Citrix papers · gcc/rustc run for this card.
What happens in the memory-safety bugs animation, step by step?
- A program sets aside a 1-litre jug for your name. The jar beside it holds a note: where to go next.
- A short name fits. The program fills the jug, reads the note, carries on.
- Your turn: send a longer name. What happens when it's bigger than the jug?
- The spill rewrites the note. The program goes where the attacker's data says: their code runs.
- This one bug family is about 70% of Microsoft's security fixes and of Chrome's serious bugs.
- Memory-safe languages check the jug's size every time. But some programs check sizes perfectly and still forget to check who's asking. Next: broken access control.
What everyday example explains memory-safety bugs?
Pouring 2 litres into a 1-litre jug on a shelf. It overflows onto the next shelf, and if that shelf holds the note saying where to go next, the spill rewrites the note.
Why should a team care about memory-safety bugs?
When you choose components for new devices or services, prefer memory-safe languages (Rust, Go, Java) for code that reads data from the network, and ask suppliers which C libraries they ship, because you inherit every jug they pour into.