Remote Code Execution (RCE) Affecting craftcms/cms package, versions >=4.0.0, <4.4.6


Severity

Recommended
0.0
high
0
10

CVSS assessment made by Snyk's Security Team

    Threat Intelligence

    Exploit Maturity
    Proof of concept
    EPSS
    0.23% (62nd 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-5595548
  • published 23 May 2023
  • disclosed 22 May 2023
  • credit awakerrday

How to fix?

Upgrade craftcms/cms to version 4.4.6 or higher.

Overview

craftcms/cms is a content management system.

Affected versions of this package are vulnerable to Remote Code Execution (RCE) due to not restricting file extensions for templates to only the expected defaultTemplateExtensions = ['html', 'twig']. This allows privileged users with ALLOW_ADMIN_CHANGES=true set to upload and execute arbitrary code. If the name parameter value is not an empty string in the _resolveTemplate() function it returns directly without extension verification.

PoC

  1. Create a new filesystem with Base Path /var/www/html/templates

  2. Create a new asset volume with Asset Filesystem template

  3. Upload payload in a twig template

{{'<pre>'}}
{{['cat /etc/passwd']|map('passthru')|join}}
{{['id;pwd;ls -altr /']|map('passthru')|join}}
  1. Create a new global set with template layout using the filename of the file just uploaded

  2. Access the global menu or /admin/global/test

CVSS Scores

version 3.1
Expand this section

Snyk

Recommended
7.2 high
  • Attack Vector (AV)
    Network
  • Attack Complexity (AC)
    Low
  • Privileges Required (PR)
    High
  • User Interaction (UI)
    None
  • Scope (S)
    Unchanged
  • Confidentiality (C)
    High
  • Integrity (I)
    High
  • Availability (A)
    High
Expand this section

NVD

7.2 high