Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: OpenID Connect / OAuth client 3.0.0-alpha9 New alpha version released for module openid_connect (3.0.0-alpha9). Release: Opensolr Search 4.5.0 Minor update available for module opensolr_search (4.5.0). Release: Timelinr 1.0.1 Minor update available for module timelinr (1.0.1). Usage Milestone: Simplify Module simplify crossed 10,000 active installs. Usage Milestone: Views Reference Filter Module entityreference_filter crossed 10,000 active installs. Usage Milestone: Dropdown Language Module dropdown_language crossed 10,000 active installs. Usage Milestone: Paragraphs Browser Module paragraphs_browser crossed 10,000 active installs. Usage Milestone: OpenAPI Module openapi crossed 10,000 active installs. Usage Milestone: Decoupled Router Module decoupled_router crossed 10,000 active installs. Module Revived: Entityqueue Buttons 1.1.2 Module entityqueue_buttons updated after 8 months of inactivity (1.1.2).

File Mime Type Enforcer

9 sites No security coverage Drupal 10–11
View on drupal.org

This module enhances file upload security by allowing administrators to configure acceptable MIME types for different file extensions through a user interface. It compares the file's extension with its actual content, blocking or logging mismatches to prevent malicious file uploads. The module also includes a Drush command to audit existing files on the system for any MIME type discrepancies.

The File Mime Type Enforcer module allows for easy UI configuration in the JSON format. Each supported file extension is mapped to alternative file mime types to enhance file security during uploads. Additionally, the module features a drush command to audit existing files local to the system and will generate log entries for any failed validations as well as display them onscreen, if so desired..

Features

  • Dual MIME Detection: Compares Drupal's extension-based detection with Symfony's content-based analysis
  • Security Protection: Blocks files where extension doesn't match actual content (e.g., PHP files renamed as .jpg)
  • Configurable Alternatives: Define acceptable MIME type variations per file extension
  • Flexible Validation: Strict mode (reject mismatches) or permissive mode (log only)
  • Audit Command: Scan existing files for MIME type discrepancies

Post-Installation

Enable the module via drush en file_mime_type_enforcer or at /admin/modules and modify the configuration at /admin/config/media/file-mime-type-enforcer.

Additional Requirements

This module requires the PHP fileinfo extension. You can verify if it is installed with php -m | grep fileinfo

Similar projects

The File Upload Secure Validator module also utilizes the PHP fileinfo library, but features a different method of configuration. The File Mime Type Enforcer module configuration maps the supported file extensions to their respective alternative mapping and in addition also includes a drush command for auditing of existing files within the system (if needed).

Depends on

Dependencies of the latest stable release

  • file Drupal core
  • system Drupal core

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
4
Tracked since
Sep 2025
Latest release
1 month ago
Releases (12 mo)
4 ▲ from 0
Maintenance
Active

Release Timeline

Releases

Version Type Core Release date
1.4.0 Stable 10–11 Jul 7, 2026
1.3.2 Stable 9–10 Nov 4, 2025
1.0.0 Stable 9–10 Oct 8, 2025
1.0.x-dev Dev 10–11 Sep 26, 2025