Project

General

Profile

Actions

Feature #43484

closed

Detect attachment content type from file contents instead of trusting client-provided values

Added by Go MAEDA 10 months ago. Updated 18 days ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Attachments
Target version:
Resolution:
Fixed

Description

Redmine currently stores the content type of uploaded files based on the value provided by the client, such as web browsers and API clients. This approach is not reliable and can lead to incorrect or misleading MIME types, especially when the client declares a spoofed or incorrect type.

According to the OWASP File Upload Cheat Sheet, the Content-Type header for uploaded files cannot be trusted, because it is easy to spoof.

The attached patch changes the behavior so that Redmine no longer trusts the client-provided content type. Instead, it detects the content type by inspecting the actual file contents using Marcel.


Files

0001-Improve-Redmine-MockFile-to-better-mimic-File-behavi.patch (1.17 KB) 0001-Improve-Redmine-MockFile-to-better-mimic-File-behavi.patch Go MAEDA, 2026-03-04 10:03
0002-Stop-using-legacy-image-x-ms-bmp-MIME-type-for-BMP-f.patch (3.47 KB) 0002-Stop-using-legacy-image-x-ms-bmp-MIME-type-for-BMP-f.patch Go MAEDA, 2026-03-04 10:03
0003-Stop-using-legacy-application-x-pkcs7-signature-MIME.patch (1.92 KB) 0003-Stop-using-legacy-application-x-pkcs7-signature-MIME.patch Go MAEDA, 2026-03-04 10:03
0004-Detect-attachment-content-type-from-file-contents-in.patch (10.2 KB) 0004-Detect-attachment-content-type-from-file-contents-in.patch Go MAEDA, 2026-03-04 10:03
0001-Improve-Redmine-MockFile-to-better-mimic-File-behavi.patch (1.17 KB) 0001-Improve-Redmine-MockFile-to-better-mimic-File-behavi.patch Go MAEDA, 2026-08-05 12:10
0002-Stop-using-legacy-image-x-ms-bmp-MIME-type-for-BMP-f.patch (1.8 KB) 0002-Stop-using-legacy-image-x-ms-bmp-MIME-type-for-BMP-f.patch Go MAEDA, 2026-08-05 12:10
0003-Stop-using-legacy-application-x-pkcs7-signature-MIME.patch (1.92 KB) 0003-Stop-using-legacy-application-x-pkcs7-signature-MIME.patch Go MAEDA, 2026-08-05 12:10
0004-Show-the-same-file-type-icon-whether-the-content-typ.patch (9.58 KB) 0004-Show-the-same-file-type-icon-whether-the-content-typ.patch Go MAEDA, 2026-08-05 12:10
0005-Detect-attachment-content-type-from-file-contents-in.patch (11.8 KB) 0005-Detect-attachment-content-type-from-file-contents-in.patch Go MAEDA, 2026-08-05 12:10
0006-Send-an-attachment-inline-based-on-its-detected-cont.patch (2.5 KB) 0006-Send-an-attachment-inline-based-on-its-detected-cont.patch Go MAEDA, 2026-08-05 12:10

Related issues

Related to Redmine - Feature #43473: Reject file uploads when actual MIME type does not match the file extensionNewActions
Related to Redmine - Feature #44385: Replace MiniMime with Marcel in Redmine::MimeType for consistent MIME type lookupClosedGo MAEDAActions
Actions

Also available in: Atom PDF