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

Should challenge.issued_at use unix time? #38

Closed
woylie opened this issue Mar 29, 2024 · 5 comments · Fixed by #39
Closed

Should challenge.issued_at use unix time? #38

woylie opened this issue Mar 29, 2024 · 5 comments · Fixed by #39

Comments

@woylie
Copy link

woylie commented Mar 29, 2024

I noticed that the issued_at value in Wax.Challenge is set using :erlang.monotonic_time/1. Is there a reason for this choice? It seems a bit problematic to me, since:

  1. This value is monotonically increasing, but not strictly monotonically increasing. Consecutive calls can produce the same result.
  2. The produced value is not the same on different runtime instances. If a challenge is generated on one node, stored in a session, and the verification happens to be handled on a different node, the timeout detection may fail.

Shouldn't the value be the unix time instead? Also, the timeouts in the WebAuthn specification are defined in milliseconds. I think it would be good to use millisecond values in the library as well, to avoid confusion. So in short, DateTime.to_unix(DateTime.utc_now(), :millisecond).

@tanguilp
Copy link
Owner

I think I did it this way for some security reasons: bad actors can succeed in changing the UNIX time (hacking NTP, changing the time on the OS...) and make an expired challenge valid again.

Now, this is probably overstretched as an attack scenario, and the issue with different nodes is real. We probably need to change that as you suggest.

Which issue do you have exactly?

@woylie
Copy link
Author

woylie commented Mar 29, 2024

I have an implementation where the authenticator response is submitted with a POST request on a controller route. The challenge is stored in a session cookie. In a multi-node deployment, I cannot guarantee that this request is made on the same node that generated the session.

@tanguilp
Copy link
Owner

Ok so this needs to be changed. Going to fix it this WE, check out for a new version on Monday.

Until then, have a good WE!

@tanguilp
Copy link
Owner

Feel free to check and comment #39

@woylie
Copy link
Author

woylie commented Mar 31, 2024

Thank you for the quick release!

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 a pull request may close this issue.

2 participants