-
-
Notifications
You must be signed in to change notification settings - Fork 318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JWT decryption does not support IVs longer than encryption key length for GCM #678
Comments
That is not what the method is doing. GCM by the JOSE spec requires 96bit iv. That's what is checked to be used. See the JWA RFC We've identitied and reported the issue of using non-conform iv lengths in python-jose already - mpdavis/python-jose#281 |
Understood. I did not consult the JWA spec, but if it requires 96 bits for the IV in AES-GCM modes, then it does seem that Simultaneously, I do not see how longer IVs would compromise the security of symmetric block ciphers in GCM mode. It seems that longer IVs could only increase their entropy, which would improve the security posture. Is it truly that critical for |
That is not universally the case https://crypto.stackexchange.com/questions/41601/aes-gcm-recommended-iv-size-why-12-bytes
If the specification allowed such. It does not. |
Sure, it makes sense for Jose encryption to be strict. But, it seems like decryption could relax on the spec for better compatibility with encryption sources that are not as strict as Jose. Encrypting is where the spec and security are critical. Decryption should work if technically possible. |
That's just not how interoperability is achieved, nor is it the spirit which the specifications are written with. |
Having read through the following resources for GCM and GHASH:
The argument that a longer IV bit string increases the likelihood of collision requires that GHASH results in collisions for distinct input values or that the hashed values are not "evenly" spaced compared to the 96 bit length IV (i.e. different IVs are spaced The AES key determines the subgroup of Since all inputs to GHASH are multiplied by For a given AES key, the IV for each message should support up to |
… block cipher mode to adhere to the RFC for JWA in `jose/backends/cryptography_backend.py` See https://www.rfc-editor.org/rfc/rfc7518.html#section-5.3 for the official RFC requirements for JWA See panva/jose#678 for related discussion on this issue
… block cipher mode to adhere to the RFC for JWA in `jose/backends/cryptography_backend.py` See https://www.rfc-editor.org/rfc/rfc7518.html#section-5.3 for the official RFC requirements for JWA See panva/jose#678 for related discussion on this issue
… block cipher mode to adhere to the RFC for JWA in `jose/backends/cryptography_backend.py` See https://www.rfc-editor.org/rfc/rfc7518.html#section-5.3 for the official RFC requirements for JWA See panva/jose#678 for related discussion on this issue
… block cipher mode to adhere to the RFC for JWA in `jose/backends/cryptography_backend.py` See https://www.rfc-editor.org/rfc/rfc7518.html#section-5.3 for the official RFC requirements for JWA See panva/jose#678 for related discussion on this issue
… block cipher mode to adhere to the RFC for JWA in `jose/backends/cryptography_backend.py` See https://www.rfc-editor.org/rfc/rfc7518.html#section-5.3 for the official RFC requirements for JWA See panva/jose#678 for related discussion on this issue
I have merged the following PR in |
I have merged the following PR in |
I see that I will be migrating my project to use https://jose.authlib.org/en/ instead. |
What happened?
The
decrypt
method undersrc/runtime/node/decrypt.js
invokescheckIvfLength
, which assumes the byte length of the IV must be the byte length of the encryption key. While this may be required for many block cipher modes, it is not required for GCM. This same issue was officially fixed by Node.js back in v6: nodejs/node#6376As such,
jose
should be updated to support IVs that are longer than encrypted key when operating with GCM block ciphers. This issue prevents encrypted JWTs produced bypython-jose
from being decrypted by thejose
NPM module.This is actively blocking the development of a Sublime Text plugin to interface with the LSP services for AWS Q Developer.
Version
5.3.0
Runtime
Node.js
Runtime Details
Node 18.18.1
Code to reproduce
I've confirmed that commenting out the
checkIvfLength
invocation in thedecrypt
method withinsrc/runtime/node/decrypt.js
successfully decrypts a JWT usingA256GCM
encryption and thedir
algorithm.My integration testing used the
decodeCredentialsRequestToken
method inaws/language-server-runtimes
, which successfully decrypts a JWT usingA256GCM
encryption and thedir
algorithm once thecheckIvfLength
invocation is commented out in thedecrypted
method.Required
The text was updated successfully, but these errors were encountered: