Conversation
…; default id_token_signed_response_alg
OpenAMClientRegistration.verifyJwtIdentity chose HMAC vs. asymmetric
verification from the client's id_token_signed_response_alg - the algorithm
of the ID tokens *we* issue - so a private_key_jwt client whose ID-token
algorithm was HS256 had its RS256 assertion pushed through the shared-secret
verifier ("Unsupported Signing Algorithm, SHA256withRSA"). Dispatch on the
JWS header of the presented JWT instead: HMAC uses the client secret only,
anything else the client's registered public keys only, and "none" is
refused. OpenAM-issued ID tokens (idtokeninfo, the OIDC SSO provider) are
unaffected since their header matches the configured algorithm.
getIDTokenSignedResponseAlgorithm() returned null when the attribute was
never persisted (AgentsRepo reads without schema defaults, e.g. a client
created via the realm-config REST endpoint or ssoadm), which NPE'd at the
token endpoint for any openid request. Fall back to HS256, the default the
schema, the console and dynamic registration already use.
Fixes OpenIdentityPlatform#1130
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1130 — both correctness bugs reported there, in
OpenAMClientRegistration.Bug 2 — client assertions were dispatched on
id_token_signed_response_algverifyJwtIdentity()chose HMAC vs. asymmetric verification from the client'sid_token_signed_response_alg— the algorithm of the ID tokens we issue — so aprivate_key_jwtclient whose ID-token algorithm wasHS256had its RS256 assertion pushed through the shared-secret verifier (JwsSigningException: Unsupported Signing Algorithm, SHA256withRSA).The method has four callers: two verify client-signed assertions (
ClientCredentialsReader,JwtBearerGrantTypeHandler), two verify OpenAM-issued ID tokens (IdTokenInfo,OpenIdConnectSSOProvider). Dispatching ontoken_endpoint_auth_methodas the issue suggests would break the latter two and legacy clients that never set the method. Instead the dispatch now follows the JWS header of the presented JWT: HMAC → client secret only; anything else → the client's registered public keys only (jwks/jwks_uri/x509);none→ refused. No alg-confusion is possible because neither branch can reach the other's key material. OpenAM-issued ID tokens are unaffected: their header matches the configured algorithm. A client without a secret (public client) now getsfalsefor an HMAC assertion instead of an NPE in the resolver.Bug 1 — NPE when
id_token_signed_response_algwas never persistedAgentsRepo.getAgentAttrs()reads agent attributes withgetAttributesWithoutDefaults(), so the schema default (HS256inAgentService.xml) is not applied; a client created via the realm-config REST endpoint or ssoadm without that attribute madegetIDTokenSignedResponseAlgorithm()returnnull, which NPE'd inStatefulTokenStore.createOpenIDToken(toUpperCase()),IdTokenInfoand the oldverifyJwtIdentity(JwsAlgorithm.valueOf(null)). It now falls back toHS256— the default the schema, the console and dynamic registration (ID_TOKEN_SIGNED_RESPONSE_ALG_DEFAULT) already use, rather than the spec'sRS256, to stay consistent with clients created through the console.Tests
OpenAMClientRegistrationTest+4: default (empty set / null / explicit value); HS256 assertion verified with the secret underidTokenSignedResponseAlg=RS256and rejected with a wrong secret; RS256 assertion verified against the client's JWKS underHS256and rejected with a foreign key;alg=nonerefused. Fullopenam-oauth2suite passes (877 test methods).