Skip to content

Clock skew between Keycloak cluster nodes within a cluster #54961

Open
2 of 7 issues completed
Open

Description

@ruchikajha95

Description

Keycloak relies on node-local wall clocks in multiple sensitive paths, including token and assertion validation, cache entry lifetimes, single-use/revoked-token retention, sessions, scheduled cleanup, and cluster or cross-site
event handling. The expected clock-synchronization guarantees and the safety margins that code should apply are not defined in one place. Individual implementations therefore use local constants and different approaches to
clock skew.

The system should warn when the clock-skew is off.

Add a shared cluster clock-skew facility that:

  1. Defines the supported clock-skew assumptions and warning thresholds centrally.
  2. Estimates clock differences between active Keycloak nodes and reports excessive skew.
  3. Exposes reusable functionality for code that calculates absolute expiry times or relative cache lifetimes.
  4. Documents the clock-synchronization requirements for clustered and multi-site deployments

Value Proposition

Clock skew can create subtle correctness and security failures that are difficult for operators to diagnose. For example, a marker created on a fast node can expire while a slow node still considers the corresponding token or
SAML assertion valid. Excessive skew has also affected cross-cluster invalidation targeting in #52649.

Detection and observability would let operators correct NTP or infrastructure problems before they cause intermittent login failures, replay windows, premature expiry, missed invalidations, or delayed cleanup. Shared constants
and expiry helpers would also prevent each subsystem from independently implementing incomplete or inconsistent safety margins.

Non-Goals

  • Multi-Cluster v1 setups
  • Detecting time differences across multiple cluster in multi-cluster v2 setups
  • Adjusting an operating system clock or replacing NTP/chrony.
  • Compensating for any clock drift.
  • Treating approximate application-level measurements as a trusted time source.
  • Making authentication or cluster availability depend on a single transient measurement by default.
  • Making the clock skew part of the health probe
  • Automatically changing protocol-level clock-skew settings such as an identity provider's allowed clock skew.
  • Solving database-server clock differences unless the selected design explicitly uses database time as a reference

Sub-issues

Sub-issues

2 of 7 Issues completed
Loading 7 sub-issues

Metadata

Metadata

Assignees

Labels

area/corekind/enhancementpriority/normalrelease/27.0.0team/core-sharedteam/production-readiness

Fields

Value

None yet

Effort

None yet

Votes

None yet

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions