Drupal Core Unrestricted File Upload Vulnerability
Summary
GHSA-7gwj-7fhm-vw4w: Drupal core unrestricted file upload. Affects drupal/core across 2 version ranges.
>= 8.0.0, < 8.7.11
>= 8.8.0, < 8.8.1
Fixed in 8.7.11 or 8.8.1, depending on the release line you run. How to fix ↓
Check if this vulnerability affects your application
Upload a manifest or SBOM and we'll show whether you're affected, plus every other risky package in the same scan.
No signup required · Results in about 60 seconds
Background
Drupal is a popular open-source content management system (CMS) written in PHP. It provides a flexible platform for building websites and applications. The Drupal core package is the foundation of the CMS and includes essential features and functionality. However, a vulnerability has been discovered in the file upload functionality of Drupal core.
Vulnerability Detail
The vulnerability in Drupal core's file_save_upload() function allows users with the ability to upload files to bypass protections provided by Drupal's default .htaccess file. The file_save_upload() function does not strip the leading and trailing dot ('.') from filenames, which can be exploited by users to upload system files such as .htaccess. This can potentially lead to unauthorized access or manipulation of the Drupal installation. The vulnerability affects versions 8.0.0 to 8.7.11 and 8.8.0 to 8.8.1 of the Drupal core package.
How To Fix
Fixed versions by release line
The minimum fixed version depends on the release line you run.
-
>= 8.0.0, < 8.7.118.7.11composer require drupal/core:8.7.11 -
>= 8.8.0, < 8.8.18.8.1composer require drupal/core:8.8.1
Tip — Not sure which release line you're on? Vulert can find the fix for the version you are using. Scan free →
Workaround
If updating the Drupal core package is not immediately possible, a temporary workaround is to implement a custom validation function for file uploads that explicitly checks for and rejects filenames with leading or trailing dots. Here is an example of a validation function in PHP:
function custom_file_upload_validation(array &$file) {
$filename = $file['name'];
if (strpos($filename, '.') === 0 || strrpos($filename, '.') === strlen($filename) - 1) {
$file['error'] = UPLOAD_ERR_EXTENSION;
}
}
Conclusion
The Drupal core unrestricted file upload vulnerability allows users to upload system files and bypass Drupal's default protections. It is crucial to update the Drupal core package to the recommended versions to mitigate this vulnerability. Implementing the provided workaround can serve as a temporary solution until the update is applied. For further support and assistance in vulnerability remediation, you can reach out to DevNack.com.
See every vulnerability recorded for drupal/core →
FAQ
This vulnerability allows users to upload system files such as .htaccess, bypassing Drupal's default protections. This can potentially lead to unauthorized access or manipulation of the Drupal installation.
Versions 8.0.0 to 8.7.11 and 8.8.0 to 8.8.1 of the Drupal core package are affected.
To fix this vulnerability, update the Drupal core package to version 8.7.12 or later (for versions 8.0.0 to 8.7.11) or version 8.8.2 or later (for versions 8.8.0 to 8.8.1).
A temporary workaround is to implement a custom validation function for file uploads that explicitly checks for and rejects filenames with leading or trailing dots. See the 'workaround' section for an example.
You can find more information about this vulnerability, including the technical details and the fix, in the advisory on the GitHub Advisory Database: https://github.com/github/advisory-database/blob/main/advisories/github-reviewed/2024/05/GHSA-7gwj-7fhm-vw4w/GHSA-7gwj-7fhm-vw4w.json
References
Related vulnerabilities
Recent vulnerabilities recorded for drupal/core.