Repository navigation
Hash 40-hex usernames in the direct provider instead of passing them through - #324
Merged
Merged
Conversation
…them through token.HashID returns a 40-char hex value unchanged, so a direct-provider username equal to the SHA1 of another username got that user's id. The default id is now the plain SHA1 of the username in both modules. Every other username keeps its id; usernames made of exactly 40 hex characters get new ones. UserIDFunc results still go through HashID, and its godoc says a 40-char hex result is used as-is.
Coverage Report for CI Build 41923348794Coverage increased (+0.04%) to 86.917%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
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.
The direct provider built the user id with
token.HashID, which returns any 40-char hex value unchanged. A username equal to the SHA1 of another username got that user's id:522b276a356bdf39013dfabea2cd43e141ecc9e8logged in asdirect_522b276a..., the same idalicegets. An app that keys records or permissions onUser.IDtreats the two logins as one account. Exploiting it needs a username policy that accepts 40-char hex names and a known victim username.The default id is now the plain SHA1 of the username, in both the root and v2 modules. For every other username the id is the same as before.
Behavior change: with the default ID mapping, usernames consisting of exactly 40 hexadecimal characters now receive new IDs; applications may need to migrate associated records. Custom
UserIDFuncbehavior is unchanged: its result still goes throughHashID, and its godoc now says a 40-char hex result is used as-is, so it must be an app-controlled id, never the raw username.token.HashIDitself is unchanged. The verify provider builds its id from the address the same way. It is exploitable only with a sender that accepts 40-hex addresses, since an email address always has an@, so it goes todocs/backloginstead of this PR.Reported privately by Rathnadeepan (@HotWater-015).