]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
[Fix] Don't perform forged recipients check for missing recipients
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 19 Oct 2018 16:47:02 +0000 (17:47 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Fri, 19 Oct 2018 16:47:02 +0000 (17:47 +0100)
src/plugins/lua/forged_recipients.lua

index 887b1bf822032597b73792abb0353d737cf37aab..8abc55a503b1c3f6281276851d3b55936c283838 100644 (file)
@@ -40,36 +40,38 @@ local function check_forged_headers(task)
   if not mime_rcpt then
     return
   elseif #mime_rcpt == 0 then
-    local sra = smtp_rcpt[1].addr .. (#smtp_rcpt > 1 and ' ...' or '')
-    task:insert_result(symbol_rcpt, score, '', sra)
     return
   end
   -- Find pair for each smtp recipient in To or Cc headers
   for _,sr in ipairs(smtp_rcpt) do
     res = false
     for _,mr in ipairs(mime_rcpt) do
-      if mr['addr'] and sr['addr'] and
-        string.lower(mr['addr']) == string.lower(sr['addr']) then
+      if mr.addr and mr.addr ~= '' then
+        if sr['addr'] and
+            string.lower(mr['addr']) == string.lower(sr['addr']) then
+          res = true
+          break
+        elseif delivered_to and delivered_to == mr['addr'] then
+          -- allow alias expansion and forwarding (Postfix)
+          res = true
+          break
+        elseif auser and auser == sr['addr'] then
+          -- allow user to BCC themselves
+          res = true
+          break
+        elseif ((smtp_from or E)[1] or E).addr and
+            smtp_from[1]['addr'] == sr['addr'] then
+          -- allow sender to BCC themselves
+          res = true
+          break
+        elseif mr['user'] and sr['user'] and
+            string.lower(mr['user']) == string.lower(sr['user']) then
+          -- If we have the same username but for another domain, then
+          -- lower the overall score
+          score = score / 2
+        end
+      else
         res = true
-        break
-      elseif delivered_to and delivered_to == mr['addr'] then
-        -- allow alias expansion and forwarding (Postfix)
-        res = true
-        break
-      elseif auser and auser == sr['addr'] then
-        -- allow user to BCC themselves
-        res = true
-        break
-      elseif ((smtp_from or E)[1] or E).addr and
-          smtp_from[1]['addr'] == sr['addr'] then
-        -- allow sender to BCC themselves
-        res = true
-        break
-      elseif mr['user'] and sr['user'] and
-        string.lower(mr['user']) == string.lower(sr['user']) then
-        -- If we have the same username but for another domain, then
-        -- lower the overall score
-        score = score / 2
       end
     end
     if not res then