4 ms·
I like this article. I want to correct something on C and C++ side. He hints it's barely possible to write correct C. He doesnt mention how safety-critical sec
by nickpsecurity 8y ago
I like this article. I want to correct something on C and C++ side.
He hints it's barely possible to write correct C. He doesnt mention how safety-critical sector, esp regulated, cranks out reliable C on a regular basis. They use C subsets with careful coding, reviews, and every automated tool they can. Static analyzers, automated testing, you name it. There's also analyzers that, when they work, can prove absence of entire classes of errors. RV-Match, Astree Analyzer (used by Airbus), and Frama-C are examples. CompCert eliminates compiler errors afterward. Most security-critical development doesnt use tools like these even when companies can afford them. It's apathy, not technological capability.
Now, C++ is special given it was designed to reduce risks of using C. Yet, almost all the verification tooling was for C and Java. C++ is just so complicated that it's hard to statically analyze or even build tools for. That means a C program done like above might have fewer errors than a C++ program. For that reason, I recommend avoiding C++ in favor of either C or safe systems languages compiling to C to take advantage of its verification tooling. They're getting hit with these vulnerabilities because they using a harder-to-analyze language possibly with coding strategy that adds difficulty. See Cleanroom Software Engineering or Praxis's Correct-by-Construction for examples of low-defect, development strategy.
- blub 8y agoI completely agree with your assertion regarding the verification tools for C, unfortunately most commercial projects (i.e. not regulated) won't pick between e.g. Frama C and C++ and instead will choose between plain old C and C++, thereby making C a very poor choice.
- snazz 8y agoNitpick: The idea of your comment is sound, but Frama-C is a C program static analysis framework, not a C subset. You still write regular old C even with Frama-C.
- nickpsecurity 8y agoYeah, but I didn't say pick between Frama-C and C++. I said pick between a subset of carefully-written C with all the tooling one could throw at it and C++. The latter comparison is an easier tradeoff to make than the former. Especially with the tools I mentioned with low, false positives. They'd be serving Google well right now. Among other users.
- brandmeyer 8y agoC has gotten considerably better over the last decade with the wide availability of dynamic analysis tools. Its not particularly difficult to run a project's unit tests under each of the various sanitizers nowadays.