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

Skip verification of JWT's iat claim #394

Merged
merged 1 commit into from
Aug 29, 2024
Merged

Conversation

jameshadfield
Copy link
Member

@jameshadfield jameshadfield commented Aug 29, 2024

Closes #307

I haven't yet tested that this works (e.g. by changing my system clock) which I'll try to get to soon, unless others have nicer ways of testing this?

  • Checks pass
  • Create a scenario where a JWT's iat is in front of my system clock and verify this PR fixes the issue

Copy link
Member

@tsibley tsibley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I verified this works for me to avoid the issue when I intentionally introduce a lagging clock on my local machine.

$ nextstrain logout
$ sudo timedatectl set-ntp false                # disable time sync
$ sudo timedatectl set-time "10 seconds ago"    # lag the clock
$ sudo ntpdate ntp.ubuntu.com                   # verify that manual lag worked; offset was -10s
$ sudo timedatectl set-time "10 seconds ago"    # lag again
$ nextstrain login                              # 8.4.0

ImmatureSignatureError: The token is not yet valid (iat)

$ /tmp/cli/nextstrain login                     # 8.5.2+git.bdfbddc (the PR build)

Logged in to https://nextstrain.org as trs.

@tsibley
Copy link
Member

tsibley commented Aug 29, 2024

A changelog entry would be good.

Client clock skew can lead to invalid JWTs
resulting the the following error during login:

```
nextstrain.cli.aws.cognito.TokenError:
ImmatureSignatureError: The token is not yet valid (iat)
````

See <#307>
and the (internal) Slack thread
<https://bedfordlab.slack.com/archives/C01LCTT7JNN/p1719286802460679>
for discussion about whether iat timestamps ahead of the current
clock are actually invalid JWTs.
@jameshadfield jameshadfield force-pushed the skip-iat-verification branch from df7d035 to 7c2723f Compare August 29, 2024 19:40
@jameshadfield
Copy link
Member Author

I verified this works for me to avoid the issue when I intentionally introduce a lagging clock on my local machine.

After a bit of googling I'm still not sure how to do this on MacOS (I think date), so thanks for testing on my behalf!

A changelog entry would be good.

Added in force push.

@tsibley
Copy link
Member

tsibley commented Aug 29, 2024

After a bit of googling I'm still not sure how to do this on MacOS (I think date), so thanks for testing on my behalf!

The traditional Unix way is to use date -s "10 seconds ago" or similar. I'd expect that to work on macOS, though you might also need to disable time synchronization first like I had to. I know you can do that via the Settings panel, but don't know off hand how to do it from the command line. Also, you can tweak the time itself directly in the Settings panel.

@jameshadfield jameshadfield merged commit fd56e19 into master Aug 29, 2024
42 checks passed
@jameshadfield jameshadfield deleted the skip-iat-verification branch August 29, 2024 21:02
@tsibley
Copy link
Member

tsibley commented Sep 3, 2024

Releasing this as part of 8.5.3.

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.

Uncaught ImmatureSignatureError: The token is not yet valid (iat)
3 participants