Elio Grieco
11-June-2025
Talk given at Rust <> Security , Wed, Jun 11, 2025, 7:00 PM session of the Desert Rust Meetup.

Slides available at: https://eliogrieco.com/typical-programming/
NewType and TypeState patterns in Rust
Inspired by:
Bugs or software defects come in 3 main flavors:
“Fools ignore complexity. Pragmatists suffer it. Some can avoid it. Geniuses remove it.”
—Alan Perlis
Failing to manage complexity leads to bugs and security issues by introducing Weird Machine behavior.
We have more than enough of those already…

Hidden complexity can be a lethal danger.
What appears to be a small stream one could easily jump across hides unfathomable depths of around 65 meters.
So let’s put in some guardrails.
This way we can still work with complexity but appreciate it in a safe way.
We can integrate the security model directly into the code. This makes it very difficult for devs to miss something or to misuse a value.
MAC then Encrypt or Encrypt then Mac?
We can enforce correct transitions to ensure that people don’t compose operations in dangerous ways.
eunicode: A text processing CLI and library that helps sanitize text by removing the naughty bits to make strings good and safe.
There are many other approaches to ensureing safety, reliability, correctness, and security in code.
“I use these techniques and languages, not because I’m a genius, but because I’m smart enough to know that I can’t write high quality software without them.”
— David Koontz
So where do we go from here?
Are there more patterns and tools to manage complexity?