ServerChallenge validity window relies on setInterval — breaks across instances in freeze/thaw serverless (e.g. AWS Lambda) · Issue #1438 · panva/node-oidc-provider · GitHub
Skip to content

ServerChallenge validity window relies on setInterval — breaks across instances in freeze/thaw serverless (e.g. AWS Lambda) #1438

Closed

Description

@RalphBragg

What happened?

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

  1. added a commit that references this issue on Aug 25, 2026
    ba9d960
  2. locked and limited conversation to collaborators on Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions