6 ms·
How Heartbleed Leaked Private Keys
- yread 13y agoI am still surprised there is code like if(b->d) OPENSSL_free(b->d); in OpenSSL :(
- pyvpx 13y agosome folks much smarter than I thought it best to proverbially take it out back and shoot it. if you're not familiar with it already, the left overs are called LibreSSL.
- endgame 13y agoAnd if you want to watch the carnage, the highlights are at http://opensslrampage.org/ http://opensslrampage.org/ .
- bbwharris 13y agoForgive me for asking but what is wrong in particular with this single line? To me it reads fine and the idea is that is frees that data address if its occupied. I'm sure I'm not the only one who is curious why this is bad.
- yread 13y agoMy concerns are well addressed in the patch: if (b->d != NULL) {
- Nursie 13y agoThere's no need to explicitly include NULL in there, it buys you nothing. Insisting on braces is a style concern, though it does seem to protect people from themselves to some extent.
- CamperBob2 13y agoIf you're careful to use NULL only in pointer expressions, it can be used to indicate that a pointer is being tested, as opposed to any other sort of integer or boolean flag. You can justify it on grounds similar to Hungarian notation, giving the reader some contextual information that might otherwise require a look at a declaration somewhere else. Code should be written for the benefit of humans, not compilers.
- Nursie 13y agoI agree, but the humans also need to be able to understand the code. I've worked in places where the ternary operator was banned because 'some people might not understand it'. This is silly.
- CamperBob2 13y agoYeah, that's pretty goofy. Being intimidated by the ternary operator is how you know you should have gone into marketing instead.
- logicallee 13y agoI don't think you should be testing for truth implicitly like that, try if ((bool(b->d != NULL) == true) { } much better to be explicit, don't you think?
- Nursie 13y agoAssuming this is satire, LOL :)
- patrickas 13y agoThe sensitive data that was saved in that address is still there. Memory has been freed so the os can use is again but the actual data is still there is memory untill get get overwritten by something else... The program will work with no problems, but sensitive data that has been used then freed is available for retrieval when bugs like heartbleed are found. As the article suggests the right way is to clean the data from memory ( by overwriting it with something else) before freeing it.
- Nursie 13y agoI've been looking at this recently, part of the problem with that approach is that compilers will often optimise out an overwrite if they can't see anything happening afterwards. For instance if you set a stack-resident buffer that contained a key to all zeros using memset, then simply exit the scope, most optimisations will detect it as unnecessary (wtf? this never gets read back, who cares?) and ditch the line. Search for memset_s (part of the C11 standard) for a clear function that can survive optimisers.
- bbwharris 13y agoGotcha, I wasn't thinking about that.
- syncsynchalt 13y agoFor one, free() is a no-op on a null.
- junto 13y agoEvery time I see a blog post from the Cloudflare team I am impressed. It isn't just their attention to detail that is impressive. They go out of their way not just to point out issue, but suggest fixes. Too many Heartbleed blog posts from across the blogosphere, and sadly, HN comments, set out to criticize without suggesting something better. Cloudflare has shown again that they are actively engaging the community for the communities benefit as well as their own. This seems to be a very effective marketing strategy (I assume it is anyway).
- ibmthrowaway218 13y agoI would have been more impressed had their original assessment of heartbleed (on nginx) not been "We've reviewed the code and we don't think it's vulnerable." Looking impressive with hindsight is relatively easy.
- jgrahamc 13y agoThe original blog post on Heartbleed said: "Here’s the good news: after extensive testing on our software stack, we have been unable to successfully use Heartbleed on a vulnerable server to retrieve any private key data. Note that is not the same as saying it is impossible to use Heartbleed to get private keys. We do not yet feel comfortable saying that." In that same blog post we also said that we were revoking and reissuing all our SSL keys, and started the challenge web site to see if private keys could be retrieved. http://blog.cloudflare.com/answering-the-critical-question-can-you-get-private-ssl-keys-using-heartbleed http://blog.cloudflare.com/answering-the-critical-question-c... So, yeah, we didn't from the outset figure out how to get the private keys, but we decided that the risk was too high so we want ahead with revocation.
- ibmthrowaway218 13y agoI don't think it's unfair to paraphrase this statement:- "And, we have reason to believe based on the data structures used by OpenSSL and the modified version of NGINX that we use, that it may in fact be impossible." as "We've reviewed the code and we don't think it's vulnerable." Obviously you disagree.