Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

IAT payload value is not respected if value is zero

Open
#874 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
58/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
javascript, node.js
Domain
backend, security

Research direction

Start at sign.js around line 179, where the issue identifies the handling of the iat payload value. Reproduce the example with iat set to 0 and expiresIn set to 86400, then verify that the payload keeps iat at 0 and calculates exp as 86400. Add or update coverage for this zero-value case if the repository's existing tests identify a suitable location.

Written by the indexing model from the issue text.

Description

Description

If the iat payload value is is zero, in other words, the UNIX epoch, it is not respected and the current time is used instead. I believe it is because zero evaluates to false here:

https://github.com/auth0/node-jsonwebtoken/blob/master/sign.js#L179

Reproduction

jwt.sign({ iat: 0, data: 'foobar' }, 'secret', { expiresIn: 86400 });

Expected payload iat value should be zero and exp is expected to be 86400. The actual iat value is the current time and exp is the current time plus 86400.

Environment
  • Version: 9.0.0
  • Node v14.18.1 (npm v8.12.2)
Dominant language
JavaScript
Stars
18.2k
Forks
1.3k
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from auth0/node-jsonwebtoken

All issues in auth0/node-jsonwebtoken

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.