CVE-2018-5382: Bouncy Castle BKS-V1 keystore files vulnerable to trivial hash collisions

Published Mar 20, 2012
·
Updated

Affected versions of the package are vulnerable to Hash Collision due to an error in the BKS version 1 keystore files.

BKS is a keystore format, designed to function similarly to a Sun/Oracle JKS keystore. BKS files can contain public keys, private keys and certificates, and they rely on a password-based encryption to provide confidentiality and integrity protections to the keystore contents.

The first version of a BKS file (aka BKS-V1) contained a design flaw when determining the key size used to protect the keystore data. It used the SHA-1 hash function, which is 160 bits in length. In a RFC7292-compliant cryptographic algorithm, the MAC key size should be the same size as the hash function being used, meaning that the MAC key size should be 160 bits long for BKS files.

However, Bouncy Castle BKS-V1 files uses only 16 bits for the MAC key size. Regardless of the complexity of the password, ghe BKS-V1 file will have merely 65,536 different encryption keys. An attacker may bruteforce this password in a matter of seconds by testing all 65K values.

References:

https://insights.sei.cmu.edu/cert/2018/03/the-curious-case-of-the-bouncy-castle-bks-passwords.html https://www.kb.cert.org/vuls/id/306792

Other sources

Bouncy Castle could allow a local attacker to obtain sensitive information, caused by an error in the BKS version 1 keystore files. By utilizing an HMAC that is only 16 bits long for the MAC key size, an attacker could exploit this vulnerability using brute-force techniques to crack a BKS-V1 keystore file in seconds and gain access to the keystore contents.

IBM

The default BKS keystore use an HMAC that is only 16 bits long, which can allow an attacker to compromise the integrity of a BKS keystore. Bouncy Castle release 1.47 changes the BKS format to a format which uses a 160 bit HMAC instead. This applies to any BKS keystore generated prior to BC 1.47. For situations where people need to create the files for legacy reasons a specific keystore type "BKS-V1" was introduced in 1.49. It should be noted that the use of "BKS-V1" is discouraged by the library authors and should only be used where it is otherwise safe to do so, as in where the use of a 16 bit checksum for the file integrity check is not going to cause a security issue in itself.

MITRE

Affected Software

6 affected componentsFixes available
redhat/bouncycastle<1.47
1.47
bouncycastle Legion-of-the-bouncy-castle-java-crytography-api<=1.49
redhat Satellite=6.4
redhat Satellite Capsule=6.4
IBM GDE<=3.0.0.2
bouncycastle bc-java<=1.49

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade redhat/bouncycastle to a version that resolves this vulnerability.

    Fixed in 1.47
  2. Upgrade

    Upgrade Bouncy Castle to a version that resolves this vulnerability.

    Fixed in 1.47
  3. Upgrade

    Upgrade Bouncy Castle to a version that resolves this vulnerability.

    Fixed in 1.49
  4. Configuration

    Do not use the legacy BKS-V1 keystore type unless legacy reasons require it, because it uses only a 16-bit MAC key size (making brute-force feasible).

    Bouncy Castle (keystore format) keystore type = BKS-V1 (avoid)

Event History

Apr 16, 2018
CVE Published
via MITRE·01:00 PM
Data Sourced
via MITRE·01:00 PM
DescriptionWeakness
Data Sourced
via NVD·02:29 PM
DescriptionSeverityWeaknessAffected Software

Parent advisories

This vulnerability appears in the following advisories.

Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is CVE-2018-5382?

CVE-2018-5382 is a vulnerability in Bouncy Castle that could allow a local attacker to obtain sensitive information.

2

What is the severity of CVE-2018-5382?

The severity of CVE-2018-5382 is medium with a CVSS score of 4.4.

3

How can an attacker exploit CVE-2018-5382?

An attacker can exploit CVE-2018-5382 by compromising the integrity of a BKS keystore that uses a 16-bit HMAC.

4

How do I fix CVE-2018-5382?

To fix CVE-2018-5382, update Bouncy Castle to version 1.47 or later.

5

Where can I find more information about CVE-2018-5382?

More information about CVE-2018-5382 can be found at the following links: [link1](https://insights.sei.cmu.edu/cert/2018/03/the-curious-case-of-the-bouncy-castle-bks-passwords.html), [link2](https://www.kb.cert.org/vuls/id/306792), [link3](https://access.redhat.com/security/updates/classification/).

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203