← Java / Spring · Contents

JAVA-046 / Advanced

Allowing JWT algorithm none or skipping signature verification

A07:2021 Identification and Authentication Failures · CWE-347 Improper Verification of Signature

Why is this a problem?

Accepting unsigned tokens allows anyone to forge privileges.

How to fix it

java
Claims c = Jwts.parser().verifyWith(publicKey).requireIssuer(ISS).build()
    .parseSignedClaims(token).getPayload();   // Fix the algorithm to the key type

Further reading