/

CVE-2026-62232

Severity:

HIGH RISK

(7.4)

AuthZ Flaw (CWE-862) in Grav 2FA Regeneration Task

CVE-2026-62232

Deferred

Vulnerability type

Category:

Missing Authorization

CWE:

CWE-862

Impact:

Two-Factor Authentication Bypass and Account Compromise

Severity:

HIGH RISK

(7.4)

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

Grav's login plugin contains an authorization flaw that allows bypassing two-factor authentication by abusing the 2FA secret regeneration task during a pending TOTP challenge.

If an attacker knows a user's password, they can overwrite the victim's 2FA secret with a chosen value, generate a valid code, and effectively downgrade the account to password-only protection.

Affected context

This vulnerability occurs within Grav's login plugin when two-factor authentication is enabled and a TOTP challenge is in progress.

The affected logic is the regenerate2FASecret task, which is reachable in the 2FA flow and performs sensitive changes to a user's second-factor secret.

The risk is present where the task is exposed without sufficient authorization checks, relies only on user existence, and can be invoked without strong request integrity protections.

Exploit preconditions

  • Attack surface: Web application login endpoint and associated 2FA (TOTP) challenge workflow.
  • Required access: Knowledge of the victim's valid username and password; ability to submit crafted HTTP requests during or around the 2FA step.
  • Trigger point: Invocation of the regenerate2FASecret task during the pending TOTP challenge, without a valid CSRF nonce and without additional authorization checks.
  • Why exploitation is possible: The task verifies that the target user exists but does not ensure that the caller is properly authorized, nor that the request is bound to a legitimate 2FA session. This missing authorization validation allows an attacker who has already passed the password check to replace the existing 2FA secret with an attacker-controlled value and then compute a matching TOTP code.

Why this happens

The underlying bug is a missing authorization check on a sensitive operation that modifies authentication factors.

The regenerate2FASecret pathway effectively trusts any request that can reference a valid user account, failing to confirm that the caller is the authenticated owner of that account or that the request carries a valid CSRF nonce tied to an established session.

This aligns with CWE-862: Missing Authorization, where access control logic neglects to enforce authorization before performing privileged actions, especially within authentication and 2FA management flows.

Conceptually, the pattern is: a state-changing security operation (resetting a 2FA secret) is exposed as a generic task endpoint, guarded only by existence checks and not by authorization or strong session binding.

Potential impact

  • An attacker who knows a user's password may bypass 2FA and gain full access to the account.
  • 2FA protection for targeted accounts can be silently downgraded to password-only security.
  • Compromise of administrator or privileged user accounts could lead to full site takeover.
  • Potential persistent control over the account by maintaining a known attacker-chosen 2FA secret.
  • Erosion of trust in the application's multi-factor authentication guarantees.

General mitigation guidance

Mitigation typically centers on strengthening authorization and request integrity around all authentication-factor management endpoints.

Effective defensive patterns include:

  • Enforcing strict authorization checks before any 2FA secret regeneration, ensuring the caller's identity matches the target account and that they are in a valid, authenticated session.
  • Binding sensitive tasks to the current authenticated user rather than accepting arbitrary user references, reducing opportunities for cross-account abuse.
  • Requiring a verified, fresh second factor (or equivalent high-assurance step) before allowing regeneration or reset of 2FA secrets.
  • Applying robust CSRF protections (nonces or same-site tokens) to all state-changing operations within the login and 2FA flows.
  • Designing 2FA management APIs with secure-by-default patterns, where destructive or high-impact changes are minimized and gated behind layered checks.

These patterns help ensure that 2FA remains an effective security control and that its lifecycle cannot be subverted through weak authorization logic.

How teams detect issues like this

Detection can focus on identifying missing or incomplete authorization logic on security-sensitive routes:

  • Static analysis rules that flag endpoints modifying authentication factors (e.g., 2FA secrets, passwords) which lack explicit access control checks tied to the current session.
  • Code review procedures that trace authentication and 2FA workflows end-to-end, verifying that every step performing account changes validates both identity and session integrity.
  • Centralized access control policies requiring that user-affecting actions be mediated through standardized authorization mechanisms rather than ad hoc task handlers.
  • Runtime logging and monitoring of 2FA-related events, such as secret regeneration or reset actions, with alerts on unusual patterns (e.g., frequent regenerations, regenerations without prior 2FA verification).
  • Automated security testing and fuzzing of login and account recovery flows to ensure that 2FA bypass paths are not exposed through unprotected secondary endpoints.

Sources

SourceLink
github.comgithub.com/getgrav/grav/security/advisories/GHSA-7mgc-c7pq-3rr3
vulncheck.comvulncheck.com/advisories/grav-2fa-bypass-via-secret-regeneration

Frequently asked

questions

Exploitability is significant wherever attackers can obtain valid user passwords. Once an attacker knows a victim's credentials, they can leverage the flawed 2FA regeneration logic to bypass the second factor, making multi-factor authentication ineffective for that account.

The attacker must know the victim's username and password and be able to interact with the Grav login interface or underlying HTTP endpoints. No prior access to the victim's current 2FA device is required, as the vulnerability allows the attacker to set a new, attacker-controlled 2FA secret.

The safest fix is to enforce strict authorization checks and strong session binding on all 2FA management operations. Regeneration or reset of 2FA secrets should only be allowed for the currently authenticated user, under a verified high-assurance context (such as requiring the existing second factor), and protected by standard CSRF defenses.

Future prevention relies on consistently treating authentication and 2FA lifecycle endpoints as high-risk and subject to centralized access control. Use a uniform authorization layer, mandate code reviews for any feature touching login or factor management, require CSRF protection on all state-changing requests, and include targeted tests in CI pipelines that attempt to perform cross-account or unauthenticated use of sensitive tasks.

Find out what's already
exploitable in your codebase.