Summary
A flaw in Cal.com's custom NextAuth JWT callback allows an attacker to assume any user's identity by updating the session with an arbitrary target email address.
When exploited, this logic issue grants full authenticated access to victim accounts without needing their credentials, as long as the attacker can trigger the vulnerable session.update() logic.
Affected context
This vulnerability affects Cal.com deployments using versions from 3.1.6 up to, but not including, 6.0.7 where:
- Authentication is handled via NextAuth with a customized JWT callback.
- The application trusts client-supplied values (such as email) during
session.update()operations. - Session identity is derived from mutable claims rather than a server-controlled principal or immutable identifier.
It becomes relevant in environments where attackers can trigger session updates or influence the data passed into the JWT/session callback.
Exploit preconditions
- Attack surface: Web application authentication/session layer exposed over HTTP(S).
- Required access: Ability to interact with the application as any user (including anonymous or low-privilege accounts) and invoke the NextAuth session update flow.
- Trigger point: A call to
session.update()or similar session-refresh mechanism that passes a target email address into the custom JWT callback. - Why exploitation is possible: The JWT callback logic fails to re-verify that the email used to identify the session owner belongs to the authenticated principal. Instead, it effectively trusts the client-controlled email and binds the session to whatever account matches that address.
Why this happens
The core issue is a broken authorization and identity-binding design in the custom NextAuth JWT callback, aligning with CWE-639: Authorization Bypass Through User-Controlled Key and influenced by CWE-602: Client-Side Enforcement of Server-Side Security.
The callback appears to:
- Accept client-supplied identity attributes (such as
email) fromsession.update(). - Use this mutable attribute as the key to look up or construct the authenticated user context.
- Fail to enforce a server-side check that the requested identity matches the already authenticated principal.
In effect, the system uses a client-controlled identifier as the authoritative account selector, rather than tying the session to a server-validated user ID and validating any changes against existing authentication state.
Potential impact
- Full account takeover of arbitrary Cal.com users by specifying their email address.
- Unauthorized access to private scheduling data, meeting details, and associated PII.
- Ability to modify victim configuration, availability, integrations, and booking links.
- Potential lateral impact if compromised accounts are integrated with external systems (e.g., calendars, video providers, CRMs).
- Reputational damage and privacy violations due to impersonation and data exposure.
General mitigation guidance
Resilient fixes focus on server-side ownership checks and immutable identity binding:
- Treat the user identifier (e.g., internal user ID) as an immutable server-side field that cannot be altered via client-controlled operations like
session.update(). - Ensure the JWT callback derives user identity strictly from verified authentication facts (e.g., provider user ID, subject claim) rather than accepting arbitrary email or ID values from the client.
- Perform explicit authorization checks when updating session attributes, confirming that changes are allowed for the current authenticated principal.
- Avoid using email (or other user-controlled, guessable fields) as the sole authoritative account key; use stable, internal identifiers.
- Minimize sensitive logic in client-controlled flows; always enforce access control on the server regardless of client-side checks.
These patterns reduce the risk of future account-takeover bugs in authentication and session logic.
How teams detect issues like this
Detection can target both code and runtime behavior:
- Static analysis / code review:
- Flag custom authentication or JWT callback code that:
- Uses client-supplied fields (like
emailoruserIdfrom request/session updates) to directly look up user records. - Updates the session's user identity based on mutable client-side input without re-authentication.
- Look for patterns where
session.update(), or equivalent functions, accept arbitrary user identifiers. - Review any customization of NextAuth callbacks (
jwt,session) for client-controlled identity changes. - Runtime / logging analysis:
- Monitor logs for frequent switches in session-associated email or user IDs within a single browser session or IP.
- Alert on unusual patterns where a single source accesses many distinct user accounts in a short period.
- Policy enforcement:
- Establish guidelines requiring that identity claims used for authorization be derived from server-controlled sources.
- Use automated review tools to enforce rules around session and JWT mutation logic before merge.

