[GH-ISSUE #8897] OAuth state not verified in cookie-based strategy (state.ts) #11225

Open
opened 2026-04-13 07:34:18 -05:00 by GiteaMirror · 0 comments
Owner

Originally created by @alavesa on GitHub (Apr 1, 2026).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/8897

In parseGenericState when storeStateStrategy === 'cookie', the state value from the OAuth callback URL is never compared against the originally generated state value. The function only checks that the oauth_state cookie exists and can be decrypted — but doesn't verify that the returned state matches what was sent. The database strategy does perform this comparison.

Impact: Potential CSRF in OAuth flows using the cookie strategy.

Note: Existing issues (#5243, #7352, #6847, #5871) report state mismatch bugs — this is a different concern: the verification step itself is missing.

Found by PatchPilots security audit.

Originally created by @alavesa on GitHub (Apr 1, 2026). Original GitHub issue: https://github.com/better-auth/better-auth/issues/8897 In `parseGenericState` when `storeStateStrategy === 'cookie'`, the `state` value from the OAuth callback URL is never compared against the originally generated state value. The function only checks that the `oauth_state` cookie exists and can be decrypted — but doesn't verify that the returned state matches what was sent. The database strategy does perform this comparison. **Impact:** Potential CSRF in OAuth flows using the cookie strategy. *Note: Existing issues (#5243, #7352, #6847, #5871) report state mismatch bugs — this is a different concern: the verification step itself is missing.* Found by [PatchPilots](https://github.com/alavesa/patchpilots) security audit.
GiteaMirror added the securitybug labels 2026-04-13 07:34:18 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#11225