Repository navigation
fix(auth): store passwords as argon2id instead of unsalted MD5 - #3
Merged
Merged
Conversation
New accounts, password changes and the -ru reset now store an argon2id hash (PHC string, 19 MiB, 2 passes, 1 lane). An account that still holds the legacy MD5 keeps signing in, and its first successful sign-in replaces the hash; the swap is conditional on the row still holding the hash it read, so a password change racing a sign-in is not undone. Hashing is limited to two at a time so parallel requests on endpoints without a rate limit cannot ask for gigabytes. A release older than this one cannot verify an argon2id hash: roll back with casaos-user-service -ru -user <name>.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Passwords were stored as an unsalted MD5 in hex (as IceWhale's service still does): a stolen
user.dbgoes back to a wordlist in minutes.What changes
-rureset store an argon2id hash (PHC string, 19 MiB, 2 passes, 1 lane: the OWASP minimum). Parameters are read back from the stored string, so they can be raised later;NeedsRehashsays when a hash should be made again.Downgrade
Once an account has signed in,
user.dbholds argon2id, which older releases (and IceWhale's) cannot verify. To roll back, set a new password with the old binary:casaos-user-service -ru -user <name>. README says so; the release notes will too.Tests
Unit tests for hash/verify, salts, long and non-ASCII passwords, legacy MD5, other parameters, malformed values and concurrent use; route tests for the sign-in upgrade, wrong password, registration, password change and the stale-write race.
go test ./...andGOOS=linux go vet ./...pass.