How a JWT Algorithm Confusion Vulnerability Allowed a $4,500 Authentication Bypass
Introduction
JSON Web Tokens (JWTs) are the standard mechanism for stateless authentication in modern microservices. When implemented properly using asymmetric cryptography — such as RS256 (RSA Signature with SHA-256) — an Identity Provider signs tokens using a private key, while downstream microservices verify those tokens using a publicly distributed public key.
However, when backend validation libraries fail to enforce the expected cryptographic algorithm explicitly, attackers can exploit Algorithm Confusion (often referred to as the RS256-to-HS256 downgrade attack). By tricking the server into verifying an HMAC signature using its own public RSA key as the secret, an attacker can forge arbitrary authentication tokens.
In this write-up, we explore how an unpinned JWT verification check in an API gateway allowed complete privilege escalation from a low-privilege guest account to a platform administrator.
Target Architecture and Root Cause
The target application utilized a distributed microservices setup protected by a central authentication gateway:
- Identity Service: Issued RS256-signed JWTs upon user login and exposed the corresponding public key…


