Cyber Risks · PortSwigger Research

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