Podcast
Root Causes 312: Why You Shouldn't Roll Your Own Crypto
Hosted by
Jason Soroko
Fellow
Original broadcast date
June 20, 2023
Don't roll your own crypto. In this episode we describe the findings from 2021 research that investigating the root causes of problems in cryptographic systems. The results may surprise you.
Podcast transcript
Lightly edited for flow and brevity.
TCTim CallanSo, Jason, I’m gonna start with a question and based on many things you’ve said on this podcast in the past, I think I know the answer to that question, but I’m just gonna ask you. Should one roll one’s own crypto?
TCTim CallanSo, this has now moved out of the realm of opinion and into the realm of academically established, peer reviewed fact. I am referencing a paper that you called my attention to originally, Jay, from July 2021 – so it took me a little while to get to it – and the title is You Really Shouldn’t Roll Your Own Crypto. An Empirical Study of Vulnerabilities and Cryptographic Libraries. It’s from three researchers from MIT – Jenny Blessing, Michael Specter and Daniel Weitzner. So, congrats Jenny, Michael and Daniel.
And, basically, what these researchers did is research the nature of vulnerabilities in cryptographic systems. They went to a set of commonly available, commonly used crypto systems. There’s a list here. Cryptographic libraries - OpenSSL, GnuTLS, Mozilla NSS, WolfSSL, Botan, Libgcrypt, LibreSSL and BoringSSL. They took this set of cryptographic libraries, and they needed a common database of vulnerabilities, and so what they wound up with was the common vulnerabilities and exposure CVE list that goes through lists for libraries and what they wanted to do. That’s from the National Vulnerability Database in particular. They took the CVE list from the National Vulnerability Database and analyzed these vulnerabilities by their nature. What is the nature of these vulnerabilities inside these cryptographic libraries?
I think you know what this paper says, Jay, because you sent it my way originally but try to channel the common person. What do you think the average informed IT person would imagine would be the main source of vulnerabilities and problems with cryptographic libraries?
And, basically, what these researchers did is research the nature of vulnerabilities in cryptographic systems. They went to a set of commonly available, commonly used crypto systems. There’s a list here. Cryptographic libraries - OpenSSL, GnuTLS, Mozilla NSS, WolfSSL, Botan, Libgcrypt, LibreSSL and BoringSSL. They took this set of cryptographic libraries, and they needed a common database of vulnerabilities, and so what they wound up with was the common vulnerabilities and exposure CVE list that goes through lists for libraries and what they wanted to do. That’s from the National Vulnerability Database in particular. They took the CVE list from the National Vulnerability Database and analyzed these vulnerabilities by their nature. What is the nature of these vulnerabilities inside these cryptographic libraries?
I think you know what this paper says, Jay, because you sent it my way originally but try to channel the common person. What do you think the average informed IT person would imagine would be the main source of vulnerabilities and problems with cryptographic libraries?
TCTim CallanSo what I’ll do if it’s fair is roll all these up and call them cryptographic implementation problems. It might have to do with keys or algorithms or deprecated processes or things along those lines.
TCTim CallanOk. So the most common problem according to this research in cryptographic systems was memory management problems. The most common vulnerability was memory related vulnerabilities. Had nothing to do with cryptography. It was software coding error.
TCTim CallanAnd we know that from Heartbleed.
TCTim CallanThe most devastating crypto-based attack that ever occurred wasn’t a problem with the cryptography.
TCTim CallanIt was a buffer override attack.
TCTim CallanExactly. And Heartbleed is just such as a case study of this. Blessing, Specter, Weitzner, here’s a quote from their paper. “Systems level bugs are a greater security concern than the actual cryptographic procedures.” That’s it in black and white. To put some numbers on it, 27.2% of the analyzed vulnerabilities were actually what they call cryptographic issues (and they have a methodology for classifying them), while 37.2% were memory safety issues. They go on to analyze the level of complexity of a cryptographic system and the number of CVEs and the conclusion they are basically coming to is the thing about cryptographic systems is they are more complex than your average bear. They are more complex than a lot of what we are running just by the nature of what they are doing and as a consequence of that, there’s just more opportunity for errors. And because there’s more opportunity for errors, there’s more opportunity for errors that are vulnerabilities and there’s more opportunities for those vulnerabilities to be discovered and exploited. And they see it as being really that simple.
TCTim CallanCode is complex. We know this. Software errors happen. They are part of life and that means they also happen in things that are really essential and really important, and in just a few recent episodes we’ve talked about direct attacks and vulnerabilities that stem from that kind of thing. And here in this case, we are looking at I think a pretty compelling case that in cryptographic systems the problems aren’t fundamentally all that different.
I have a breakdown here of the different types: Cryptographic issues are 25.8%, memory buffer issues 19.4%, resource management errors 17.7%, exposure of sensitive information 11.3%, improper input validation (of all things) 11.3%, numeric errors (hmm, I wonder what that means) 5.3%, and then other is a 9.2%. So, you know, a small number of things dominate but the memory error issues are actually worse on the whole than the actual cryptographic issues even in these complicated, very esoteric, cryptographic systems.
I have a breakdown here of the different types: Cryptographic issues are 25.8%, memory buffer issues 19.4%, resource management errors 17.7%, exposure of sensitive information 11.3%, improper input validation (of all things) 11.3%, numeric errors (hmm, I wonder what that means) 5.3%, and then other is a 9.2%. So, you know, a small number of things dominate but the memory error issues are actually worse on the whole than the actual cryptographic issues even in these complicated, very esoteric, cryptographic systems.
TCTim CallanOh, it’s been a long time since we talked about floating points.
TCTim CallanThank you. That helps.
Now, I’m gonna show you one other thing which is – and I just found this interesting – it’s the exploitable lifetime. This is Table 3 of this paper. Exploitable lifetimes in years of vulnerabilities in cryptographic libraries. So, they include three. They use OpenSSL, GnuTLS and Mozilla NCSS, and that was all they could get data for. They’ve got a bunch of columns. They got two columns I’m gonna focus on – median lifetime and average lifetime, because we know average and median of course are not the same. OpenSSL – this is median lifetime of an exploitable vulnerability in years. Should I make you guess or should I just tell you?
Now, I’m gonna show you one other thing which is – and I just found this interesting – it’s the exploitable lifetime. This is Table 3 of this paper. Exploitable lifetimes in years of vulnerabilities in cryptographic libraries. So, they include three. They use OpenSSL, GnuTLS and Mozilla NCSS, and that was all they could get data for. They’ve got a bunch of columns. They got two columns I’m gonna focus on – median lifetime and average lifetime, because we know average and median of course are not the same. OpenSSL – this is median lifetime of an exploitable vulnerability in years. Should I make you guess or should I just tell you?
TCTim Callan4.14 years median lifetime. Average lifetime, 6.16 years. GnuTLS is doing much better. It’s got a median lifetime of a mere 1.65 years and an average lifetime of a mere 2.35 years and Mozilla NSS has a median lifetime of 12.43 years and an average lifetime of 9.43 years. So, WOW!
TCTim CallanThese vulnerabilities are just sitting out there. Then, like I said, they have a whole analysis where they basically compare a number of bugs to code complexity and they have a method for that and the conclusion they come to is that it’s pretty correlative that the more complex the code, the more the bugs you get and that really code complexity is the ultimate source of this problem. The reason that cryptographic systems seem to have more bugs that other systems is they just also have more code and more complex code.
TCTim CallanYes. It makes sense. I’m not sure how directly actionable it is, but things like this are always interesting and I love to look at them and think about them and think about what they imply.
TCTim CallanYeah. It’s hard. It’s even hard for the people who do this professionally.
TCTim CallanSo, anyway, thank you to the three MIT researchers for this. It certainly was an interesting read and wanted to make sure we share it. I don’t have any data behind this but just having been around the world, I think you correctly, in my opinion, channeled what the average person would have said which is, oh, cryptography is, you know, there’s all this esoteric stuff and people are gonna get the esoteric stuff wrong. And we see that. You and I see examples for that on a routine basis. But what’s interesting here is just to say, hey, code is hard and complicated code is extra hard and complicated code that is fundamentally meant to be secure is a place to be ultra careful. It’s interesting and enlightening to see that backed up by the evidence.
TCTim CallanI was going to. I was just gonna sit down and roll my own crypto, but instead in guess I won’t.
TCTim CallanAlright.