Executive brief
LibreChat is an open-source interface for interacting with various AI models. A security flaw allows an attacker who has gained access to a user's active session to overwrite and take full control of that user's two-factor authentication (2FA) settings. This results in the legitimate user being locked out of their account's security features, as the attacker can replace the existing 2FA codes with their own without needing to provide the original verification.
Technical details
A missing authentication check for a critical function (CWE-306) exists in the `enable2FA` function within `api/server/controllers/TwoFactorController.js`. The `/api/auth/2fa/enable` endpoint fails to verify if 2FA is already active and does not require a valid TOTP or backup code before performing destructive operations. An attacker with a valid JWT (obtained via session hijacking or similar means) can trigger this endpoint to overwrite the victim's TOTP secret and backup codes, effectively resetting the 2FA state to 'disabled' while generating new credentials for the attacker to finalize. This allows for a complete 2FA takeover, as the attacker can then re-confirm 2FA using their own generated secret. The issue is resolved in version 0.8.4-rc1 by requiring verification if 2FA is already enabled.
Affected products
- danny-avila LibreChat < 0.8.4-rc1
Timeline
- 2026-06-02: advisory: GitHub Security Advisory published by vendor
- 2026-06-25: disclosed: CVE published to NVD
- 2026-06-25: patched: Fix confirmed in version 0.8.4-rc1