You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After creating/rotating a new JWK, when existing sessions call the end_session_endpoint with the id_token_hint Hydra is redirecting to the error page with the following error:
error: invalid_request
error_description: The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. go-jose/go-jose: error in cryptographic primitive
Reproducing the bug
Successfully login and retrieve an access_token and id_token from Hydra.
Create a new JWK by making a POST call to /admin/keys/hydra.openid.id-token
Logout from the application being redirected to the end_session_endpoint with id_token_hint populated.
Hydra redirects to the error page with error:
The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed. go-jose/go-jose: error in cryptographic primitive
WithHintf(`Could not ensure that signing keys for "%s" exists. If you are running against a persistent SQL database this is most likely because your "secrets.system" ("SECRETS_SYSTEM" environment variable) is not set or changed. When running with an SQL database backend you need to make sure that the secret is set and stays the same, unless when doing key rotation. This may also happen when you forget to run "hydra migrate sql..`, j.setID))
}
GetOrGenerateKeys(...) called by the GetPrivateKey func and calls FindPrivateKey(...):
This is where the issue lies, because the active id_token is no longer the first token anymore since the JWK was rotated. It seems the id_tokensKID should be pulled out along the way at some point and passed in so the proper key is found instead of the first one found.
The text was updated successfully, but these errors were encountered:
Preflight checklist
Ory Network Project
No response
Describe the bug
After creating/rotating a new JWK, when existing sessions call the
end_session_endpoint
with theid_token_hint
Hydra is redirecting to the error page with the following error:Reproducing the bug
access_token
andid_token
from Hydra.POST
call to/admin/keys/hydra.openid.id-token
end_session_endpoint
withid_token_hint
populated.Relevant log output
time=2024-02-15T23:03:15Z level=error msg=An error occurred audience=application error=map[debug: message:invalid_request reason:go-jose/go-jose: error in cryptographic primitive status:Bad Request status_code:400]
Relevant configuration
No response
Version
2.2.0-pre.1
On which operating system are you observing this issue?
None
In which environment are you deploying?
None
Additional Context
Digging into the code this is the trail I found:
h.r.ConsentStrategy().HandleOpenIDConnectLogout(...)
:hydra/oauth2/handler.go
Line 129 in 0421fda
s.issueLogoutVerifier(...)
because nologout_verifier
was passed:hydra/consent/strategy_default.go
Line 1091 in 0421fda
s.getIDTokenHintClaims(...)
with id token:hydra/consent/strategy_default.go
Line 878 in 0421fda
s.r.OpenIDJWTStrategy().Decode(ctx, idTokenHint)
usingjwk.NewDefaultJWTSigner()
:hydra/consent/strategy_default.go
Line 173 in 0421fda
NewDefaultJWTSigner
sets aGetPrivateKey
func to essentially:hydra/jwk/jwt_strategy.go
Lines 42 to 57 in 0421fda
GetOrGenerateKeys(...)
called by theGetPrivateKey
func and callsFindPrivateKey(...)
:hydra/jwk/helper.go
Lines 46 to 78 in 0421fda
FindPrivateKeys(...)
removes public keys and returns the First key in the set:hydra/jwk/helper.go
Lines 96 to 103 in 0421fda
This is where the issue lies, because the active
id_token
is no longer thefirst
token anymore since the JWK was rotated. It seems theid_tokens
KID
should be pulled out along the way at some point and passed in so the proper key is found instead of thefirst
one found.The text was updated successfully, but these errors were encountered: