A critical vulnerability in Mautic, an open-source marketing automation platform used by over 200,000 organizations, has been identified by the SonicWall Capture Labs threat research team.
This vulnerability tracked as CVE-2024-47051, allows low-privileged authenticated users to upload malicious files, potentially leading to remote code execution (RCE) and arbitrary file deletion.
The vulnerability has a critical CVSS score of 9.1, highlighting its severe impact.
Technical Overview
The vulnerability arises from a logical flaw in the file upload functionality, specifically in the preUpload()
and upload()
functions.
These functions are responsible for handling file uploads when users add or edit assets.
The flaw allows attackers to bypass file extension restrictions by modifying the originalFileName
parameter to include a .php
extension, even if the file is uploaded with an allowed extension like .jpg
.
Code Snippet Example:
In a typical PHP-based file upload scenario, the preUpload()
function might look something like this:
phppublic function preUpload($file)
{
// Generate filename using SHA1 sum
$filename = sha1($file['name']);
// Attempt to guess the extension based on MIME type
$extension = $this->guessExtension($file['type']);
// If guessExtension returns NULL, use the extension from the original file name
if (!$extension) {
$extension = pathinfo($file['name'], PATHINFO_EXTENSION);
}
return $filename . '.' . $extension;
}
An attacker could exploit this by uploading a file named shell1.jpg
containing PHP code and then modifying the request to change the extension to .php
, allowing the file to be saved with a .php
extension.
Exploitation Steps
- Network Access and Permissions: The attacker must have network access to the vulnerable Mautic system and permissions to manage assets.
- Upload Malicious File: Upload a file containing PHP code with an allowed extension (e.g.,
.jpg
). - Modify Request: Intercept and modify the
originalFileName
parameter to include a.php
extension when sending the save asset request. - Access Uploaded File: Attempt to access the uploaded PHP file to execute the code.
Mitigation and Remediation
While the SonicWall team encountered a “403 Forbidden” response in their Docker-based test environment due to default Apache .htaccess
security measures, manual installations might still be vulnerable if configured to allow access to .php
files.
Therefore, users must update their Mautic instances to version 5.2.3 or later, as recommended by the vendor advisory.
SonicWall Protections:
To protect against potential exploitation, SonicWall has released the following signatures:
- IPS: 20803 Mautic Arbitrary File Upload
- IPS: 20805 Mautic Arbitrary File Upload
- IPS: 20806 Mautic Arbitrary File Deletion
The CVE-2024-47051 vulnerability poses a significant risk to organizations using Mautic, as it allows authenticated users to execute arbitrary code and delete files.
Given the widespread use of Mautic and the severity of this vulnerability, immediate action is necessary to prevent exploitation.
Users should update their Mautic installations to the latest version and ensure that their security configurations prevent unauthorized access to uploaded files.
Also Read: