[Paper Review] You Really Shouldn't Roll Your Own Crypto: An Empirical Study of Vulnerabilities in Cryptographic Libraries
This empirical study analyzes 300+ vulnerabilities in eight major cryptographic libraries, finding that 37.2% are memory safety issues rather than cryptographic flaws, and that code complexity—especially in C/C++—is a primary driver of vulnerabilities. The study demonstrates that cryptographic software has significantly higher vulnerability rates than non-cryptographic systems, with a median exploitable lifetime of 4.18 years and at least one vulnerability per 1,000 lines of code in OpenSSL, reinforcing the danger of 'rolling your own crypto'.
The security of the Internet rests on a small number of open-source cryptographic libraries: a vulnerability in any one of them threatens to compromise a significant percentage of web traffic. Despite this potential for security impact, the characteristics and causes of vulnerabilities in cryptographic software are not well understood. In this work, we conduct the first comprehensive analysis of cryptographic libraries and the vulnerabilities affecting them. We collect data from the National Vulnerability Database, individual project repositories and mailing lists, and other relevant sources for eight widely used cryptographic libraries. Among our most interesting findings is that only 27.2% of vulnerabilities in cryptographic libraries are cryptographic issues while 37.2% of vulnerabilities are memory safety issues, indicating that systems-level bugs are a greater security concern than the actual cryptographic procedures. In our investigation of the causes of these vulnerabilities, we find evidence of a strong correlation between the complexity of these libraries and their (in)security, empirically demonstrating the potential risks of bloated cryptographic codebases. We further compare our findings with non-cryptographic systems, observing that these systems are, indeed, more complex than similar counterparts, and that this excess complexity appears to produce significantly more vulnerabilities in cryptographic libraries than in non-cryptographic software.
Motivation & Objective
- To empirically assess the root causes of vulnerabilities in widely used cryptographic libraries.
- To investigate the relationship between code complexity and vulnerability frequency in cryptographic software.
- To compare vulnerability rates and characteristics between cryptographic and non-cryptographic systems.
- To evaluate the security implications of proposed 'exceptional access' mechanisms in encryption for law enforcement.
- To provide data-driven support for the long-held security principle that 'you shouldn’t roll your own crypto'.
Proposed method
- Collected vulnerability data from the National Vulnerability Database (NVD), GitHub repositories, mailing lists, and bug trackers for eight major cryptographic libraries.
- Classified vulnerabilities by type (e.g., cryptographic, memory safety, resource management) using NVD definitions and manual labeling.
- Measured codebase size and cyclomatic complexity to assess software complexity and correlate it with vulnerability frequency.
- Tracked vulnerability lifetimes by analyzing time from first public disclosure to patch release.
- Compared vulnerability rates in cryptographic libraries (OpenSSL, GnuTLS, etc.) with non-cryptographic systems (e.g., web browsers, OS components) to assess relative risk.
- Conducted a case study on LibreSSL and BoringSSL forks to analyze the impact of source code reduction on vulnerability reduction.
Experimental results
Research questions
- RQ1What proportion of vulnerabilities in cryptographic libraries are due to cryptographic flaws versus systems-level implementation issues?
- RQ2How does code complexity—measured by size and cyclomatic complexity—correlate with vulnerability frequency in cryptographic software?
- RQ3How do vulnerability rates and lifetimes in cryptographic libraries compare to those in non-cryptographic systems?
- RQ4What is the rate of vulnerability introduction per line of code in major cryptographic libraries like OpenSSL?
- RQ5To what extent does reducing codebase size through forking (e.g., LibreSSL, BoringSSL) lead to a measurable reduction in vulnerabilities?
Key findings
- Only 27.2% of vulnerabilities in cryptographic libraries are cryptographic issues, while 37.2% are memory safety or resource management bugs.
- The median exploitable lifetime of a vulnerability in a cryptographic library is 4.18 years, indicating prolonged exposure windows for attackers.
- In OpenSSL, at least one vulnerability is introduced for every 1,000 lines of code added, with vulnerability rates up to three times higher than in non-cryptographic software.
- Cryptographic software exhibits significantly higher code complexity than non-cryptographic systems, and this complexity correlates strongly with increased vulnerability frequency.
- Forks like LibreSSL and BoringSSL show a linear relationship between source code reduction and vulnerability reduction, supporting the hypothesis that simpler codebases are more secure.
- The study provides empirical evidence that complexity is a greater threat to security in cryptographic software than cryptographic design flaws, reinforcing the principle against 'rolling your own crypto'.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.