Summary
Nhost's OAuth account-linking logic previously trusted provider-specific "email verified" flags that were incorrectly populated by several adapters (Discord, Bitbucket, AzureAD, EntraID).
Under these conditions, an attacker could supply an email address they do not own, have that OAuth identity automatically merged into a victim's Nhost account, and gain a fully authenticated session as the victim.
Affected context
This vulnerability appears in Nhost deployments that:
- Enable OAuth-based authentication through providers such as Discord, Bitbucket, AzureAD, or EntraID
- Use automatic account linking based on matching email addresses
- Rely on provider adapters to correctly set an
EmailVerified(or equivalent) flag
The issue manifests when Nhost's controller treats these verification flags as trustworthy indicators of email ownership, even though some adapters either ignore provider verification signals or infer verification from non-ownership-proving fields.
Exploit preconditions
- Attack surface: Public-facing OAuth sign-in and sign-up endpoints exposed by Nhost.
- Required access: Ability to initiate an OAuth login flow using the vulnerable providers; no prior account on Nhost is required.
- Trigger point: Completing the OAuth flow with an identity whose email matches an existing Nhost user, while the provider adapter incorrectly marks that email as verified.
- Why exploitation is possible: Nhost's account-linking logic automatically merges identities purely on "same email + EmailVerified = true," trusting adapter-populated fields that are either:
- Dropped despite the provider exposing verification status (Discord),
- Set to "verified" even when the email is unconfirmed (Bitbucket), or
- Derived from non-ownership signals like user principal name then marked verified (AzureAD, EntraID).
Why this happens
The underlying bug fits CWE-287: Improper Authentication, driven by over-trusting external identity assertions without strong verification of email ownership semantics.
Nhost's OAuth controller implements an auto-linking pattern: when an incoming OAuth profile reports an email address that matches an existing Nhost account and profile.EmailVerified is true, it merges that identity into the existing account. However, the controller assumes that:
- Each provider adapter correctly maps the provider's "verified email" semantics to
profile.EmailVerified, and - The presence of a "verified" flag implies the provider has robustly validated ownership of that email address.
Several adapters violate these assumptions:
- Some ignore or mishandle a provider's actual verified-email field (e.g., Discord).
- Others treat any returned email as verified, even if the provider indicates it is unconfirmed (e.g., Bitbucket).
- Microsoft-related providers (AzureAD, EntraID) treat identifiers like user principal name as if they were verified emails, despite not being an ownership proof.
Abstractly, this is an insecure trust boundary between Nhost and downstream identity providers. Nhost conflates "email string returned by the provider" with "proof that the user controls this email," enabling attackers to inject identities into existing accounts.
Potential impact
- Full account takeover of targeted Nhost users whose email addresses are known or guessable
- Unauthorized access to application data protected by Nhost authentication (e.g., GraphQL APIs, storage, functions)
- Abuse of victim accounts to perform privileged actions within the application (depending on the app's authz model)
- Elevation of privileges if the compromised account belongs to an administrator or high-privilege user
- Reputation damage and potential compliance issues for applications relying on Nhost for security guarantees
General mitigation guidance
Effective mitigation focuses on tightening email ownership verification semantics and reducing blind trust in external OAuth assertions:
- Decouple account linking from untrusted verification flags:
- Treat provider-specific "verified" booleans as hints, not as authoritative proof of email ownership.
- Introduce explicit, Nhost-controlled verification steps (e.g., confirmation emails) before linking identities to existing accounts.
- Harden identity provider adapters:
- Map only well-defined, documented "verified email" fields to a "verified" status.
- Avoid inferring verification from identifiers that do not prove email control (e.g., user principal name, display name).
- Reject or treat as unverified any email fields that lack explicit verification metadata.
- Constrain automatic account linking behavior:
- Require explicit user confirmation or step-up authentication before linking a new OAuth provider to an existing account with the same email.
- Optionally disable auto-linking and require users to log in via a primary method before attaching additional providers.
- Apply principle of least privilege:
- Design application-level authorization so that a compromised account has minimal impact by default.
- Segment administrative capabilities and require additional checks (e.g., re-authentication) for critical operations.
- Improve configuration defaults and documentation:
- Default to conservative assumptions for all providers whose email verification semantics are not well-understood.
- Clearly document which providers offer strong email verification and which require extra safeguards.
How teams detect issues like this
Detection generally combines code-level review of identity flows with runtime monitoring:
- Static analysis and code review:
- Examine all OAuth provider adapters for:
- How provider-specific email and verification fields are mapped into internal structs.
- Any logic that defaults unverified or absent fields to "verified" or "true."
- Use of non-email identifiers (e.g., user principal name) as email equivalents.
- Review the account-linking logic for patterns such as:
- Automatic merging of accounts solely based on email equality and a single boolean flag.
- Absence of server-side confirmation or second-factor checks before linking providers.
- Security policy and schema checks:
- Enforce internal contracts that
EmailVerifiedmay only be set from specific, documented provider fields. - Use type-safe wrappers or invariants that disallow "verified" status without an explicit provider proof type.
- Runtime logging and anomaly detection:
- Log all OAuth link events, including provider name, email, verification state, and whether an existing account was merged.
- Monitor for suspicious patterns, such as:
- Multiple provider accounts from different domains rapidly linking to the same Nhost account.
- Linking events where the email domain or format does not align with expected organization policies.
- Automated checks in CI/CD:
- Integrate SAST or custom linters to flag:
- Direct trust of external "verified" flags.
- New adapters that bypass established verification handling patterns.

