Details
Fix: Add EmailVerified bool \json:"email_verified"`` to the struct and map it correctly.
Attack Scenario (Discord)
Setup: An Nhost application uses Discord OAuth. A victim has an account with [email protected].
- Attacker opens Discord → User Settings → Account, changes email to
[email protected], and dismisses the dialog, without clicking the confirmation link.
- At this point Discord's API returns
"email": "[email protected]", "verified": falsefor the attacker's account.
- Attacker visits the target application and clicks Sign in with Discord.
- Nhost fetches the Discord profile. The missing
Verifiedfield in the struct causes the JSON decoder to drop it. The adapter setsEmailVerified: truebecause"[email protected]" != "".
- Nhost finds the victim's account by email, sees no Discord provider row linked to it, and calls
InsertUserProviderto link the attacker's Discord ID.
- Nhost issues a full session for the victim's account and returns it to the attacker.
- The attacker is now authenticated as the victim.
The attack is silent, the victim receives no notification and the session appears entirely legitimate.
Defense-in-Depth Gap (Informational)
Several other providers also use EmailVerified: email != "", the same logical pattern as the vulnerable ones above. However, these are not currently exploitable because the platforms themselves enforce email verification before returning an address in the API response:
|Provider|API Field Used|Why Not Exploitable Today|
|---|---|---|
|Twitch|email string only|Twitch requires email verification at sign-up; the API never returns an unverified email|
|GitLab|email string only|GET /api/v4/user only returns the confirmed primary email|
|Facebook|email via Graph API|Facebook only includes email in the response when it is confirmed|
|Twitter|email via verify_credentials|Twitter requires a working email address on the account|
|Spotify|email string only|Spotify enforces verification before account activation|
|Windows Live|preferred account email|Microsoft's Live API only surfaces confirmed addresses|
|WorkOS|email from SSO profile|Controlled by the enterprise IdP|
These providers happen to be safe due to external platform behavior, not due to any validation in Nhost's code. The email != "" shortcut is fragile:
- If any of these platforms change how their API works, Nhost silently becomes exploitable for that provider.
- Any developer adding a new provider in the future will likely copy the same pattern, believing it is the established convention, creating vulnerabilities in new integrations.
For this reason, the controller-level guard in Layer 1 of the fix below is important even beyond the four currently vulnerable providers: it makes the system safe by design regardless of what any individual adapter returns.
Impact
- Full account takeover of any existing Nhost user.
- Requires no interaction from the victim.
- Attacker can change the account email, disable other login methods, and permanently lock out the legitimate owner.
- Severity escalates to Critical in applications with admin or privileged accounts.