/

CVE-2026-31944

Severity:

HIGH RISK

(7.6)

Missing Authentication / Session Binding in OAuth Flows

CVE-2026-31944

Analyzed

Vulnerability type

Category:

Missing Authentication / Session Binding in OAuth Flows

CWE:

CWE-306

Impact:

Account Takeover of Linked Third-Party Services

Severity:

HIGH RISK

(7.6)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

LibreChat's MCP OAuth callback endpoint fails to verify that the user completing an OAuth flow is the same user who initiated it.

This allows an attacker to trick a victim into completing an OAuth authorization sequence and have the victim's tokens bound to the attacker's LibreChat account, enabling takeover of the victim's MCP-linked services.

Affected context

The vulnerability occurs in LibreChat deployments using the Model Context Protocol (MCP) integrations with third-party identity or service providers (e.g., Atlassian, Outlook).

It affects instances where:

  • Users can initiate OAuth flows for MCP-linked services, and
  • The OAuth callback endpoint stores access/refresh tokens based solely on the flow identifier, without verifying session identity or login state.

The risk is present when users can be induced to click on attacker-provided OAuth authorization URLs.

Exploit preconditions

  • Attack surface: Public-facing MCP OAuth callback endpoint on a LibreChat instance.
  • Required attacker access: Ability to create an account on the target LibreChat instance and initiate an OAuth flow for an MCP integration.
  • Victim involvement: Victim must be willing (or tricked) into following a crafted authorization URL and completing the OAuth consent with the third-party provider while logged into that provider.
  • Trigger point: When the identity provider redirects back to the LibreChat OAuth callback endpoint with authorization codes/tokens.
  • Why exploitation is possible: The callback logic associates the returned OAuth tokens with the user who initiated the flow, without confirming that the browser/session completing the flow is the same user or even authenticated to the intended LibreChat account.

Why this happens

This issue stems from missing authentication and improper binding between the OAuth authorization response and the authenticated user session in LibreChat.

Instead of validating that:

  1. a browser accessing the OAuth callback is currently logged into LibreChat, and
  2. the logged-in user matches the user who initiated the OAuth flow,

the implementation assumes that whoever completes the OAuth redirect can safely have tokens stored against the original initiator's account.

This maps to CWE-306: Missing Authentication for Critical Function, as a critical operation—binding OAuth tokens to an account—is performed without enforcing proper authentication and session correlation at the callback stage.

Potential impact

  • Attacker may gain access to a victim's MCP-linked services (e.g., Atlassian, Outlook) via stolen OAuth tokens.
  • Attacker could read, modify, or delete data in third-party services tied to the victim's identity.
  • Attacker can act as the victim in integrated systems, potentially escalating to broader organizational compromise depending on the privileges of the victim's external accounts.
  • Long-lived refresh tokens, if present, can allow persistent access even if the immediate session is invalidated.

General mitigation guidance

Robust mitigation focuses on securing OAuth flows and tightening identity binding:

  • Require an authenticated LibreChat session at the OAuth callback and verify that the logged-in user matches the user who initiated the OAuth flow.
  • Use server-side state parameters or correlation identifiers tied to the user's session and validate them at the callback before storing tokens.
  • Treat token storage and account linking as a sensitive operation that demands explicit user identity confirmation and CSRF protection.
  • Minimize token scope and lifetime; prefer least-privilege access and short-lived tokens where supported.
  • Clearly separate initiation and completion of OAuth flows so that tokens are only bound after all identity checks pass.

How teams detect issues like this

Detection efforts can focus on both code-level and behavioral indicators:

  • Static analysis / code review:
  • Look for OAuth callback handlers that store tokens or bind accounts without verifying the current authenticated user.
  • Flag flows that rely solely on client-side parameters (e.g., query strings) to decide which account to associate tokens with.
  • Review use of OAuth state and session identifiers to ensure they are validated and bound to the initiator's session.
  • Runtime and logging:
  • Monitor logs for OAuth flows where the initiating user and the logged-in user at callback differ, or where callbacks occur without a valid session.
  • Alert on unusual patterns such as a single LibreChat account collecting tokens for multiple distinct third-party identities.
  • Policy and CI/CD checks:
  • Enforce security design reviews for new or modified authentication/OAuth integration code paths.
  • Integrate automated review tools that highlight authentication/authorization gaps around callback endpoints and token handling.

Sources

SourceLink
github.comgithub.com/danny-avila/LibreChat/security/advisories/GHSA-vf7j-7mrx-hp7g

Frequently asked

questions

Exploitation is feasible wherever attackers can register on the same LibreChat instance and send crafted OAuth authorization URLs to victims.

The attack works over the network and can be launched via phishing, chat messages, or other social-engineering channels.

No. The attacker needs their own LibreChat account and a victim who completes the OAuth authorization flow via a malicious link.

The core issue is that the callback binds the victim's tokens to the attacker's account without verifying the user/session.

Always authenticate and identify the user at the OAuth callback, then verify that this user is the same party who initiated the flow.

Use server-side state or correlation tokens bound to the user's session and reject any callback that does not match the expected session and user identity.

Design OAuth flows with strict session binding and CSRF protections:

  • Require a valid, authenticated session at callback time.
  • Validate state parameters and any flow identifiers against server-side records.
  • Treat token issuance and account linking as sensitive operations that require strong identity checks and careful review.
Find out what's already
exploitable in your codebase.