JWT: expired and future tokens are accepted for 300 seconds with no leeway option

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

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
1-2 days
Newbie friendliness
58/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
c

Research direction

Start with the JWT verification logic in src/security/jwt/jwt.c at lines 719–745, then trace how verification options are passed through the middleware. Add configurable leeway and boundary tests for -1, 0, 300, and 301 seconds; document the acceptance behavior and verify expired and future tokens follow the configured setting.

Written by the indexing model from the issue text.

Description

bug

Confirmed on dev at fd8cf045770459ebc0f6b6740f54dcd30a80ce6c.

JWT verification accepts expired exp tokens for an additional hard-coded 300 seconds and future nbf tokens up to 300 seconds early. There is no option to disable or reduce this leeway.

Source: https://github.com/c4punks/CWIST/blob/fd8cf045770459ebc0f6b6740f54dcd30a80ce6c/src/security/jwt/jwt.c#L719-L745

Reproduction with a correctly signed token whose exp is ten seconds in the past:

expired_seconds=10 verified=1

The middleware presents this as a valid token even though its expiry has passed. A five-minute acceptance window can be too long for short-lived credentials and is not documented as a mandatory security policy.

Make leeway configurable, default to zero unless compatibility requires otherwise, and document the exact acceptance behavior. Add boundary tests at -1, 0, 300, and 301 seconds.

Dominant language
C
Stars
16
Forks
7
Avg merge
4h 54m
Merged PRs (30d)
185

Getting set up

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 c4punks/CWIST

All issues in c4punks/CWIST

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.