VYPR
Moderate severityNVD Advisory· Published Jun 6, 2024· Updated Sep 3, 2025

CraftCMS Plugin - Two-Factor Authentication - TOTP Token Stays Valid After Use

CVE-2024-5658

Description

The CraftCMS plugin Two-Factor Authentication through 3.3.3 allows reuse of TOTP tokens multiple times within the validity period.

AI Insight

LLM-synthesized narrative grounded in this CVE's description and references.

The CraftCMS Two-Factor Authentication plugin through 3.3.3 fails to invalidate TOTP tokens after use, allowing reuse within the validity period.

The CraftCMS Two-Factor Authentication plugin versions 3.3.3 and earlier do not enforce one-time use of Time-based One-Time Password (TOTP) tokens. According to RFC 6238, a TOTP must not be accepted more than once; however, the plugin accepts the same token multiple times if used within its validity window [1][3].

An attacker who possesses a valid TOTP token and knows the victim's credentials can reuse that token to establish multiple authenticated sessions. For example, starting the login process in two separate browsers and submitting the same TOTP simultaneously can both succeed, as demonstrated in the proof of concept [1][3].

Successful exploitation allows an attacker to bypass the intended two-factor authentication and gain repeated access to the victim's account without generating new tokens. The CVSS base score is 4.8 (Medium), reflecting the need for prior knowledge of credentials but relatively low attack complexity [2][3].

The vulnerability is fixed in version 3.3.4 of the plugin. Users are strongly advised to update to this version or later to ensure TOTP tokens are invalidated after a single use [4].

AI Insight generated on May 20, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
born05/craft-twofactorauthenticationPackagist
< 3.3.43.3.4

Affected products

3

Patches

1
89d2339463c0

fix: Corrected the single use token time window

1 file changed · +14 6
  • src/services/Verify.php+14 6 modified
    @@ -183,9 +183,7 @@ private function getUserRecord(User $user)
          */
         private function isTokenUsed($token, User $user): bool
         {
    -        $settings = TwoFactorAuth::$plugin->getSettings();
    -        $delay = is_int($settings->totpDelay) ? $settings->totpDelay : 0;
    -        $start = new \DateTime("-$delay seconds");
    +        $start = $this->getTotpStartTime();
     
             // Find the token used by user in the current window.
             $userTokenRecord = UserTokenRecord::find()
    @@ -230,9 +228,7 @@ private function insertToken($token, User $user)
          */
         public function removeOldTokens(User $user)
         {
    -        $settings = TwoFactorAuth::$plugin->getSettings();
    -        $delay = is_int($settings->totpDelay) ? $settings->totpDelay : 0;
    -        $start = new \DateTime("-$delay seconds");
    +        $start = $this->getTotpStartTime();
     
             $userTokenRecords = UserTokenRecord::find()
                 ->where([
    @@ -245,4 +241,16 @@ public function removeOldTokens(User $user)
                 $userTokenRecord->delete();
             }
         }
    +
    +    /**
    +     * Get TOTP start time
    +     * @return \DateTime
    +     */
    +    private function getTotpStartTime(): \DateTime
    +    {
    +        $settings = TwoFactorAuth::$plugin->getSettings();
    +        $delay = is_int($settings->totpDelay) ? $settings->totpDelay : 0;
    +        $window = 31 + $delay; // Default window is 30 seconds, but we add 1 second to be sure.
    +        return new \DateTime("-$window seconds");
    +    }
     }
    

Vulnerability mechanics

Generated on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

7

News mentions

0

No linked articles in our index yet.