commit 7d14e4a: [Enhancement] Exclude false positives of MIME_DOUBLE_BAD_EXTENSION

GitHub noreply at github.com
Mon Jul 29 17:55:33 UTC 2024


Author: Dmitriy Alekseev
Date: 2024-04-11 19:17:08 +0300
URL: https://github.com/rspamd/rspamd/commit/7d14e4af43ee1435b47a5d38b699b24bf598d4bf (refs/pull/4920/head)

[Enhancement] Exclude false positives of MIME_DOUBLE_BAD_EXTENSION
If we detected extension of the file and this extension is equal to the real extension then we should not pass second extension to check function as it will trigger false positive for MIME_DOUBLE_BAD_EXTENSION.
---
 src/plugins/lua/mime_types.lua | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/plugins/lua/mime_types.lua b/src/plugins/lua/mime_types.lua
index 167ed38e2..71b6481d8 100644
--- a/src/plugins/lua/mime_types.lua
+++ b/src/plugins/lua/mime_types.lua
@@ -397,7 +397,12 @@ local function check_mime_type(task)
       if ext2 then
         local score1 = check_tables(ext)
         local score2 = check_tables(ext2)
-        check_extension(score1, score2)
+        -- Check if detected extension match real extension
+        if detected_ext and detected_ext == ext then
+            check_extension(score1, nil)
+        else
+            check_extension(score1, score2)
+        end
         -- Check for archive cloaking like .zip.gz
         if settings['archive_extensions'][ext2]
             -- Exclude multipart archive extensions, e.g. .zip.001


More information about the Commits mailing list