Q34: What are the security pitfalls of implementing 'Login with Google/GitHub' and how do you resolve them?
Difficulty:MediumTopic:OAuth Security
Common pitfalls when implementing Social Login via OAuth 2.0:
Account Takeover via Unverified Email: Trusting unverified emails from social providers. Fix: Verify the email_verified claim from OIDC providers before linking social accounts to local profile records.
CSRF in Social Callback: Omitting state parameter validation during OAuth redirects. Fix: Enforce strict state checks.
Token Misuse: Accepting an ID token intended for a different application client ID. Fix: Always validate that aud (Audience) claim matches your application's client ID.
Key Takeaways
Always verify email_verified: true assertions before linking third-party social accounts to local profiles.
Validate the aud (Audience) claim to prevent using tokens issued for different applications.
Q34: What are the security pitfalls of implementing 'Login with Google/GitHub' and how do you resolve them?
Common pitfalls when implementing Social Login via OAuth 2.0:
email_verifiedclaim from OIDC providers before linking social accounts to local profile records.stateparameter validation during OAuth redirects. Fix: Enforce strictstatechecks.aud(Audience) claim matches your application's client ID.Always verify
email_verified: trueassertions before linking third-party social accounts to local profiles.Validate the
aud(Audience) claim to prevent using tokens issued for different applications.