Subscribe to the Non-Human & AI Identity Journal

Should organisations use JWKS for JWT key rotation?

Yes, when tokens are verified across multiple services or environments. JWKS centralises public key distribution, uses kid to identify the right key, and makes rotation safer than manual PEM distribution. The key requirement is overlap, so old keys stay available until all issued tokens signed with them have expired.

Why This Matters for Security Teams

JWKS is not just a convenience layer for JWT rotation; it is often the difference between controlled key rollover and a brittle, manual trust update across distributed services. When multiple APIs, runtimes, or environments verify the same token family, centralised public key discovery reduces outage risk and shortens the window where old keys remain trusted. That matters most in NHI-heavy estates, where token issuance and verification are already moving faster than human review cycles.

Security teams often underestimate the operational cost of key drift. The issue is rarely the signing event itself; it is the lag between issuer rotation and verifier refresh, especially when teams still depend on exported PEM files or ad hoc deployment steps. The Guide to the Secret Sprawl Challenge shows how quickly unmanaged distribution paths create exposure, and the same pattern applies to signing keys. The OWASP Non-Human Identity Top 10 reinforces that lifecycle controls matter as much as the initial credential choice. In practice, many security teams discover key rotation failures only after a verifier rejects a still-valid token or, worse, continues trusting an expired key after the issuer has moved on.

How It Works in Practice

JWKS exposes a set of public signing keys over HTTPS so verifiers can select the correct one using the JWT kid header. For rotation, the issuer publishes the new key, keeps the previous key available for a defined overlap period, and then retires the old key only after all tokens signed with it have expired. This is safer than distributing PEM files manually because verifiers can refresh keys on demand without waiting for a coordinated deployment.

In practice, the control works best when the issuer and verifiers follow a few discipline points:

  • Use short-lived JWTs so the overlap window stays small and predictable.
  • Cache JWKS responses carefully, but honour refresh logic so verifiers do not pin stale keys.
  • Keep old keys published until every token they signed is guaranteed to expire.
  • Monitor for missing kid values, duplicate key IDs, and verification failures after rotation.
  • Protect the JWKS endpoint with strong availability and integrity controls, because verifier trust depends on it.

This operational model aligns with the NHI Lifecycle Management Guide, which treats rotation as a lifecycle event rather than a one-time admin task. It also fits the broader guidance in the OWASP Non-Human Identity Top 10, where stale credentials and weak rotation discipline are recurring failure modes. Current guidance suggests JWKS is most effective when key publication, cache TTLs, and token lifetime are designed together, not separately. These controls tend to break down in tightly coupled legacy estates where services cannot refresh keys dynamically and every verifier expects a locally installed certificate bundle.

Common Variations and Edge Cases

Tighter key distribution often increases operational coupling, requiring organisations to balance rotation safety against availability and cache consistency. That tradeoff becomes visible when different services have different token validation behaviour, different cache TTLs, or different tolerance for network failures.

There is no universal standard for JWKS refresh timing, so best practice is evolving. Some environments poll JWKS regularly, while others refresh only on an unknown kid value. Both can work, but each creates a different failure mode: aggressive polling increases dependency on the JWKS endpoint, while lazy refresh can delay trust in newly rotated keys. Organisations should also watch for edge cases such as:

  • multiple issuers sharing similar key identifiers;
  • offline or air-gapped verifiers that cannot reach the JWKS endpoint;
  • long-lived tokens that outlast a safe overlap window;
  • rotation events during incident response, when rapid revocation is more important than graceful rollover.

The Guide to NHI Rotation Challenges is useful here because it highlights the same practical problem: rotation is easy to describe and hard to execute consistently at scale. The key point is that JWKS improves rotation safety only when token TTLs, cache behaviour, and rollback procedures are aligned. Otherwise, organisations trade manual key copying for a more distributed but still fragile trust model.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP Non-Human Identity Top 10 address the attack and risk surface, while NIST CSF 2.0 and NIST AI RMF set the governance and control requirements practitioners need to meet.

Framework Control / Reference Relevance
OWASP Non-Human Identity Top 10 NHI-03 Rotation and stale-key handling are core NHI lifecycle risks.
NIST CSF 2.0 PR.AC-1 JWKS supports controlled authentication and key verification across services.
NIST AI RMF Runtime trust and lifecycle governance map to AI system risk management.

Define ownership, monitoring, and rollback for key rotation as part of AI trust operations.