backscatter: rescue by penpals not working anymore

Simon Klempert simon at klempert.net
Tue Oct 18 11:45:54 CEST 2016


Hi,

I discovered a problem with the backscatter protection handling in amavisd 2.11.0 (and some older version). In check_mail if $bounce_killer_score > 0, backscatter should be rescued by penpal database (bounce contains msgid which is in penpal database). This was working in some of the previous versions.

Unfortunately this is not working anymore. The rescue by penpals if statement (line 15028) will never be triggered anymore. This is because the pp_age is defined twice (as my) in different scopes. The variable
  my $pp_age;
defined in line 14922 will never be assigned a value, because it is hidden by the second definition of this variable in line 14967
  my $pp_age = $r->recip_penpals_age;

But the if statement
  if (defined $pp_age && $pp_age < 8*24*3600) {  # less than 8 days ago
in line 15028 access the variable $pp_age from line 14922 (without it ever getting a value assigned, so it is always undefined)

For now I solved it with the patch below:

------------------------------------------------

--- amavisd.dist        2015-12-06 00:20:22.000000000 +0100
+++ amavisd     2016-10-17 18:21:06.760110881 +0200
@@ -14450,7 +14454,7 @@
     $max_spam_level = 0  if !defined $max_spam_level;

     $which_section = "penpals_check";
-    my $pp_age;
+    my $min_pp_age;

     if (!$redis_storage &&
         !(defined $sql_storage && $sql_store_info_for_all_msgs)) {
@@ -14518,6 +14522,9 @@

             $msginfo->checks_performed->{P} = 1;
             if (defined $pp_age) {  # found info about previous correspondence
+              if ((!defined $min_pp_age) || ($pp_age < $min_pp_age)) {
+                $min_pp_age = $pp_age;
+              }
               my $weight = exp(-($pp_age/$pp_halflife) * log(2));
               # weight is a factor between 1 and 0, representing
               # exponential decay: weight(t) = 1 / 2^(t/halflife)
@@ -14556,7 +14563,7 @@
     if ($bounce_header_fields_ref) {  # message looks like a DSN (= bounce)
       snmp_count('InMsgsBounce');
       my $bounce_rescued;
-      if (defined $pp_age && $pp_age < 8*24*3600) {  # less than 8 days ago
+      if (defined $min_pp_age && $min_pp_age < 8*24*3600) {  # less than 8 days ago
         # found by pen pals by a Message-ID in attachment and recip. address;
         # is a bounce, refers to our previous outgoing message, treat it kindly
         snmp_count('InMsgsBounceRescuedByPenPals');

------------------------------------------------

Please consider fixing this. Thanks!

Simon



More information about the amavis-users mailing list