Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

verifyJWT assumes non-standard expiration claim format (ms instead of seconds) #88

Open
entropi opened this issue May 10, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@entropi
Copy link

entropi commented May 10, 2024

Describe the bug

The jwt logic assumes exp is in ms timestamp format (time.getUnixTime is just Date.now), but the JWT RFC (https://www.rfc-editor.org/rfc/rfc7519#section-4.1.4) states it should be seconds since epoch, not ms. This means that if something is using lib0 to validate a JWT token, but that JWT token was generated to the RFC, the expiration check will fail.

To Reproduce
Steps to reproduce the behavior:

  1. Generate a standards compliant JWT token (e.g., with a JWT library in another platform)
  2. Verify the token with lib0
  3. See false expiration error

Expected behavior
Expect epoch seconds for exp claims.

Possibly add logic to support both since the bug was out there.

Relevant code:

if (payload.exp != null && time.getUnixTime() > payload.exp) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants