Repository navigation
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Replay-cache expiry leaves an accepted boundary window, and cache keys lack realm isolation.
2 open issues
What changed in this PR
This PR strengthens attestation-based client authentication by rejecting reused and stale proof-of-possession JWTs, addressing #51111. Server-provided challenge binding remains out of scope.
Changes:
- Adds replay detection through
SingleUseObjectProviderand a bounded freshness check. - Adds regression tests for replay rejection, fresh proofs, and stale timestamps.
- Updates HAIP tests to generate a fresh proof for each authenticated request.
| File | Description |
|---|---|
tests/base/src/test/java/org/keycloak/tests/oid4vc/OID4VCBasicWallet.java |
Supports explicit proof issuance timestamps for testing. |
tests/base/src/test/java/org/keycloak/tests/oid4vc/abca/OIDCAttestationBasedClientAuthenticationTest.java |
Tests replay rejection and proof freshness. |
tests/base/src/test/java/org/keycloak/tests/oid4vc/abca/HAIPIssuerConformanceTest.java |
Generates fresh proofs for token and refresh requests. |
services/src/main/java/org/keycloak/authentication/authenticators/client/AttestationBasedClientAuthenticator.java |
Enforces proof freshness and records used proof identifiers. |
Review effort: Balanced
abab4f9 to
89b7ab3
Compare
26fd7d7 to
cff0d20
Compare
| * Allowed clock skew when validating PoP {@code iat}, | ||
| * aligned with {@link org.keycloak.services.util.DPoPUtil#DEFAULT_ALLOWED_CLOCK_SKEW}. | ||
| */ | ||
| public static final int DEFAULT_POP_CLOCK_SKEW_SECONDS = 15; |
There was a problem hiding this comment.
It's not really a default because it cant currently be changed. From my experience, there are a lot of devices with messed up time settings out there. Especially mobile phones managed by corporations (and ABCA will be primarily used by Wallets on mobile phones initially).
Could this be made configurable? Or at least provide some way to override the default via parameters/config?
There was a problem hiding this comment.
Do you have concrete ABCA case where 15s isn’t enough? These values intentionally match DPoPUtil.DEFAULT_PROOF_LIFETIME / DEFAULT_ALLOWED_CLOCK_SKEW, which also aren’t admin-configurable.
| int lifespan = Math.max(1, (int) (attestationPoPJwt.getIat() + DEFAULT_POP_LIFETIME_SECONDS | ||
| + DEFAULT_POP_CLOCK_SKEW_SECONDS - Time.currentTime()) + 1); |
Enforce single-use PoP jti via SingleUseObjectProvider and a bounded iat freshness window so captured ABCA headers cannot be replayed. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
Namespace single-use keys by realm, extend TTL past the inclusive freshness boundary, and place the Hex import in Spotless order. Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
01f8da5 to
92715fc
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Replay tests lack expiry-aware coverage proving rejection throughout the clock-skew window and at the inclusive freshness boundary, and the current-base HAIP issuer conformance result is missing.
2 open issues
Review effort: Balanced
| AccessTokenResponse tokenResponse = wallet.accessTokenRequest(ctx, authCode) | ||
| .header(OAUTH_CLIENT_ATTESTATION_HEADER, attestationJwt) | ||
| .header(OAUTH_CLIENT_ATTESTATION_POP_HEADER, attestationPoPJwt) | ||
| .header(OAUTH_CLIENT_ATTESTATION_POP_HEADER, wallet.buildClientAttestationPoPJWT(ctx, rsaKey)) |


Closes #51111
Summary
jtiwas already used, viaSingleUseObjectProvider(same pattern as DPoP)iatfalls outside a short freshness window (10s lifetime + 15s clock skew)Server-provided challenge binding remains out of scope until Keycloak can issue attestation challenges.