A couple of nits:
That being said, this is a good example of a real problem with a real solution, explaining an important concept - nice!
Thanks for the nits, cuz this kind of thing is all about nits! Agree with the first two, re your third one, it's safeSub and safeAdd that would protect from overflows. Like the transaction, they're more complex in the sense that their implementation is probably slower and more code, but simpler in the sense that they have a less constrained "safe space of operation". (I am in search of a better term for that.)
(We're always in search of a concise and actionable way to communicate security mindset. Here's my attempt.)
Just as a sprocket you don't use never fails and code you don't write has no bugs, an input constraint you don't require is never violated.
Want a secure system? Then DO yourself a FAVAR:
Let's take this
transferMoney
procedure in a token program or an online bank as a case study:transfer
's executionNow the system can tolerate untrusted input, a database connection that fails, simultaneous calls to
transfer
, etc. We reduced complexity instead of increasing it.When we're trying to make safe AI, it is so so much higher impact to remove an assumption than to add a check or balance.
The hardest parts are finding and removing assumptions, so the full message is "DO yourself a FAVAR, FR!"
More examples
See also