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

TOTP_VALID_WINDOW setting #11

Merged
merged 1 commit into from
Jun 23, 2022
Merged

TOTP_VALID_WINDOW setting #11

merged 1 commit into from
Jun 23, 2022

Conversation

tobiasmboelz
Copy link

This pull request adds a setting for the valid_window value passed to PyTOTP’s verify method.

In my tests users with a certain authenticator app couldn’t log in unless I changed the code to call verify with valid_window=1 (or higher). I added a setting instead of just changing the value as increasing the value has security implications and not everyone would want to have this change.

Please let me know if I should add a test or some additional documentation.

@xi
Copy link
Owner

xi commented Jun 22, 2022

Thanks for the contribution! The code looks good to me, and I think exposing a lower level parameter sounds reasonable.

But just to be sure: What is causing this issue? Is this a bug in the authenticator app? The spec discusses this issue:

A larger acceptable delay window would expose a larger window for attacks. We RECOMMEND that at most one time step is allowed as the network delay.

@tobiasmboelz
Copy link
Author

Thanks for the contribution! The code looks good to me, and I think exposing a lower level parameter sounds reasonable.

But just to be sure: What is causing this issue? Is this a bug in the authenticator app?

The app in question is Google Authenticator for Android. I think it’s rather particular behaviour than a bug. As far as I can tell it only supports generating codes every 30 seconds and seems to expect that a code remains valid for 60 seconds.

The spec discusses this issue:

A larger acceptable delay window would expose a larger window for attacks. We RECOMMEND that at most one time step is allowed as the network delay.

Yes, you probably shouldn’t set valid_window to anything lager than 1.

The next section of the spec says:

Because of possible clock drifts between a client and a validation server, we RECOMMEND that the validator be set with a specific limit to the number of time steps a prover can be "out of synch" before being rejected.

And it suggests to do automatic resynchronisation, but PyOTP doesn’t support that.

@xi
Copy link
Owner

xi commented Jun 23, 2022

OK, sounds solid to me.

I will make a release as soon as #10 as been resolved.

@xi xi merged commit f55050f into xi:main Jun 23, 2022
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.

2 participants