-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Vulnerability / Unexpected Token Verification Behavior with Private Key #930
Comments
This behavior should be better documented. This library simply uses createPublicKey which detects the key type and automatically derives the public key from private keys. I would not consider this to be a security issue since the key derivation only occurs when the key material is known to represent a private key. |
Thank you for the guidance. @ArielPrevu3D |
Until now, I cannot understand the advantages of using private key signature and public key verification for the use of jwt |
@guda-art
For example In a web app if we use jwt for authentication.
So by using public/private key we can securely transmit any data over http |
Thank you very much. I think I understand because my project does not require client-side verification of server information, so I feel confused. This way, I understand |
@guda-art |
@AbdullahSoomroOfficial |
Issue Title: Unexpected Token Verification Behavior with Private Key
Description:
I've encountered unexpected behavior while using the jsonwebtoken library for token verification. As per best practices, I'm aware that token verification should use the public key, but I noticed that token verification is succeeding even when using the private key.
Steps to Reproduce:
Generate an RSA key pair using the crypto module.
Sign a JWT using the private key with the RS256 algorithm.
Attempt to verify the JWT using the private key instead of the public key.
Expected Behavior:
Token verification using the private key should fail, as the private key is meant for signing, not verification.
Actual Behavior:
Token verification using the private key surprisingly succeeds, which contradicts the expected behavior.
Environment:
Node.js version: v16.19.0
jsonwebtoken library version: 9.0.1/8.5.1 -> In these versions I have checked.
Operating System: Windows 10
Additional Information:
I've verified this behavior in multiple environments to ensure accuracy. It's important to clarify that this behavior goes against established best practices for token verification. I would appreciate assistance in understanding if this is an issue or if there's a valid explanation for this behavior.
The text was updated successfully, but these errors were encountered: