jsonwebtoken's insecure implementation of key retrieval function could lead to Forgeable Public/Private Tokens from RSA to HMAC
The jsonwebtoken library (versions ≤ 8.5.1) can incorrectly verify JSON Web Tokens if the key retrieval function is poorly implemented, allowing attackers to forge valid tokens by switching from asymmetric (RSA) to symmetric (HMAC) algorithms. This happens because the library may accept tokens signed with one algorithm but verified with a different one.
The vulnerability exists in the key retrieval mechanism of jsonwebtoken ≤ 8.5.1, where misconfiguration allows algorithm confusion attacks. An attacker can forge tokens by exploiting weak key retrieval functions that fail to enforce algorithm consistency between signing and verification, enabling RSA-signed tokens to be validated using HMAC with a symmetric key. Pre-condition: application must use both symmetric and asymmetric keys in the same jwt.verify() function.
Want to know if your infrastructure is exposed to this?
Talk to TrueHacking →