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
ServerChallenge validity window relies on setInterval — breaks across instances in freeze/thaw serverless (e.g. AWS Lambda) #1438
ServerChallenge (lib/helpers/challenge.js), which backs DPoPNonces, AttestChallenges and CNonceChallenges, precomputes its ±2-step validity window in the constructor and advances it with setInterval(...).unref().
In freeze/thaw serverless runtimes (AWS Lambda and similar) the execution context is frozen between invocations, so that timer never fires — each instance's window stays pinned to its cold-start time even though Date.now() keeps moving. Two instances therefore disagree on the current window, and a challenge issued by one is rejected by another.
Observed with OpenID4VCI: a c_nonce fetched from the nonce endpoint on one Lambda is rejected invalid_nonce at the credential endpoint on another Lambda, immediately after issuance. Same applies to DPoP nonces and attestation challenges. Any multi-instance serverless deployment is affected.
Root cause
nextChallenge()/checkChallenge() read the setInterval-rotated instance fields instead of deriving the step from the clock at call time. The scheme is otherwise already stateless (HKDF(secret, step, info)), so the stored window and the timer are the only reason it fails under freeze/thaw.
Suggested fix (behaviour-preserving)
Derive the step from Date.now() on each call; drop the precomputed fields + the timer. compute, compare, sixfourbeify, STEP, CHALLENGE_OK_WINDOW unchanged.
Activity
fix: derive server challenges from the clock rather than a timer