Lab: JWT authentication bypass via algorithm confusion with no exposed key
Summary: This PortSwigger lab presents a JWT session mechanism that uses an RSA key pair to sign and verify tokens but is vulnerable to algorithm confusion attacks due to implementation flaws. The exercise has the user derive the server's public key from two valid JWTs, sign a modified token with the alg header set to HS256 and the sub claim changed to administrator, and use it to reach /admin and delete the user carlos.
Why it matters: The server's own public key, which is meant to be shared, becomes the signing secret once the algorithm is switched to HS256 - so a token forged with a key the server hands out is accepted as administrator.
Read the original at PortSwigger Research ↗
- Topics
- Vulnerabilities & Patching
- Related
- Attackers Exploit UnrealIRCd Flaw That Enables Server-Level Command Injection Cyber Risks · Nov 14, 2026U.S. CISA adds Check Point and UnrealIRCd flaws to its Known Exploited Vulnerabilities catalog Cyber Risks · Nov 14, 2026PostgreSQL Patches 52 Flaws, Including 22-Year-Old Bug Enabling Authenticated RCE Cyber Risks · Nov 13, 2026