CVE-2018-5382: Improper Validation of Integrity Check Value in Bouncy Castle
Summary
CVE-2018-5382: Improper Validation of Integrity Check Value in Bouncy Castle. Affects org.bouncycastle:bcprov-jdk15on versions < 1.50. Fixed in 1.50. How to fix ↓
Also tracked for
- bouncycastle · Debian:11
The same CVE-2018-5382 is tracked separately for each ecosystem and vendor. Its fix information is the same; the package and affected versions differ.
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
The Bouncy Castle library is a popular open-source cryptographic library for Java. It provides a wide range of cryptographic algorithms and functions, including support for various keystore formats. One of the keystore formats used by Bouncy Castle is the BKS keystore, which is a binary keystore format. The BKS keystore uses an HMAC (Hash-based Message Authentication Code) to ensure the integrity of the keystore file. However, prior to version 1.47 of Bouncy Castle, the default BKS keystore used an HMAC that was only 16 bits long, which could allow an attacker to compromise the integrity of the keystore. This vulnerability, identified as CVE-2018-5382, poses a moderate risk to applications using Bouncy Castle versions prior to 1.50.
Vulnerability Detail
The vulnerability arises from the use of a weak HMAC in the BKS keystore format. The 16-bit HMAC used in earlier versions of Bouncy Castle is susceptible to brute-force attacks, where an attacker can modify the keystore file without detection. This could lead to various security issues, such as unauthorized access to sensitive information or the injection of malicious code into the keystore. Bouncy Castle release 1.47 addressed this vulnerability by introducing a new BKS format that uses a 160-bit HMAC instead. However, the use of the legacy keystore type "BKS-V1" is discouraged, as it still relies on the weak 16-bit HMAC. It is recommended to upgrade to Bouncy Castle version 1.50 or later to mitigate this vulnerability.
How To Fix
Minimum fixed version
1.50
This is the first release that contains the fix.
Tip — Not sure which version your app runs? Vulert can match this fix to it. Scan free →
Workaround
If upgrading to Bouncy Castle version 1.50 or later is not feasible, a workaround is to manually convert the existing BKS keystores to the new format using the provided tools or APIs. This can be done by creating a new BKS keystore of type "BKS-V1" and importing the entries from the old keystore. However, it should be noted that this workaround is not recommended by the library authors and should only be used in situations where it is safe to do so.
Conclusion
The vulnerability in Bouncy Castle's BKS keystore format, identified as CVE-2018-5382, can compromise the integrity of the keystore and lead to various security risks. It is recommended to update applications to use Bouncy Castle version 1.50 or later to mitigate this vulnerability. If upgrading is not feasible, manual conversion of existing BKS keystores to the new format can be done as a workaround. For further support on vulnerability remediation, contact DevNack.com.
See every vulnerability recorded for org.bouncycastle:bcprov-jdk15on →
FAQ
The vulnerability allows an attacker to compromise the integrity of BKS keystores, potentially leading to unauthorized access to sensitive information or the injection of malicious code.
You can use Vulert's playground (https://vulert.com/scanner) to check if your application is affected by this vulnerability. Vulert monitors and alerts in real-time for open-source vulnerabilities, using just the pom.xml file of your application.
Yes, the vulnerability has been fixed in Bouncy Castle version 1.50. It is recommended to update your application to use this version or later to mitigate the vulnerability.
The use of the legacy keystore type "BKS-V1" is discouraged by the library authors and should only be used where it is otherwise safe to do so. It is recommended to migrate to the new BKS format with a 160-bit HMAC for improved security.
There are no known exploits for this vulnerability at the time of this advisory. However, it is important to address the vulnerability to prevent potential security issues.
Related vulnerabilities
Recent vulnerabilities recorded for org.bouncycastle:bcprov-jdk15on.