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

Use HMAC-SHA256 instead of SHA256 for hashing phone numbers #41

Merged
merged 3 commits into from
Feb 4, 2025

Conversation

sietseringers
Copy link
Member

This solves this issue identified by @confiks by using HMAC-SHA256 on phone numbers instead of SHA256, before storing them as Redis keys.

Note that this adds new configuration to the application so the deployment(s) will need to be updated.

@kamphuisem
Copy link
Contributor

Just a thought; couldn't/shouldn't we include the token in the hash (instead of storing it as one of the values) and match on the set, so that even if the database and secret key are leaked, the extra randomness makes it more secure?

@sietseringers
Copy link
Member Author

That would be possible, yes. But it would also mean that the application isn't able to distinguish anymore between nonexisting sessions, and an existing session for which the user entered a wrong token. In other words, entering the wrong code for an existing session will result in an error message saying the session doesn't exist, rendering much of the logic in case of wrong tokens in TokenManager.verify() dead code. I don't think we want to go that far.

@kamphuisem kamphuisem merged commit 5b69c35 into master Feb 4, 2025
7 checks passed
@kamphuisem kamphuisem deleted the use-hmac branch February 4, 2025 10:45
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.

3 participants