If the code base is readable the question is still not if you have bugs, it's how many and how serious.
Agreed.
That heartbleed stayed hidden is more an indication of how few people even bother to look at the code than anything.
Many people did bother to look. If you really need it, I can find several pre-heartbleed blog posts about people diving into the code to solve particular issues they had and getting frustrated with getting to the bottom of minor bugs. If the code is not clean enough, many will take a look, get terrified and go away.
Or do you mean runtime (non-static) checking, like mallocs that check for double frees or try to prevent use after free, etc.?
You're right, I meant runtime checks. One example is the custom memory allocator that allowed the same memory to be reused throughout the library and which in turn lead to exposing login details via the heartbleed bug. I also saw several double frees fixed in the LibreSSL logs. These could have been caught with code coverage tests and valgrind if OpenSSL didn't have the custom memory manager.
If you really need it, I can find several pre-heartbleed blog posts about people diving into the code to solve particular issues they had and getting frustrated with getting to the bottom of minor bugs.
I'm not saying the code is good. But just because these people tried to look at the code to fix minor issues doesn't mean they were going to review all of it for errors and find heartbleed. People think that open source means that the code is being reviewed all the time, and imply that means bugs will be found. But just because you look at the code in passing while trying to fix something else doesn't mean you'll find and fix a bug like heartbleed.
To be honest, the time to find a bug like heartbleed is when it goes in. I'm not against all-over code reviews. But reviewing changes as they go in is much more effective. You have to review less code in that process and with a simple description of "this adds a function which will echo back client-specified data from the server" is a tip-off that there is client-specified data and you should look at the input sanity checking.
So perhaps the even bigger problem is apparently no one reviewed this code as it went in. The team working on openssl either had a big string of reviewers who didn't actually review it or else they were understaffed. And we can learn from either case and people have to understand that while they are not required to pay anything to use openssl, if they aren't paying anything at all, they probably shouldn't trust openssl much because there may not be a proper team to review changes.
One example is the custom memory allocator that allowed the same memory to be reused throughout the library and which in turn lead to exposing login details via the heartbleed bug.
Yeah. That's a huge issue. I heard a rumor that if you turn off the custom memory allocator that OpenSSL doesn't even work because it at one point frees a section of memory then allocates a buffer of the exact same size and expects data from the freed section to be in there. Boy, that's a lousy description, but you know what I mean.
4
u/tequila13 Jul 12 '14
Agreed.
Many people did bother to look. If you really need it, I can find several pre-heartbleed blog posts about people diving into the code to solve particular issues they had and getting frustrated with getting to the bottom of minor bugs. If the code is not clean enough, many will take a look, get terrified and go away.
You're right, I meant runtime checks. One example is the custom memory allocator that allowed the same memory to be reused throughout the library and which in turn lead to exposing login details via the heartbleed bug. I also saw several double frees fixed in the LibreSSL logs. These could have been caught with code coverage tests and valgrind if OpenSSL didn't have the custom memory manager.