You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Introduce a Staged Keys Concept for JWKS Rotation (i.e. next Active key concept)
#38274
Issue
Currently, Keycloak lacks the concept of "staged keys" (i.e., a pre-announced key that will become active in the future). As a result, whenever a Resource Server encounters a JWT signed with an unknown key, it must fetch the latest JWKS from Keycloak to verify the token’s integrity. This approach opens a potential DOS vector: an attacker could send many requests each signed with a different, unknown key. Since every new key forces a JWKS fetch (which cannot be cached effectively), the Resource Server repeatedly queries the Identity Provider, leading to unnecessary load.
Proposed Enhancement
To mitigate this DOS risk, I propose a modified JWKS fetching strategy. The Identity Provider could periodically update its JWKS endpoint with a set of "staged" keys. These keys would not be active immediately but would be scheduled to become active later. When a Resource Server receives a JWT signed with an unknown key, it could assume that no key rotation has occurred yet and simply deny the request. Thus avoiding an immediate, potentially costly fetch of new JWKS.
Reference Example
A similar concept is implemented in OpenStack Keystone’s Fernet key rotation mechanism. More details can be found in their documentation: OpenStack Keystone - Identity Fernet Token FAQ.
Additional Considerations
If Keycloak rotates or invalidates keys outside the regular schedule (e.g., in response to a security compromise), a mechanism would still be required to notify all Resource Servers to re-sync their JWKS. However, this scenario falls outside the scope of this feature request.
The primary focus here is on incorporating a staged keys model within the key rotation mechanism to help mitigate DOS attacks targeting the Identity Provider.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Issue
Currently, Keycloak lacks the concept of "staged keys" (i.e., a pre-announced key that will become active in the future). As a result, whenever a Resource Server encounters a JWT signed with an unknown key, it must fetch the latest JWKS from Keycloak to verify the token’s integrity. This approach opens a potential DOS vector: an attacker could send many requests each signed with a different, unknown key. Since every new key forces a JWKS fetch (which cannot be cached effectively), the Resource Server repeatedly queries the Identity Provider, leading to unnecessary load.
Proposed Enhancement
To mitigate this DOS risk, I propose a modified JWKS fetching strategy. The Identity Provider could periodically update its JWKS endpoint with a set of "staged" keys. These keys would not be active immediately but would be scheduled to become active later. When a Resource Server receives a JWT signed with an unknown key, it could assume that no key rotation has occurred yet and simply deny the request. Thus avoiding an immediate, potentially costly fetch of new JWKS.
Reference Example
A similar concept is implemented in OpenStack Keystone’s Fernet key rotation mechanism. More details can be found in their documentation: OpenStack Keystone - Identity Fernet Token FAQ.
Additional Considerations
All reactions