[OID4VCI] Fix JWT proof validation gaps and attestation verification#47995
[OID4VCI] Fix JWT proof validation gaps and attestation verification#47995mposolda merged 2 commits intokeycloak:mainfrom
Conversation
f186ddf to
dda8d51
Compare
mposolda
left a comment
There was a problem hiding this comment.
@forkimenjeckayang Thanks for the PR! Nice stuff! Sorry for late review.
@tdiesler Thanks as well for the review!
I've did also some review and testing of the PR. Found some very small things. I've sent you the PR to your branch adorsys#272 . If you merge (or apply those changes), this PR is good to me.
But I think there might be some follow-up work, which should not block this PR IMO, but will be good to address in the future 1 bigger thing and 2 smaller things (will create GH issues once this PR is merged):
-
The realm attributes
Trusted Key IDsandTrusted Keys (JSON)are not so ideal for figure the attestation keys. As attestation is rather something, which might be different between various wallets. For example walletlissi, which might be represented by clientlissi-clientwill likely use completely different attestation keys than walletheidi(represented byheidi-client) . The keys might be rather figured either per client (similarly like for example client keys used forprivate_key_jwtclient authentication) or from identity provider (similarly like for exampleCLIENT_AUTH_FEDERATEDfeature is doing) -
Hardcoded constant
JWK_PRIVATE_KEY_CLAIMSis not very reliable. May not work in case some custom key providers are deployed or when we support more keys in the future (which can happen in the near future probably as Keycloak will need to add something due the post-quantum cryptography) -
Test
OID4VCJWTIssuerEndpointTestis some combination of E2E test and "unit" test. It uses endpoints, but at the same time, still usesKeycloakSessionto figure some things from the server directly. Also it seems some functionality inside this test is already tested in the context of other tests though...
closes keycloak#47513 Signed-off-by: forkimenjeckayang <[email protected]>
…lgorithms Signed-off-by: mposolda <[email protected]>
95d3453 to
477bdbe
Compare
Unreported flaky test detectedIf the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR. org.keycloak.testsuite.authz.PolicyEvaluationTest# |
mposolda
left a comment
There was a problem hiding this comment.
@forkimenjeckayang Thanks!
Fixes validation gaps in OID4VCI JWT proof handling by ensuring proper key resolution (
jwk,kid,x5c), enforcing JOSE header constraints, and rejecting unsupportedtrust_chain.Adds full verification of
key_attestation, including signature, claims, and proof-key membership inattested_keys.Strengthens JWT payload validation (issuer handling, single audience,
iatfreshness, optionalexp/nbf, and nonce checks), with nonce failures mapped toinvalid_nonce.Also introduces trusted attestation key loading from the realm and expands test coverage for key resolution, attestation validation, and error scenarios.
closes #47513