A newly discovered vulnerability in the PHP-based Craft CMS, tracked as CVE-2024-56145, allows unauthenticated attackers to execute remote code on affected systems. This flaw, which affects default PHP configurations, poses a significant threat to the more than 150,000 websites running the platform globally. The issue arises from an insecure implementation of PHP’s register_argc_argv configuration, which populates the $_SERVER[‘argv’] variable using query string parameters and can be exploited by malicious actors.
The vulnerability lies in Craft CMS’s bootstrap process, where the App::cliOption function checks for command-line options without confirming if the application is running in a command-line environment. Exploiting this flaw, attackers can manipulate the –templatesPath parameter to force the CMS to load template files from an attacker-controlled FTP server. Security researchers at Assetnote demonstrated how this technique bypasses typical security measures, allowing attackers to execute malicious code remotely.
To exploit the flaw, attackers set up an anonymous FTP server and create malicious Twig template files, which Craft CMS loads during the rendering process. The attack chain also involves bypassing sandboxing attempts through clever filter manipulation, enabling full system compromise. The vulnerability affects Craft CMS versions prior to 5.5.2 and 4.13.2, leaving outdated systems particularly vulnerable to remote code execution.
The Craft CMS team acted quickly, releasing patches for the vulnerability within 24 hours of its disclosure. Site administrators are strongly urged to update to versions 5.5.2 or 4.13.2 immediately. For those unable to upgrade, disabling the register_argc_argv setting in the php.ini configuration file offers temporary mitigation. This incident underscores the importance of proactive security measures, regular software updates, and vigilance in managing potentially risky PHP configurations to safeguard web applications from emerging threats.
Reference: