Skip to content

fix(verify): add upper bound of 300 seconds for clockTolerance option#1039

Open
Pranav18M wants to merge 2 commits into
auth0:masterfrom
Pranav18M:master
Open

fix(verify): add upper bound of 300 seconds for clockTolerance option#1039
Pranav18M wants to merge 2 commits into
auth0:masterfrom
Pranav18M:master

Conversation

@Pranav18M

Copy link
Copy Markdown

Fixes #1021

Adds an upper bound of 300 seconds to the clockTolerance option in
verify().

The existing PR #1036 correctly rejects invalid values (NaN, Infinity,
negative) but does not cap the maximum value. A large-but-finite
clockTolerance like Number.MAX_SAFE_INTEGER still effectively bypasses
expiry verification since exp + 9007199254740991 produces a value far
larger than any realistic clockTimestamp, causing expired tokens to be
silently accepted.

Any clockTolerance above 300 seconds is almost certainly a
misconfiguration and poses a security risk.

Description

Adds an upper bound validation for the clockTolerance option in
verify(). When clockTolerance exceeds 300 seconds, a
JsonWebTokenError is thrown immediately, preventing accidental or
malicious expiry bypass via large tolerance values.

References

Testing

The fix can be tested by calling jwt.verify() with clockTolerance
set to a value greater than 300 (e.g. 301 or Number.MAX_SAFE_INTEGER)
and confirming a JsonWebTokenError is thrown with the message
"clockTolerance must not exceed 300 seconds to prevent accidental
expiry bypass".

Environment: Node.js v20, jsonwebtoken v9.0.3

  • This change adds test coverage for new/changed/fixed functionality
  • All active GitHub checks for tests, formatting, and security are passing

@Pranav18M Pranav18M requested a review from a team as a code owner June 29, 2026 05:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: clockTolerance accepts arbitrarily large values, bypassing exp verification entirely

1 participant