The analysis of the security advisory and the corresponding patch commit reveals a critical multi-factor authentication bypass in ApostropheCMS. The root cause lies in the @apostrophecms/express module's getBearer function. This function is responsible for validating bearer tokens for API requests. The vulnerability stems from an incorrect MongoDB query operator ($ne: [] instead of the correct $size: 0) used to check the status of multi-factor authentication requirements. This logic error allows an 'incomplete' token, issued after password verification but before MFA completion, to be accepted as a fully authenticated token, granting the attacker full API access as the victim.
A secondary, amplifying bug was identified in the finalizeIncompleteLogin function within the @apostrophecms/login module. This function fails to properly delete the incomplete token from the database after a legitimate login because it uses the wrong identifier (token.userId instead of token._id). This leaves the incomplete token active and exploitable for its entire lifetime (defaulting to one hour), even if the legitimate user logs in successfully.
The exploitation process begins when an attacker, having compromised a user's password, makes a login request. The initialLogin function issues an incompleteToken. The attacker then uses this token in the Authorization: Bearer header of subsequent API requests. The getBearer function incorrectly validates this token, leading to a full session hijack. Therefore, getBearer is the primary vulnerable function that would appear in a runtime profile during exploitation.