JSON Web Tokens (JWT) are a common standard for representing claims to be transferred between two parties. However, improper implementation of JWT validation can lead to critical security vulnerabilities, one of the most devastating being "Algorithm Confusion".
Algorithm confusion occurs when a server-side application accepts a JWT and uses a public key (intended for asymmetric algorithms like RS256) as a secret key for a symmetric algorithm (like HS256). An attacker can then sign a JWT using the public key and the HS256 algorithm, which the server will then validate using the same public key, erroneously treating it as a shared secret.
In our recent engagements, we've seen this vulnerability lead to full account takeover, allowing attackers to bypass authentication entirely and gain administrative access to sensitive platforms.
To prevent algorithm confusion, developers should: