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. Learn more

Threat Intelligence

Exploit Maturity
Proof of concept
EPSS
0.25% (66th 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 Learn

Learn about Remote Code Execution (RCE) vulnerabilities in an interactive lesson.

Start learning
  • Snyk IDSNYK-PHP-CRAFTCMSCMS-5595548
  • published23 May 2023
  • disclosed22 May 2023
  • creditawakerrday

Introduced: 22 May 2023

CVE-2023-32679  (opens in a new tab)
CWE-94  (opens in a new tab)

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