The Patreon OAuth provider maps every authenticated Patreon account to the same local user.ID, instead of deriving a unique ID from the Patreon account returned by Patreon.
In practice, this means all Patreon-authenticated users of an application using this library are collapsed into a single local identity. Any application that trusts token.User.ID as the stable account key can end up mixing or fully merging unrelated Patreon users, which can lead to cross-account access, privilege confusion, and subscription-state leakage.
The bug is in the Patreon provider's user-mapping logic.
Both the root module and the v2 module create a fresh empty token.User{} and then derive the Patreon ID from userInfo.ID before that field has been populated:
mapUser: func(data UserData, bdata []byte) token.User {
userInfo := token.User{}
uinfoJSON := uinfo{}
if err := json.Unmarshal(bdata, &uinfoJSON); err == nil {
userInfo.ID = "patreon_" + token.HashID(sha1.New(), userInfo.ID)
userInfo.Name = uinfoJSON.Data.Attributes.FullName
userInfo.Picture = uinfoJSON.Data.Attributes.ImageURL
...
}
return userInfo
}
Affected locations:
provider/providers.go:257v2/provider/providers.go:257At that point, userInfo.ID is still the empty string, so the effective result is always:
patreon_ + sha1("")
which is:
patreon_da39a3ee5e6b4b0d3255bfef95601890afd80709
for every Patreon user.
The code appears to have intended to hash the Patreon user ID returned by Patreon, i.e. uinfoJSON.Data.ID, but instead hashes the uninitialized destination field.
Why this matters:
token.User.ID as the hashed user ID exposed to consumers.1.25.22.1.2Exploitability
AV:NAC:LPR:NUI:NScope
S:UImpact
C:HI:HA:N9.1/CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N