wso2 / product-is

Welcome to the WSO2 Identity Server source code! For info on working with the WSO2 Identity Server repository and contributing code, click the link below.
http://wso2.github.io/
Apache License 2.0
748 stars 729 forks source link

x5t value in JWT tokens is not correct as per the specifications hence JWT tokens cannot be validated by JWKS #19876

Closed tharakawijekoon closed 8 months ago

tharakawijekoon commented 8 months ago

Describe the issue: Following improvement[1], the JWKS endpoint now returns the x5c value. Since the x5c value is returned in the JWKS response, libraries processing the JWTs are capable of computing the x5t value for each of the keys returned in the JWKS response to identify the corresponding key by checking whether the value matches with the x5t in the JWT token.

The x5t value that is currently generated by the Identity server is not correct because of an additional hexify step[2] that is performed, this hexify step is not correct and was fixed for the x5t#s256 value in the JWKS response through issue[3]. However, it is not fixed for the x5t generation in the JWT token generation flows(JWT access token and id token).

Because the x5t value generated by the Identity server is incorrect and not as per the specification[4], when these libraries try to validate the JWT tokens they will not be able to find the corresponding key from the JWKS endpoint[5].

How to reproduce:

Expected behavior: It should be possible to validate the JWT token issued by the server with its JWKS response.

Environment information (Please complete the following information; remove any unnecessary fields) :


[1]https://github.com/wso2/product-is/issues/6686 [2]https://github.com/wso2-extensions/identity-inbound-auth-oauth/blob/3c36fc4bb338b8373099b80ab87fa0bdc07ea0f7/components/org.wso2.carbon.identity.oauth/src/main/java/org/wso2/carbon/identity/oauth2/util/OAuth2Util.java#L3279 [3]https://github.com/wso2/product-is/issues/18817 [4]https://datatracker.ietf.org/doc/html/rfc7515#section-4.1.7 [5]https://bitbucket.org/b_c/jose4j/src/a3a21a6c3169e2fea87153a4fad53896f953abf2/src/main/java/org/jose4j/jwk/SimpleJwkFilter.java#lines-108 [6]https://bitbucket.org/b_c/jose4j/wiki/Home

ImalshaG commented 8 months ago

Fixed by https://github.com/wso2-extensions/identity-inbound-auth-oauth/pull/2400