GHSA-f6qq-3m3h-4g42: auth: Patreon provider assigns the same local user ID to every authenticated Patreon account, enabling cross‑user impersonation
SummaryThe 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.DetailsThe 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:Affected locations:`provider/providers.go:257``v2/provider/providers.go:257`At that point, `userInfo.ID` is still the empty string, so the effective result is always:which is: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:Patreon is a documented, supported provider.The library documents `token.User.ID` as the hashed user ID exposed to consumers.The OAuth flow stores the mapped user object in JWT claims, and middleware later injects that object into the request context verbatim, consuming handlers receive the provider's wrong user.ID as authoritative identity.Relevant flow in `v2`:`v2/provider/oauth2.go:207` calls `u := p.mapUser(...)``v2/provider/oauth2.go:223` stores `u` in token claims`v2/middleware/auth.go:154` copies `*claims.User` into request contextThe existing tests already encode the broken behavior:`provider/providers_test.go:179``provider/providers_test.go:204``v2/provider/providers_test.go:179``v2/provider/providers_test.go:204`Those tests assert the constant empty-string hash value for Patreon users.PoCThis can be reproduced locally without contacting Patreon by exercising the provider's `mapUser` logic with two different Patreon payloads.From the repository root, create a temporary test file:`v2/provider/patreon_repro_test.go`Then run:Expected result:I also confirmed this locally with three distinct Patreon `data.id` values; all of them produced the same `patreon_da39...` identity.You can also see the same issue reflected in the existing built-in tests, which already assert this constant Patreon ID.ImpactThis is an authentication/identity-collision vulnerability in the Patreon provider.Impacted users:applications using `github.com/go-pkgz/auth/provider.NewPatreon`applications using `github.com/go-pkgz/auth/v2/provider.NewPatreon`applications that rely on `token.User.ID` as the stable local account identifier, or use it to key roles, profiles, entitlements, subscription state, or other authorization-relevant recordsPractical impact:all Patreon-authenticated users in the same application can collapse into the same local accountdata associated with one Patreon user may be exposed to or overwritten by another Patreon userPatreon-specific attributes such as `is_paid_sub` can leak across unrelated usersif a target application grants any elevated privileges to the local account keyed by this shared Patreon ID, those privileges can effectively apply to every Patreon loginSuggested FixThe Patreon provider should derive the user ID from the Patreon account ID returned by Patreon, not from the uninitialized destination struct.In both of these files:`provider/providers.go``v2/provider/providers.go`change:to:I would also recommend adding a regression test with at least two different Patreon `data.id` values and asserting that they produce different local IDs.Because the current bug causes all Patreon users to share a single local ID, maintainers may also want to consider migration guidance for consumers who already have Patreon-linked local accounts created under the broken identifier.
CVSS v3.1: 9.1