Chapter 13: Security

Memory safety

Also called Buffer overflow, Use after free, Memory-safe language

Code is memory-safe when it can't read or write memory it doesn't own. C and C++ leave that to the programmer, so one wrong length can overwrite whatever sits next to it. Languages like Rust, Go, Java and Python check it for you, or won't let you write it.

It is the largest single kind of serious bug in big C and C++ systems, and ordinary tests rarely see it, because the program carries on. Writing JavaScript or Python covers most of it for you. It comes back the moment an agent writes a native module, or offers to port one.

Say it to your agent

“This C parser reads files from strangers. Build it with -fsanitize=address, fuzz it for ten minutes, and paste each crash with its stack. Don't fix anything yet. Then estimate what it would take to port only this parser to Rust, and list every place the port would still need unsafe.”

The workshop

Name a word, or describe what you mean in everyday language.