SA Bugzilla – Bug 5878
IPV4_ADDRESS regexp matches ip.ad.dr.in-addr.arpa format
Last modified: 2010-02-01 11:26:07 UTC
Hi, via some recent testing. I saw that RCVD_NUMERIC_HELO was being fired when the helo detected by SA was of the form a.b.c.d.in-adddr.arpa (where a.b.c.d) was an ip address in reverse octect form I wrote the following test case which uses the constant IPV4_ADDRESS from the SA source to show this behaviour. #!/usr/bin/perl use strict; use warnings; use Test::More tests => 1; use constant IPV4_ADDRESS => qr/\b (?:1\d\d|2[0-4]\d|25[0-5]|\d\d|\d)\. (?:1\d\d|2[0-4]\d|25[0-5]|\d\d|\d)\. (?:1\d\d|2[0-4]\d|25[0-5]|\d\d|\d)\. (?:1\d\d|2[0-4]\d|25[0-5]|\d\d|\d) \b/ox; sub check_ipv4 { my ($rcvd) = @_ ; my $IP_ADDRESS = IPV4_ADDRESS; if ($rcvd =~ /helo=($IP_ADDRESS)\b/i) { return 1; } return 0; } my $helostring = "helo=242.8.168.192.in-addr.arpa"; ok(check_ipv4($helostring) == 1);
Created attachment 4383 [details] Correct ip address boundary check
Created attachment 4384 [details] Correct ip address boundary check
My site has encountered a false positive because of this bug. (Aside: I am not sure if bug#5767 is related or not - it is not reproducible.) I don't think the problem here is IPV4_ADDRESS, but rather the way that check_for_numeric_helo() uses it. The code uses $rcvd =~ /helo=($IP_ADDRESS)\b/i but \b matches dots inside hostnames not the ends of hostnames. It should be a space instead. Patch attached.
I got a bunch of similar FP's with RCVD_NUMERIC_HELO today; a bunch of my staff was staying at the same hotel, and using the hotel's internet service. [30294] dbg: rules: ran header rule HELO_DYNAMIC_IPADDR2 ======> got hit: "[ ip=66.238.164.2 rdns=66.238.164.2.ptr.us.xo.net helo=154.3.168.192.in-addr.arpa.noptr.antlabs.com by=magus.merit.edu ident= envfrom= intl=0 id=ADD7B225CEB auth= " The actual Received line is: Received: from 154.3.168.192.in-addr.arpa.noptr.antlabs.com (66.238.164.2.ptr.us.xo.net [66.238.164.2]) by magus.merit.edu (Postfix) with ESMTP id ADD7B225CEB; Thu, 11 Dec 2008 22:40:02 -0500 (EST) Tony's analysis seems correct to me. I'm not sure if there's something better than using a literal space in the regexp (\s instead perhaps?) but \b is clearly wrong. thanks all for all your hard work on SA.
If it is still broken, it should be fixed for 3.3.0.
Created attachment 4516 [details] Suggested patch
Bug 5878: IPV4_ADDRESS regexp matches ip.ad.dr.in-addr.arpa format (attempting a fix; do we have any tests for this?) Sending lib/Mail/SpamAssassin/Plugin/RelayEval.pm Committed revision 803940.
(In reply to comment #7) > Bug 5878: IPV4_ADDRESS regexp matches ip.ad.dr.in-addr.arpa format > (attempting a fix; do we have any tests for this?) yep, I think we do. t/ip_addrs.t
closing
*** Bug 6256 has been marked as a duplicate of this bug. ***