/

CVE-2026-32730

Severity:

HIGH RISK

(8.1)

Authentication Bypass in ApostropheCMS

CVE-2026-32730

Analyzed

Vulnerability type

Category:

Authentication Bypass

CWE:

CWE-287, CWE-305

Impact:

Bypass of Multi-Factor Authentication and Unauthorized Account Access

Severity:

HIGH RISK

(8.1)

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

ApostropheCMS contains an authentication flaw where bearer tokens associated with logins that have not completed TOTP/MFA checks are mistakenly treated as fully authenticated sessions.

In deployments using @apostrophecms/login-totp or custom afterPasswordVerified requirements, this allows attackers who obtain or generate such partial tokens to bypass multi-factor authentication and access protected resources as if MFA were satisfied.

Affected context

The vulnerability occurs in ApostropheCMS instances that:

  • Use bearer token authentication via the middleware in @apostrophecms/express
  • Have TOTP/MFA enabled through @apostrophecms/login-totp or any custom afterPasswordVerified login requirement
  • Rely on MongoDB-backed login token documents to represent authentication state

The issue arises when an incomplete login token—where the password has been validated but the additional factor has not—can still satisfy the middleware's database query and be treated as a fully authenticated bearer token.

Exploit preconditions

  • Attack surface: HTTP(S) endpoints protected by ApostropheCMS bearer token authentication.
  • Required access: Ability to obtain or submit a bearer token corresponding to a login flow where the password was successfully verified but TOTP/MFA or other afterPasswordVerified checks were not completed.
  • Trigger point: Sending API or web requests with the affected bearer token in the Authorization header to routes guarded by the authentication middleware.
  • Why exploitation is possible: The MongoDB query used by the bearer token middleware does not correctly ensure that all post-password-verification requirements (such as TOTP/MFA) have been satisfied, so tokens from partially completed login flows are accepted as if they represented full authentication.

Why this happens

This vulnerability stems from an authorization logic error in the bearer token authentication middleware.

The MongoDB query that looks up login tokens fails to distinguish between:

  • Tokens created after password verification but before completion of MFA or other afterPasswordVerified checks, and
  • Tokens representing fully authenticated sessions.

As a result, the middleware incorrectly treats any token that matches the partial criteria as fully valid.

This maps primarily to CWE-287: Improper Authentication, because the system does not correctly enforce the required authentication steps, and secondarily to CWE-305: Authentication Bypass by Primary Weakness, since the bypass arises from flawed verification logic rather than cryptographic weakness.

Abstractly, this is an insecure pattern where a single token or flag is used for multiple authentication states, and downstream code fails to check that the state reflects completion of all required factors.

Potential impact

  • Attackers may bypass TOTP/MFA or custom afterPasswordVerified checks and gain access using only a password-verified token.
  • Compromise of user accounts protected by multi-factor authentication.
  • Escalation to administrative or editorial privileges if high-privilege accounts are targeted.
  • Unauthorized content changes, data exposure, or manipulation of CMS-managed resources.
  • Potential pivot into related systems or integrations that trust ApostropheCMS authentication.

General mitigation guidance

Mitigation focuses on enforcing complete authentication state before issuing or accepting bearer tokens:

  • Ensure that login tokens used for bearer authentication are only created or marked as valid after all authentication steps (password plus TOTP/MFA or other secondary checks) are successfully completed.
  • Represent authentication state explicitly in the data model, using distinct fields or token types for "password-verified" and "fully authenticated" sessions, and require the stronger state for API access.
  • Centralize authentication logic so that bearer token validation reuses the same checks and invariants as interactive login flows.
  • Apply the principle of least privilege to tokens: limit their scope, lifetime, and permissible actions so that a single logic error has reduced blast radius.
  • Incorporate defense-in-depth controls such as IP-based alerts, unusual login detection, or rate limiting around token-based access to reduce exploitation opportunities.

How teams detect issues like this

Effective detection typically includes:

  • Static analysis and code review:
  • Look for authentication middleware that queries login or token collections without explicitly checking MFA-related fields or flags.
  • Review MongoDB queries in authentication code paths for ambiguous criteria that do not differentiate partial and complete authentication states.
  • Identify any code paths where tokens are generated or persisted before all required checks are finalized.
  • Logging and monitoring:
  • Log token creation events separately for password verification and full MFA completion, and alert on tokens used without corresponding MFA-complete events.
  • Monitor for repeated use of tokens associated with incomplete login flows or unusually fast transitions from password verification to authenticated API usage.
  • Automated tooling and policy enforcement:
  • Use security-focused linters or custom rules to flag authentication logic that does not explicitly enforce secondary factors where configured.
  • Integrate CI checks that prevent changes to authentication middleware unless they include validation of configured MFA or afterPasswordVerified states.

Sources

SourceLink
github.comgithub.com/apostrophecms/apostrophe/security/advisories/GHSA-v9xm-ffx2-7h35

Frequently asked

questions

Yes. Any remote client that can interact with ApostropheCMS endpoints protected by bearer token authentication could exploit this issue if it can obtain or cause issuance of a token from a partially completed login flow.

Typically, the attacker needs to reach a state where the password for an account has been successfully verified, which often implies knowledge or compromise of user credentials.

However, if other weaknesses or implementation details allow attackers to obtain such partial tokens without credentials, those could be chained with this flaw.

The safest pattern is to ensure that bearer tokens accepted by the middleware are tied exclusively to a "fully authenticated" state.

This means separating "password-verified" from "MFA-complete" states in the data model and updating token queries so they only match records that explicitly indicate successful completion of all configured authentication steps.

Future prevention should rely on designing authentication as a state machine with clearly defined transitions and invariants:

  • Model each authentication step (password, TOTP, additional checks) as distinct states.
  • Require explicit checks for the final, strongest state before granting API access or issuing long-lived tokens.
  • Subject all authentication changes to focused security review, and add automated tests that verify MFA is mandatory wherever it is configured.
Find out what's already
exploitable in your codebase.