8000 Prevent 2fa token reuse · Issue #276 · scheb/2fa · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Prevent 2fa token reuse #276

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

Closed
VarunAgw opened this issue Apr 29, 2025 · 4 comments
Closed

Prevent 2fa token reuse #276

VarunAgw opened this issue Apr 29, 2025 · 4 comments

Comments

@VarunAgw
Copy link

The library should support a feature to prevent 2FA token reuse.

Currently, we can use same token unlimited number of times before it expires

@scheb
Copy link
Owner
scheb commented Apr 29, 2025

How do you "reuse" a 2FA authentication code? Would you please describe a scenario, in which a 2FA code is reused, causing a security risk?

Generated codes like the email code are re-generated on each login. So each time you try to log into an account, a new code is generated and the old one becomes invalid. Time-based codes (TOTP codes) are changing each period, which is typically 30 seconds. So a time-based code is only valid for a very limited amount of time. In general, 2FA codes are only valid for the specific account they're generated for, so you cannot use a code that was generated for account A to pass 2FA for account B.

@VarunAgw
Copy link
Author

I do agree that it's not a big security risk, though.

But I feel it's a good practice to invalidate the code after each use.

Repository owner deleted a comment from VarunAgw Apr 29, 2025
@scheb
Copy link
Owner
scheb commented Apr 29, 2025
  • Email code de-facto becomes invalid immediately, because each login generates a new email code. Knowing a previous email code doesn't give you any advantage.
  • As explained, TOTP codes are changing each period, e.g. every 30 seconds. That's by design, they automatically become invalid after a short amount of time.

Multiple people can use the same code to log in to the same account.

Only possible for time-based codes within a small time window. Though, how would an attacker acquire the authentication code? Any scenario that I could think of would require a severe security breach either on side of the user, or on the side of your system.

@scheb
Copy link
Owner
scheb commented Apr 29, 2025

If you really want to do that, you could listen to the check events, keep track of all the used authentication codes and throw an exception when a code is used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants
0