Skip to content

fix: reject JWTs with out-of-bounds exp/nbf/iat timestamps - #6

Open
wasim-builds wants to merge 1 commit into
heathivorjocelyn6:mainfrom
wasim-builds:fix/invalid-epoch-overflow
Open

fix: reject JWTs with out-of-bounds exp/nbf/iat timestamps#6
wasim-builds wants to merge 1 commit into
heathivorjocelyn6:mainfrom
wasim-builds:fix/invalid-epoch-overflow

Conversation

@wasim-builds

Copy link
Copy Markdown

Fixes #1

This PR adds safe temporal bounds checking to JWT time claims (exp, nbf, iat) to prevent integer overflow and precision loss.

Changes:

  • Validates time claims against safe Unix timestamp range (year 1 to year 9999)
  • Rejects values that cause integer overflow (max/min int64) or floating-point truncation (1e21+)
  • Returns specific error types: ErrInvalidEpoch, ErrExpiredToken, ErrTokenNotYetValid
  • Handles edge cases: NaN, Inf, precision loss, min/max boundaries

Tests (all passing):

  • Valid tokens, expired tokens, not-yet-valid tokens
  • Max int64 overflow, min int64 overflow, 1e21 floating point
  • Zero timestamp, year 9999 max, just beyond max
  • Nil/empty claims, valid/overflowed iat

Acceptance Criteria Met:

  • Validates exp/nbf/iat for safe Go time.Time conversion
  • Rejects timestamps beyond year 9999 or causing overflow
  • Returns specific actionable errors (ErrInvalidEpoch)
  • Handles large floats (1e21), max int64, negative values

Fixes heathivorjocelyn6#1

Adds validation to reject time claims that overflow or fall outside
safe temporal boundaries (year 1 to year 9999). Includes bounds checking
for exp, nbf, and iat with specific error types.

Co-Authored-By: Claude <noreply@anthropic.com>
@wasim-builds

Copy link
Copy Markdown
Author

/claim #1

@opirebot

opirebot Bot commented Jul 28, 2026

Copy link
Copy Markdown

😅 Unfortunately there are no rewards left to claim in this issue!

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.

🎯 Reject JWTs with Out-of-Bounds Expiration (exp) Values to Prevent time.Time Overflow

1 participant