GHSA-4446-656p-f54g CVE-2018-1000613
Deserialization of Untrusted Data in Bouncy castle
- Severity
- 9.8 / 10
- Critical · CVSS 3.0
- Exploit chance (EPSS)
- 4.77%
- Chance of exploitation in the next 30 days. Higher than 91.91% of scored vulnerabilities.
- Known exploited
- No
- Not in CISA's catalog
- Weakness
- CWE-470 Use of Externally-Controlled Input to Select Classes or Code ('Unsafe Reflection')
- CWE-502 Deserialization of Untrusted Data
- Fix
1.60- Upgrade org.bouncycastle:bcprov-jdk15on to this version or later
Description
Legion of the Bouncy Castle Java Cryptography APIs starting in version 1.57 and prior to version 1.60 contains a CWE-470: Use of Externally-Controlled Input to Select Classes or Code ('Unsafe Reflection') vulnerability in XMSS/XMSS^MT private key deserialization that can result in Deserializing an XMSS/XMSS^MT private key can result in the execution of unexpected code. This attack appear to be exploitable via A handcrafted private key can include references to unexpected classes which will be picked up from the class path for the executing application.
This vulnerability appears to have been fixed in 1.60 and later.
Affected versions
Maven
| Package | Vulnerable | Fixed in |
|---|---|---|
| org.bouncycastle:bcprov-jdk15on | >= 1.57, < 1.60 |
1.60 |
How to fix
Move to the fixed version or later with your package manager, update the lockfile, and run your tests. If the package only arrives through another dependency, upgrade that dependency first. If none of its releases pulls a fixed version yet, force the version with your package manager's override.
org.bouncycastle:bcprov-jdk15on Maven → 1.60
- maven
<dependency><groupId>org.bouncycastle</groupId><artifactId>bcprov-jdk15on</artifactId><version>1.60</version></dependency>- gradle
implementation("org.bouncycastle:bcprov-jdk15on:1.60")
Severity breakdown
CVSS 3.0 9.8
CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
- Attack vector
- Network
- Attack complexity
- Low
- Privileges required
- None
- User interaction
- None
- Scope
- Unchanged
- Confidentiality
- High
- Integrity
- High
- Availability
- High
Weakness
CWE-470: Use of Externally-Controlled Input to Select Classes or Code ('Unsafe Reflection')
The product uses external input with reflection to select which classes or code to use, but it does not sufficiently prevent the input from selecting improper classes or code.
How to prevent it
- Architecture and Design: Refactor your code to avoid using reflection.
- Architecture and Design: Do not use user-controlled inputs to select and load classes or code.
- Implementation: Apply strict input validation by using allowlists or indirect selection to ensure that the user is only selecting allowable classes or code.
CWE-502: Deserialization of Untrusted Data
The product deserializes untrusted data without sufficiently ensuring that the resulting data will be valid.
How to prevent it
- Architecture and Design, Implementation: If available, use the signing/sealing features of the programming language to assure that deserialized data has not been tainted. For example, a hash-based message authentication code (HMAC) could be used to ensure that data has not been modified.
- Implementation: When deserializing data, populate a new object rather than just deserializing. The result is that the data flows through safe input validation and that the functions are safe.
- Implementation: Explicitly define a final object() to prevent deserialization.
- Architecture and Design, Implementation: Make fields transient to protect them from deserialization. An attempt to serialize and then deserialize a class containing transient fields will result in NULLs where the transient data should be. This is an excellent way to prevent time, environment-based, or sensitive variables from being carried over and used improperly.
- Implementation: Avoid having unnecessary types or gadgets (a sequence of instances and method invocations that can self-execute during the deserialization process, often found in libraries) available that can be leveraged for malicious ends. This limits the potential for unintended or unauthorized types and gadgets to be leveraged by the attacker. Add only acceptable classes to an allowlist. Note: new gadgets are constantly being discovered, so this alone is not a sufficient mitigation.
- Architecture and Design, Implementation: Employ cryptography of the data or code for protection. However, it's important to note that it would still be client-side security. This is risky because if the client is compromised then the security implemented on the client (the cryptography) can be bypassed.
- Operation: Use an application firewall that can detect attacks against this weakness. It can be beneficial in cases in which the code cannot be fixed (because it is controlled by a third party), as an emergency prevention measure while more comprehensive software assurance measures are applied, or to provide defense in depth [REF-1481].
References
Advisories
Packages
Other links
- github.com/bcgit/bc-java/commit/4092ede58da51af9a21e4825fbad0d9a3ef5a223
- github.com/bcgit/bc-java/commit/cc9f91c41be67e88fca4e38f4872418448950fd9
- github.com/bcgit/bc-java/commit/cd98322b171b15b3f88c5ec871175147893c31e6
- lists.apache.org/thread.html/rf1bbc0ea4a9f014cf94df9a12a6477d24a27f52741dbc87f2fd52ff…
- lists.apache.org/thread.html/rf1bbc0ea4a9f014cf94df9a12a6477d24a27f52741dbc87f2fd52ff…
- security.netapp.com/advisory/ntap-20190204-0003
- oracle.com/security-alerts/cpuApr2021.html
- oracle.com/security-alerts/cpuapr2020.html
- oracle.com/security-alerts/cpuoct2020.html
- oracle.com/technetwork/security-advisory/cpuapr2019-5072813.html
- oracle.com/technetwork/security-advisory/cpujan2019-5072801.html
- oracle.com/technetwork/security-advisory/cpujul2019-5072835.html
- lists.opensuse.org/opensuse-security-announce/2020-05/msg00011.html
Timeline
- Published
- Last updated by the source
- Latest EPSS score
Related advisories
| Advisory | Severity | Why it's related |
|---|---|---|
| GHSA-574f-3g2m-x479 Bouncy Castle for Java GOST 28147 CTR mode reuses keystream after 255 blocks | High | Also affects org.bouncycastle:bcprov-jdk15on |
| GHSA-v435-xc8x-wvr9 Bouncy Castle affected by timing side-channel for RSA key exchange ("The Marvin Attack") | Medium | Also affects org.bouncycastle:bcprov-jdk15on |
| GHSA-8xfc-gm6g-vgpv Bouncy Castle certificate parsing issues cause high CPU usage during parameter evaluation. | High | Also affects org.bouncycastle:bcprov-jdk15on |
| GHSA-4h8f-2wvx-gg5w Bouncy Castle Java Cryptography API vulnerable to DNS poisoning | High | Also affects org.bouncycastle:bcprov-jdk15on |
| GHSA-wjxj-5m7g-mg7q Bouncy Castle Denial of Service (DoS) | Medium | Also affects org.bouncycastle:bcprov-jdk15on |
| GHSA-hr8g-6v94-x4m9 Bouncy Castle For Java LDAP injection vulnerability | Medium | Also affects org.bouncycastle:bcprov-jdk15on |
| GHSA-8353-fgcr-xfhx Improper Input Validation in Bouncy Castle | Medium | Also affects org.bouncycastle:bcprov-jdk15on |
| GHSA-wrwf-pmmj-w989 Observable Discrepancy in BouncyCastle | Medium | Also affects org.bouncycastle:bcprov-jdk15on |
MergeHarbor checks every repository's dependencies against this database, ranks what matters by exploitability and reachability, routes it to the owning team and opens the fix pull request.
Check your repos with MergeHarbor