Summary
Capgo contains an authorization flaw where authenticated users can arbitrarily change the email field that is later trusted as a key for SSO account merging.
By pre-setting their email to a victim's corporate SSO address, an attacker can cause the SSO provisioning flow to merge the victim's identity into the attacker-controlled account.
Affected context
This vulnerability occurs in Capgo deployments where:
- The
public.users.emailfield is user-modifiable after account creation - The SSO provisioning endpoint uses the email value as a trusted key for identity linking or account merging
- There is no separate, non-user-controlled identifier used to correlate SSO identities with existing accounts
Under these conditions, a user can align their mutable email field with a victim's corporate SSO email and influence how SSO provisioning resolves identity ownership.
Exploit preconditions
- Attack surface: Application web/API interface handling profile updates and SSO provisioning
- Required access: Valid authenticated user account on the Capgo instance
- Trigger point: Invocation of the SSO provision-user or similar endpoint after the attacker has changed their account email to match a victim's SSO email
- Why exploitation is possible: The system treats a user-controlled email attribute as an authoritative account-merge key without verifying that the email is bound to that user through a trusted, non-spoofable channel
Why this happens
The core issue is an authorization and object reference flaw consistent with CWE-639: Insecure Direct Object Reference (IDOR).
A sensitive linking operation (SSO account merge) relies on an attribute (public.users.email) that the user can directly manipulate.
Instead of using an internal, immutable identifier for correlation, the design trusts a mutable, user-supplied field as a secure reference, enabling attackers to impersonate or absorb other identities during SSO provisioning.
Potential impact
- Attackers could gain unauthorized access to data and capabilities associated with a victim's SSO identity.
- SSO-linked accounts could be merged into attacker-controlled profiles, effectively enabling account takeover.
- Access control policies based on email domain or SSO groups could be bypassed.
- Audit trails and identity records can become unreliable due to misattributed account merges.
General mitigation guidance
Mitigation typically focuses on separating user-controlled attributes from authoritative identity keys and enforcing strong ownership verification.
Useful defensive patterns include:
- Using immutable, server-assigned identifiers (e.g., internal user IDs, SSO subject/issuer pairs) as the sole basis for SSO account linking and merging.
- Treating email and similar attributes as display or contact information, not as trust anchors for identity resolution.
- Requiring proof-of-control (e.g., verified email flows or SSO assertions) before accepting changes to any attribute used in authorization or account linking logic.
- Restricting updates to sensitive fields and recording changes through auditable, policy-checked flows instead of generic profile updates.
How teams detect issues like this
Detection generally involves both code-level and behavior-level analysis:
- Static and manual code review to identify places where user-controlled fields (email, username, external IDs) are used as keys for account linking, merging, or authorization decisions.
- Policy checks in CI/CD pipelines that flag usage of mutable profile attributes in SSO or identity correlation logic.
- Runtime monitoring for anomalous patterns, such as frequent profile email changes followed by SSO provisioning events.
- Use of automated security testing tools that simulate IDOR scenarios, especially around identity and SSO workflows.

