8000 Reject reused and stale ABCA Client Attestation PoP JWTs by edewit · Pull Request #54367 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

Reject reused and stale ABCA Client Attestation PoP JWTs - #54367

Open
edewit wants to merge 2 commits into
keycloak:mainfrom
edewit:fix-51111-abca-pop-replay
Open

edewit wants to merge 2 commits into
keycloak:mainfrom
edewit:fix-51111-abca-pop-replay

Conversation

@edewit
@edewit edewit commented Oct 27, 2026 •
Copy link
Copy Markdown
Contributor

Closes #51111

Summary

  • Reject Client Attestation PoP JWTs whose jti was already used, via SingleUseObjectProvider (same pattern as DPoP)
  • Reject PoP JWTs whose iat falls outside a short freshness window (10s lifetime + 15s clock skew)
  • Update HAIP ABCA tests to mint a fresh PoP for each client-authenticated request

Server-provided challenge binding remains out of scope until Keycloak can issue attestation challenges.

10000
@edewit
edewit requested a review from a team as a code owner October 27, 2026 11:07
Copilot AI balanced review requested due to automatic review settings October 27, 2026 11:07
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 SingleUseObjectProvider and 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

@edewit
edewit force-pushed the fix-51111-abca-pop-replay branch from abab4f9 to 89b7ab3 Compare October 27, 2026 11:12
Copilot AI balanced review requested due to automatic review settings October 27, 2026 14:37
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Security-sensitive replay protection warrants human validation of cache expiry and clustered behavior across supported storage providers.

No open issues 🎉

2 resolved since last review

Review effort: Balanced

@edewit
edewit force-pushed the fix-51111-abca-pop-replay branch 2 times, most recently from 26fd7d7 to cff0d20 Compare October 28, 2026 08:25
* 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;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

10BC8

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot AI balanced review requested due to automatic review settings November 9, 2026 12:18
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The replay test retries only immediately, leaving replay rejection after the nominal 10-second lifetime and through the inclusive allowed-skew boundary unverified.

1 open issue

Review effort: Balanced

Comment on lines +550 to +551
int lifespan = Math.max(1, (int) (attestationPoPJwt.getIat() + DEFAULT_POP_LIFETIME_SECONDS
+ DEFAULT_POP_CLOCK_SKEW_SECONDS - Time.currentTime()) + 1);
@edewit
edewit requested a review from mposolda November 9, 2026 12:21
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>
@edewit
edewit force-pushed the fix-51111-abca-pop-replay branch from 01f8da5 to 92715fc Compare December 4, 2026 14:31
Copilot AI balanced review requested due to automatic review settings December 4, 2026 14:31
Copilot AI left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ABCA] Attestation-based client-auth PoP JWTs are replayable across token requests

3 participants

0