GHSA-jgvc-jfgh-rjvv: Jose4j Chosen Ciphertext Attack Vulnerability
MODERATEGHSA-jgvc-jfgh-rjvv is a MODERATE chosen ciphertext attack vulnerability (CWE-327: Use of a Broken or Risky Cryptographic Algorithm) affecting Jose4j libraries in the Maven ecosystem. The issue involves chosen ciphertext attack in jose4j. Remediation is available by upgrading affected packages to version 0.9.3.
GHSA-jgvc-jfgh-rjvv at a Glance
How to Fix GHSA-jgvc-jfgh-rjvv
To remediate this vulnerability, upgrade all affected Jose4j dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
<dependency>
<groupId>org.bitbucket.b_c</groupId>
<artifactId>jose4j</artifactId>
<version>0.9.3</version>
</dependency>
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
mvn dependency:tree -Dincludes=org.bitbucket.b_c
How to Check if You Are Affected
To determine whether your Java application is affected by GHSA-jgvc-jfgh-rjvv, inspect your build dependencies using the Maven Dependency Plugin:
mvn dependency:tree -Dincludes=org.bitbucket.b_c
Analyze the terminal output to locate any version of Jose4j in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.9.3), your application is affected.
Note: The mvn dependency:tree -Dincludes=org.bitbucket.b_c command inspects the resolved dependency graph declared in your project's POM files; it does not perform automated security scanning or inspect runtime dynamic classpaths. Always verify runtime container classpaths and shaded JARs.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-327: Use of a Broken or Risky Cryptographic Algorithm, where the product uses a broken or risky cryptographic algorithm or protocol. In Jose4j, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
GHSA-jgvc-jfgh-rjvv Affected Jose4j Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
org.bitbucket.b_c:jose4j
|
Maven |
< 0.9.3
|
0.9.3
|
References
Frequently Asked Questions
What is GHSA-jgvc-jfgh-rjvv?
Which Jose4j versions are affected?
What version fixes GHSA-jgvc-jfgh-rjvv?
Is jose4j affected?
What CWE is associated with GHSA-jgvc-jfgh-rjvv?
How can I check Maven dependencies for GHSA-jgvc-jfgh-rjvv?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-jgvc-jfgh-rjvv",
"modified" : "2023-04-27T23:52:54Z",
"published" : "2023-04-27T23:52:54Z",
"aliases" : [ ],
"summary" : "Chosen Ciphertext Attack in Jose4j",
"details" : "### Summary\nRSA1_5 in jose4j is susceptible to chosen ciphertext attacks. The\nattack allows to decrypt RSA1_5 or RSA_OAEP encrypted ciphertexts. It may\nbe feasible to sign with affected keys.\n\n### Severity\nModerate - exploiting this ciphertext attack could result in the ability to decrypt RSA1_5 or RSA_OAEP encrypted ciphertexts.\n\n### Proof of Concept\nA test case that can reproduce the padding oracle uses the following private key:\n\n```\n{\n \"kty\": \"RSA\",\n \"alg\": \"RSA1_5\",\n \"use\": \"enc\",\n \"n\": \"w2A4cbwOAK4ATnwXkGWereqv9dkEcgAGHc9g-cjo1HFeilYirvfD2Un2vQxW_6g2OKRPmmo46vMZFMYv_V57174j411y-NQlZGb7iFqMQADzo60VZ7vpvAX_NuxNGxYR-N2cBgvgqDiGAoO9ouNdhuHhxipTjGVfrPUpxmJtNPZpxsgxQWSpYCYMl304DD_5wWrnumNNIKOaVsAYmjFPV_wqxFCHbitPd1BG9SwXPk7wAHtXT6rYaUImS_OKaHkTO1OO0PNhd3-wJRNMCh_EGUwAghfWgFyAd20pQLZamamxgHvfL4-0hwuzndhHt0ye-gRVTtXDFEwABB--zwvlCw\",\n \"e\": \"AQAB\",\n \"kid\": \"rsa1_5\",\n \"d\": \"EjMvbuDeyQ9sdeM3arscqgTXuWYq9Netui8sUHh3v_qDnQ1jE7t-4gny0y-IFy67RlGAHNlSTgixSG8h309i5_kNbMuyvx08EntJaS1OLVQpXhDskoo9vscsPBiNIj3PFMjIFQQcPG9vhGJzUu4tMzhtiME-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xBPY8U449_iNgXd4\"\n },\n```\njose4j has distinguishable behvaior for the following test cases:\n\nThe first ciphertext below contains an invalid PKCS #1 padding. Because of hte invalid padding a random AES key is generated during decryption. This leads to an authentication error.\n\n```\n\"eyJhbGciOiJSU0ExXzUiLCJlbmMiOiJBMTI4R0NNIn0.ksmeZ6dBbP0UfDEaLXlqPl2XDaAA29kGlKtDb89x-4xN5-A6bx2umI_ToHK2GadzxUOgKROCACYb6rmKsqsQCOZaBsnq_4mDII1W0pja7Lz4zTnr7R3O4kALg4zXqG-gSlcDA7k1NgkpMDS15PjMmADqyqxbxQsXdfjstN324iqdvYGh6NsckkfTSWxDVAqiSR9fW8PsIbo3uSMokNaC-f64CDWIB9AsCxhF-3mnFbxXNxw7JE0upOgG4enQ8kZkwi_v54HBqAau1YNW7gPhFV8ElTQ71J6aHB3dja23lbWdaJmrK6PJE7gEeZmUbFkSYmuyzRUS-NGfXA23fYv5JQ.46AsIpPgnJCLH0Xm.u2rG.LyEHEGCWM8CXDEEHiaqhiQ\"\n```\n\nThe second ciphertext below ontains valid PKCS #1 padding, but the size of the encoded key is incorrect. Because of this, trying to dcrypt the symmetric part of the ciphertext immediately fails with org.jose4j.lang.JoseException: Invalid key for AES/GCM/NoPadding.\n\n```\n\"eyJhbGciOiJSU0ExXzUiLCJlbmMiOiJBMTI4R0NNIn0.oyVTmkyoChxFtyCtiKhv8OpBJcV6C6s_gMFSSRJBNStpdHPzq2YmroTfXGj1J1plFG4BBQwIZtdt6rIS6YkCvTLGqP1hds9CAO1a_bgRyoAVuOVvH2vmz5U2r74_SRbAzD35M7yZ_tSnnEdMFlHMFbf5uNwmgArrtPgh0V5OLn5i4XIc154FLTiQlvAEhUxiPuYBkm_1GBiYEH4JjP2RKXAUx_TxAVwPsOfIPAVrO0Ev_nvdtVLCE-uOn8WQbxh4wwOztaXOV1HIaPrl7HN-YtDOA840QUHm97ZZLAPRgLzGlkMI0ZS8QkYdb9_FT3KMbNu60nBKEniv2uhBdIhM9g.46AsIpPgnJCLH0Xm.u2rG.LyEHEGCWM8CXDEEHiaqhiQ\"\n```\n\nA correct implementation would not have distinguishable behavior. A test case for the missing algorithm checks uses the key:\n\n```\n{\n \"alg\": \"RSA-OAEP\",\n \"use\": \"enc\",\n \"n\": \"kqGboBfAWttWPCA-0cGRgsY6SaYoIARt0B_PkaEcIq9HPYNdu9n6UuWHuuTHrjF_ZoQW97r5HaAorNvrMEGTGdxCHZdEtkHvNVVmrtxTBLiQCbCozXhFoIrVcr3qUBrdGnNn_M3jJi7Wg7p_-x62nS5gNG875oyheRkutHsQXikFZwsN3q_TsPNOVlCiHy8mxzaFTUQGm-X8UYexFyAivlDSjgDJLAZSWfxd7k9Gxuwa3AUfQqQcVcegmgKGCaErQ3qQbh1x7WB6iopE3_-GZ8HMAVtR9AmrVscqYsnjhaCehfAI0iKKs8zXr8tISc0ORbaalrkk03H1ZrsEnDKEWQ\",\n \"e\": \"AQAB\",\n \"d\": \"YsfIRYN6rDqSz5KRf1E9q7HK1o6-_UK-j7S-asb0Y1FdVs1GuiRQhMPoOjmhY3Io93EI3_7vj8uzWzAUMsAaTxOY3sJnIbktYuqTcD0xGD8VmdGPBkx963db8B6M2UYfqZARf7dbzP9EuB1N1miMcTsqyGgfHGOk7CXQ1vkIv8Uww38KMtEdJ3iB8r-f3qcu-UJjE7Egw9CxKOMjArOXxZEr4VnoIXrImrcTxBfjdY8GbzXGATiPQLur5GT99ZDW78falsir-b5Ean6HNyOeuaJuceT-yjgCXn57Rd3oIHD94CrjNtjBusoLdjbr489L8K9ksCh1gynzLGkeeWgVGQ\",\n \"p\": \"0xalbl1PJbSBGD4XOjIYJLwMYyHMiM06SBauMGzBfCask5DN5jH68Kw1yPS4wkLpx4ltGLuy0X5mMaZzrSOkBGb27-NizBgB2-L279XotznWeh2jbF05Kqzkoz3VaX_7dRhCHEhOopMQh619hA1bwaJyW1k8aNlLPTl3BotkP4M\",\n \"q\": \"sdQsQVz3tI7hmisAgiIjppOssEnZaZO0ON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5GolnTki4IGvH5FDssDHz6MS2JG5QBcITzfuXU81vDC00xzNEuMat0AngmOw.UjPQbnakkZYUdoDa.vcbS.WQ_bOPiGKjPSq-qyGOIfjA\"\n```\nThe header of this ciphertext is:\n ``` {\"alg\":\"RSA1_5\",\"enc\":\"A128GCM\"}```\nHence the algorithm in the header does not match the algorithm in the key. Such ciphertexts should be rejected. The wrapped key is a valid RSA1_5 encrypted key. jose4j currently decrypts the ciphertext above without an exception. The problem with this behavior is that jose4j also allows chosen ciphertext attacks when the key uses RSA_OAEP. The attacker simply has to modify the header to and replace the algorithm with RSA1_5. Attempts to decrypt modified ciphertexts will then leak whether the decrypted message has valid PKCS #1 padding.\n\n\n### Further Analysis\nFix Commit - https://bitbucket.org/b_c/jose4j/commits/63b86581e7bfcc2d9d04ee15caea4b5bfb911f59\n\n\n\n### Timeline\n**Date reported**: 01/27/2023\n**Date fixed**: 02/09/2023\n**Date disclosed**: 04/27/2023\n",
"severity" : [ ],
"affected" : [ {
"package" : {
"ecosystem" : "Maven",
"name" : "org.bitbucket.b_c:jose4j"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "0.9.3"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/google/security-research/security/advisories/GHSA-jgvc-jfgh-rjvv"
}, {
"type" : "WEB",
"url" : "https://bitbucket.org/b_c/jose4j/commits/14e62a8dee9decb4ff6e0625aedc5724601bfdb6"
}, {
"type" : "WEB",
"url" : "https://bitbucket.org/b_c/jose4j/commits/63b86581e7bfcc2d9d04ee15caea4b5bfb911f59"
}, {
"type" : "WEB",
"url" : "https://bitbucket.org/b_c/jose4j/commits/tag/jose4j-0.9.3"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/google/security-research"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-327" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2023-04-27T23:52:54Z",
"nvd_published_at" : null
}
}