-
Notifications
You must be signed in to change notification settings - Fork 17
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
generateTOTP generates insecure OTPs with digits over 6 and alphabetic charSet #6
Comments
I'm afraid this is as far as my knowledge goes with this. I'm not sure whether this is expected or a bug. Sorry. |
Hey, understood. No problem. This type-safe OTP library is exactly what we need. Thanks for it! I might try to figure out how to fix this bug over the weekend. |
Thank you! |
https://chat.openai.com/share/e96f8b80-8b65-4f46-a75e-8eb68142c40b This is what ChatGPT had to say about this, can anyone confirm this is an ok change to make? I can confirm it generates less biased HOTP's @ChristianBoehlke linking you in here as you seem to have some experience with this. |
I would definitely appreciate any change be accompanied by tests. Especially those that involve some sort of time mocking so we can verify things work over time. |
Here is what I know about this bug:
The spec says in section 5.4.:
So, based on this, to me it sounds like adding more characters to the charset will not make the resulting string any more secure (once the 4 bytes are "processed") or longer (in fact, adding more characters will make it shorter). |
In that case I think it would make sense to throw a descriptive error if anyone provides more digits than is supported. If you really want long codes, then you can concat multiple together. Anyone up for a pull request? |
Unless I misunderstand what's being said and we should remove the charSet option as well to restore spec compliance? |
Closing due to inactivity. Please feel free to open up a PR if anyone is interested in working on this. Thanks! |
As far as I can tell this happens even without
Output will be something like:
Seems like |
Seems reasonable to go up to 8 or 10 🤔 |
I'm not sure if this is intentional but it seems that this particular case is not covered in the tests.
So here's the main issue:
I'm using
generateTOTP
from the @epic-web/totp library to generate OTP codes. I'm trying to create secure and unique tokens using the SHA256 algorithm with 20 digits and a custom character set for a password reset flow in Remix. However, the generated tokens have repetitive and insecure patterns. This seems to happen only when I include alphabetic letters in thecharSet
Here's the code to reproduce:
Environment:
Deps:
The text was updated successfully, but these errors were encountered: