From 83562258eb5fab56eb68da79a9d3fcacc7b8f5b7 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 25 Apr 2017 13:44:16 +0100 Subject: [PATCH] [Feature] Add rules to detect bad 8bit characters in From and To --- rules/headers_checks.lua | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/rules/headers_checks.lua b/rules/headers_checks.lua index 28409f276..ebe3e0aa0 100644 --- a/rules/headers_checks.lua +++ b/rules/headers_checks.lua @@ -918,3 +918,39 @@ rspamd_config.CTYPE_MIXED_BOGUS = { score = 0.1, group = 'headers' } + +local function is_8bit_addr(addr) + if addr.flags and addr.flags['8bit'] then + return true + end + + return false; +end + +rspamd_config.INVALID_FROM_8BIT = { + callback = function(task) + local from = (task:get_from('mime') or {})[1] or {} + if is_8bit_addr(from) then + return true + end + return false + end, + description = 'Invalid 8bit character in From header', + score = 6.0, + group = 'headers' +} + +rspamd_config.INVALID_RCPT_8BIT = { + callback = function(task) + local rcpts = task:get_recipients('mime') or {} + return fun.any(function(rcpt) + if is_8bit_addr(rcpt) then + return true + end + return false + end, rcpts) + end, + description = 'Invalid 8bit character in recipients headers', + score = 6.0, + group = 'headers' +} \ No newline at end of file -- 2.39.5