Skip to content

Commit

Permalink
Avoid potentially critical vulnerability in ECDSA signature validation
Browse files Browse the repository at this point in the history
Quite possible we're missing something here, so please forgive if so. After seeing [this article](https://auth0.com/blog/2015/03/31/critical-vulnerabilities-in-json-web-token-libraries/) (see "RSA or HMAC?" section), we did a quick scan through the JJWT implementation to see if it was vulnerable. While it seems like the RSA check should work, no such check seemed to exist for ECDSA signatures.

As a result, it may be possible for users of this library to use `setSigningKey(byte[] key)` while intending to use ECDSA, but have the client alter the algorithm and signature to use HMAC with the public key as the "secret key", allowing the client to inject arbitrary payloads.

cc @thomaso-mirodin
  • Loading branch information
aarondav committed Mar 20, 2016
1 parent 0534120 commit 5385e0d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/main/java/io/jsonwebtoken/impl/DefaultJwtParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,9 @@ public Jwt parse(String jwt) throws ExpiredJwtException, MalformedJwtException,
Assert.isTrue(!algorithm.isRsa(),
"Key bytes cannot be specified for RSA signatures. Please specify a PublicKey or PrivateKey instance.");

Assert.isTrue(!algorithm.isEllipticCurve(),
"Key bytes cannot be specified for ECDSA signatures. Please specify a PublicKey instance.");

key = new SecretKeySpec(keyBytes, algorithm.getJcaName());
}
}
Expand Down

0 comments on commit 5385e0d

Please sign in to comment.