Tech●●●●●Difficulty 4 of 5

Why is the US government telling programmers to move away from C?

About 70% of serious security bugs in some huge codebases come from memory-safety mistakes, and agencies like CISA and the NSA now say so in writing.

▶ Start the story

The US government's concern is not really about C itself. It is about a kind of bug that C makes easy and that causes a huge share of security holes. Memory safety is the state of being protected from software bugs and vulnerabilities in memory access, such as and . Java is memory-safe because its runtime checks array bounds and pointer dereferences. C, C++ and Fortran allow arbitrary with no , which makes them memory-unsafe.

A buffer overflow is a bug in which a program writes data beyond the end of a buffer's allocated memory, overwriting whatever lies next to it. The earliest documented hostile use of one was in 1988, as one of several exploits of the Morris worm. And the problem is not rare: in 2019 a Microsoft security engineer reported that 70% of all security vulnerabilities were caused by memory safety issues, and in 2020 a Google team found that 70% of severe security bugs in Chromium had the same cause.

70%

of severe Chromium security bugs came from memory safety problems (Google, 2020)

So CISA, the US cybersecurity agency, and the FBI listed it among "bad practices". They call developing new critical-infrastructure product lines in a memory-unsafe language such as C or C++ dangerous when readily available memory-safe languages could be used. For existing products, they say having no published memory safety roadmap is dangerous. But read closely: the guidance is non-binding and imposes no requirement, and the authors acknowledge that migrating takes significant time and resources. CISA and the NSA also published a joint guide on how to adopt memory safe languages.

Rust is one alternative that does not rely on garbage collection. It enforces memory safety without a conventional garbage collector, using a that tracks the lifetime of references at compile time. Its creator, Graydon Hoare, reportedly started it out of frustration with an apartment elevator whose software had crashed.

Quiz me

0/3

  1. 1.What makes C and C++ memory-unsafe, unlike Java?
  2. 2.What does CISA's guidance actually say about C and C++?
  3. 3.How does Rust achieve memory safety without a conventional garbage collector?

Recap

C and C++ trust the programmer to stay inside memory's lines, while memory safe languages like Java and Rust enforce the lines.

💡 A trick to remember it · Unsafe languages hand you the keys to the whole library; safe ones only let you into your own aisle.

Surprising fact · The US guidance is non-binding, and it asks for roadmaps for old software, not an overnight ban on C.

Sources (5)

No source, no claim. Every fact in this lesson (15 claims) cites at least one of these.

  1. [1]Memory safety · Wikipedia
  2. [2]Buffer overflow · Wikipedia
  3. [3]Product Security Bad Practices · CISA
  4. [4]Memory Safe Languages: Reducing Vulnerabilities in Modern Software Development · CISA
  5. [5]Rust (programming language) · Wikipedia
More lessons in 💻 Tech (3) See all tech lessons →

One more light on your map.

Get one lesson like this every day, about the things you love. Free, in two or five minutes.

Get the share card for this lesson ↗