OSV 1.4.0 · github-reviewed · 修改于 2026-05-16 01:33
发布时间
2026-05-16 01:33
GitHub 审查时间
2026-05-16 01:33
NVD 发布时间
—
源文件
advisories/github-reviewed/2026/05/GHSA-wxw3-q3m9-c3jr/GHSA-wxw3-q3m9-c3jr.json
Users are affected if all of the following are true:
better-auth at a version below 1.6.2 (or @better-auth/sso paired with such a version).betterAuth({ account: { storeStateStrategy } }) is set to "cookie". The default "database" is not affected.genericOAuth({ config }) with pkce: false, or it supplies a custom getToken or tokenUrl that does not require the stored codeVerifier. Stock social providers with PKCE on are not affected.code values to the configured callback URL.If users are on [email protected] or later, they are not affected.
Fix:
[email protected] or later (current stable is 1.6.10).In parseGenericState, the cookie branch decrypted the oauth_state cookie and validated expiry, but did not compare the incoming OAuth state query parameter to the nonce that generateGenericState issued at sign-in. Any callback to /api/auth/oauth2/callback/<providerId> that arrived with a forged state and any code was therefore accepted as long as the browser still held a live oauth_state cookie. With pkce: false (or any getToken path that does not enforce a code-verifier round-trip), an attacker who forced the victim to deliver an attacker-controlled authorization code to the callback would mint a session bound to the attacker's external identity in the victim's browser. Account-linking flows behaved the same way, binding the attacker's external account to an authenticated victim row.
The cookie branch of parseGenericState did not compare the cookie's stored nonce to the incoming parameter. The database branch (the default) was not affected because the verification row is keyed by and the lookup itself enforces equality.
statestateThe fix re-binds the cookie to the nonce: generateGenericState writes oauthState: state into the encrypted payload before storage, and parseGenericState rejects when parsedData.oauthState !== state. The same primitive covers every caller (generic-oauth, social, account-link, oauth-proxy passthrough, OIDC SSO, SAML relay state).
Fixed in [email protected] via PR #8949 (commit 9deb7936a, merged 2026-04-09). The cookie branch of parseGenericState now rejects when the encrypted payload's nonce does not match the incoming state parameter; the database branch gained a defense-in-depth equality check.
If users cannot upgrade immediately:
storeStateStrategy back to "database" (the default). This closes the cookie-only bypass without a code change.pkce: true on every affected genericOAuth provider. The codeVerifier is the missing primitive that the attacker cannot supply.Reported by @Jvr2022 via private advisory disclosure, and by @alavesa (PatchPilots audit) via the public duplicate issue #8897.