flashman
← All posts

JWT nbf and iat clock drift 401 debugging

Debug JWT nbf, iat, and clock drift 401s by comparing token times, verifier skew settings, server clocks, and safe fixtures before auth fixes ship safely.

2026-07-25 · 6 min read · Rahul Chitturi

  • jwt
  • auth
  • debugging

A JWT can look valid and still fail because the verifier thinks it is too early or too old. The nbf and iat claims depend on clocks across identity providers, API gateways, workers, and containers that may not agree during deploys or regional failovers.

These 401s are especially noisy when the failure lasts only a few seconds. Retrying may hide the bug, while logs show a token that appears normal by the time a person inspects it.

Align token time with verifier time

Decode a safe token fixture and convert every time claim into the same timezone. Then compare those values with the server clock and the verifier skew settings that were active when the request failed.

  • Check nbf, iat, exp, issuer time, and API receipt time together
  • Verify whether the library allows clock tolerance and what default it uses
  • Look for containers, edge nodes, or test runners without reliable time sync
  • Compare accepted and rejected tokens before changing issuer configuration

Keep skew tolerance intentional

A small clock tolerance can absorb normal distributed-system drift, but a large tolerance weakens freshness guarantees and can hide infrastructure problems. Treat skew as a named auth setting, not a magic retry workaround.

When rotating providers or moving verification to an API gateway, document which component owns clock tolerance. Multiple layers with different rules create confusing partial failures.

A Flashman workflow

Use the JWT decoder to inspect claims, the timestamp converter to translate nbf, iat, and exp, the JSON formatter for provider metadata, and the diff tool to compare verifier settings across environments.

The final fix should name the allowed skew, the clock source, the failing component, and the test fixture that proves near-boundary tokens behave predictably.

Try these tools