Algorithm confusion is a JWT validation flaw in which a verifier accepts an unintended signing algorithm or lets untrusted token-header data determine how verification works. For example, a poorly designed verifier may confuse asymmetric signing, which uses a private key to sign and a public key to verify, with HMAC signing, which uses a shared secret. This can undermine authentication and allow forged tokens if the verifier’s key handling is also flawed.
Defenders should configure an explicit allowlist of permitted algorithms and keys, choose the verification method from trusted server-side settings rather than the token header, and reject tokens that do not match the expected issuer, audience, and other claims. In real attacks, algorithm confusion is a potential route to impersonation or privilege misuse; in secure implementations, strict verification prevents a token from choosing its own trust rules.


