Closed rc-mattschwager closed 8 months ago
if application uses the same key pair.
if application uses the same key pair.
You mean the same key pair for signing and encryption? Yes, that's true if the application is offering both signing and encryption. I think another consideration here is if the application is only intending to offer signing functionality, and it uses asymmetric algorithms (e.g. RSA) for signing, and the public key is in fact made public, then the sign/encrypt confusion can be exploited. In other words, the application intending to only offer signing functionality can be convinced to successfully authenticate a user using the implicit encryption decoding.
Here are the preconditions listed from the Black Hat presentation:
/jwks.json
b. If alg
is RS*, can compute it from two tokens (https://github.com/SecuraBV/jws2pubkey)The list of preconditions is relatively large, however, successful exploitation means authentication bypass.
There is no encryptor authentication in that context, thus no authentication bypass happens.
https://github.com/P3ngu1nW/CVE_Request/blob/main/novjson-jwt.md seems related? If so this got a CVE assigned: CVE-2023-51774
probably same. but JWE decryption result (JWE object w/ String payload) cannot be confused with JWS verification result (JWS object w/ indifferent-access Hash payload).
Hi there,
This attack was recently described in a Black Hat 2023 presentation: Three New Attacks Against JSON Web Tokens.
In short, if an attacker can acquire the public key used for JWS signing, they can use that to forge JWE tokens that decode successfully. Public keys are often made available at an OIDC URL, so they are commonly available. This is due to the
JWT.decode
interface working for both JWS and JWE. The following code demonstrates the issue:As you can see, an attacker can use the public key to successfully forge tokens.
This behavior was also observed in the following Python libraries:
authlib
: https://github.com/lepture/authlib/commit/3a382780907226d99c09606aac78e29fe5bd3bf6, CVE-2022-39174jwcrypto
: https://github.com/latchset/jwcrypto/commit/f4e912f83cb578e2cd47f8a9398bf15f680bf558, CVE-2022-3102