Bug 6460 - [review] RCVD_ILLEGAL_IP false positives with numerically-named relays
Summary: [review] RCVD_ILLEGAL_IP false positives with numerically-named relays
Status: RESOLVED FIXED
Alias: None
Product: Spamassassin
Classification: Unclassified
Component: Rules (show other bugs)
Version: 3.3.1
Hardware: PC Linux
: P1 critical
Target Milestone: 3.3.2
Assignee: SpamAssassin Developer Mailing List
URL:
Whiteboard: needs 1 vote for 3.3
Keywords:
Depends on:
Blocks: 6467 6516
  Show dependency tree
 
Reported: 2010-07-02 09:37 UTC by Phil Randal
Modified: 2010-12-28 09:27 UTC (History)
6 users (show)



Attachment Type Modified Status Actions Submitter/CLA Status
Remove newly allocated and to-be-allocated IANA address ranges from the rule patch None Mark Martinec [HasCLA]

Note You need to log in before you can comment on or make changes to this bug.
Description Phil Randal 2010-07-02 09:37:11 UTC
The rule RCVD_ILLEGAL_IP seems to fire erroneously

From debug:

Jul  2 14:28:07.473 [9951] dbg: metadata: X-Spam-Relays-Untrusted: [ ip=80.249.108.233 rdns=233.ncuk.mta.dotmailer.co.uk helo=233.ncuk.mta.dotmailer.co.uk by=mx1.herefordshire.gov.uk ident= envfrom= intl=0 id=o62DG6UR005877 auth= msa=0 ] [ ip=10.0.12.33 rdns=dmdroid201 helo=dmdroid201 by=233.ncuk.mta.dotmailer.co.uk ident= envfrom=bo-BS7-6WPZ-1O40MT-BYTT8@itsmfnews.co.uk intl=0 id=h5nj4g0vbl8d auth= msa=0 ]


The rule:

header RCVD_ILLEGAL_IP         X-Spam-Relays-Untrusted =~ / (?:by|ip)=(?:[05]|14|23|3[1679]|4[29]|1(?:0[0-6]|7[679]|8[15])|2(?:2[3-9]|[3-5]\d)|169\.254|192\.0\.2|198\.51\.100|203\.0\.113)\./

As the score for this is 3.399, it is creating a few too many false positives here.

(sa-update reposrts version 953612)
Comment 1 John Wilcock 2010-07-02 10:11:09 UTC
Hmm, I'm seeing similar occasional FPs here with numerically-named mail relays. Example:

dbg: metadata: X-Spam-Relays-Untrusted: [ ip=213.186.36.34 rdns=5.mail-out.ovh.net helo=5.mail-out.ovh.net by=extranet.tradoc.fr ident= envfrom= intl=0 id=79A4E334033 auth= msa=0 ] [ ip=213.186.33.62 rdns=a2.ovh.net helo=mozg.ha.ovh.net by=5.mail-out.ovh.net ident= envfrom= intl=0 id= auth= msa=0 ]
dbg: rules: ran header rule RCVD_ILLEGAL_IP ======> got hit: " by=5."


I'd suggest that the regex needs to ensure that it is hitting on an IP address rather than a host name that happens to start with a number and a dot.
Comment 2 Phil Randal 2010-07-02 10:28:57 UTC
(In reply to comment #1)
> Hmm, I'm seeing similar occasional FPs here with numerically-named mail relays.
> Example:
> 
> dbg: metadata: X-Spam-Relays-Untrusted: [ ip=213.186.36.34
> rdns=5.mail-out.ovh.net helo=5.mail-out.ovh.net by=extranet.tradoc.fr ident=
> envfrom= intl=0 id=79A4E334033 auth= msa=0 ] [ ip=213.186.33.62 rdns=a2.ovh.net
> helo=mozg.ha.ovh.net by=5.mail-out.ovh.net ident= envfrom= intl=0 id= auth=
> msa=0 ]
> dbg: rules: ran header rule RCVD_ILLEGAL_IP ======> got hit: " by=5."
> 
> 
> I'd suggest that the regex needs to ensure that it is hitting on an IP address
> rather than a host name that happens to start with a number and a dot.

That's exactly it.

We've has 395 rule hits (on corpus of 55253) over the last 39.5 hours, ALL false-positives.
Comment 3 Phil Randal 2010-07-14 15:54:20 UTC
Latest mass checks:

RCVD_ILLEGAL_IP:  bad, avg S/O=0.67 avg Spam%=0.11 avg Ham%=0.05

It will do badly until it is fixed...
Comment 4 Karsten Bräckelmann 2010-07-23 10:06:45 UTC
(In reply to comment #1)
> I'd suggest that the regex needs to ensure that it is hitting on an IP address
> rather than a host name that happens to start with a number and a dot.

Inserting a positive look-ahead after the equal in the RE would do, only accepting an IP by ensuring a space as delimiter.
  /(?=\d+\.\d+\.\d+\.\d+ )/

Another approach would be, to append a trailing part to the RE, enforcing only IP style, non-hostname chars until the delimiting space.
  /[0-9.]+ /

Devs, comments, thoughts?
Comment 5 Karsten Bräckelmann 2010-07-23 11:05:16 UTC
Went ahead with the first variant, which is more elegant IMHO. Committed to trunk, along with the fix for bug 6465. Please vote for 3.3.

Ensure RCVD_ILLEGAL_IP only matches on IPs, bug 6460.  Remove 169.254/16
assigned as "link local" block, bug 6465.

Sending        rules/20_head_tests.cf
Transmitting file data .
Committed revision 967120.
Comment 6 Mark Martinec 2010-11-30 14:34:23 UTC
> Went ahead with the first variant, which is more elegant IMHO. Committed to
> trunk, along with the fix for bug 6465. Please vote for 3.3.
> Ensure RCVD_ILLEGAL_IP only matches on IPs, bug 6460.  Remove 169.254/16
> assigned as "link local" block, bug 6465.

+1
Comment 7 Kevin A. McGrail 2010-11-30 14:44:07 UTC
(In reply to comment #6)
> > Went ahead with the first variant, which is more elegant IMHO. Committed to
> > trunk, along with the fix for bug 6465. Please vote for 3.3.
> > Ensure RCVD_ILLEGAL_IP only matches on IPs, bug 6460.  Remove 169.254/16
> > assigned as "link local" block, bug 6465.
> 
> +1

This regex has gotten so complex I am wondering if a test case should be created for it?

I can't really read it fast enough anymore to know what it should and shouldn't be hitting on to vote without writing a test stub.

Regards,
KAM
Comment 8 Mark Martinec 2010-11-30 14:52:52 UTC
> This regex has gotten so complex I am wondering if a test case should be
> created for it?

Maybe it should just be dropped or restricted to private address space,
considering that IANA Unallocated Address Pool Exhaustion is estimated
for March 2011, and considering the 'fast' deployment rate of SA in
various distributions. The next allocation blocks released are about
to happen at a steady rate, so the rule is just waiting for its next
round of false positives.
Comment 9 AXB 2010-11-30 16:33:33 UTC
(In reply to comment #8)
> > This regex has gotten so complex I am wondering if a test case should be
> > created for it?
> 
> Maybe it should just be dropped or restricted to private address space,
> considering that IANA Unallocated Address Pool Exhaustion is estimated
> for March 2011, and considering the 'fast' deployment rate of SA in
> various distributions. The next allocation blocks released are about
> to happen at a steady rate, so the rule is just waiting for its next
> round of false positives.

+1 to restricted to private address space only
Comment 10 Mark Martinec 2010-11-30 18:23:17 UTC
Created attachment 4828 [details]
Remove newly allocated and to-be-allocated IANA address ranges from the rule

As it turns out, even now the rule triggers on several newly-allocated
address ranges, causing false positives.

The patch strips off all already allocated and to-be-allocated
address ranges from the rule, leaving only the:
- 0.0.0.0/8 self-identification network
- multicast addresses
- all three 'test' networks
Comment 11 Kevin A. McGrail 2010-11-30 18:31:45 UTC
(In reply to comment #10)
> Created an attachment (id=4828) [details]
> Remove newly allocated and to-be-allocated IANA address ranges from the rule
> 
> As it turns out, even now the rule triggers on several newly-allocated
> address ranges, causing false positives.
> 
> The patch strips off all already allocated and to-be-allocated
> address ranges from the rule, leaving only the:
> - 0.0.0.0/8 self-identification network
> - multicast addresses
> - all three 'test' networks

AXB's comment was +1 for private use networks which doesn't make sense to me since theoretically those should always be trusted, yes?

Since your rule doesn't hit 192.168.X or 10.X, I think you covered what makes sense to me.

+1 KAM
Comment 12 Mark Martinec 2010-11-30 18:37:23 UTC
trunk:
  Bug 6460: RCVD_ILLEGAL_IP false positives
Sending rules/20_head_tests.cf
Committed revision 1040826.


I keep forgetting: is the rules directory now supposed to be
common between branches? If so, I wonder why Günther's previous
fix to this rule is only seen in trunk.
Comment 13 Mark Martinec 2010-11-30 18:40:40 UTC
> AXB's comment was +1 for private use networks which doesn't make sense to me
> since theoretically those should always be trusted, yes?

Yes, sorry, my fault, my misleading statement. The rule has nothing to do
with private networks. It covers self, multicast and test networks, and
previously also covered unallocated IANA networks, which are going away
in the following months.
Comment 14 AXB 2010-12-01 02:51:06 UTC
(In reply to comment #11)
> (In reply to comment #10)
> > Created an attachment (id=4828) [details] [details]
> > Remove newly allocated and to-be-allocated IANA address ranges from the rule
> > 
> > As it turns out, even now the rule triggers on several newly-allocated
> > address ranges, causing false positives.
> > 
> > The patch strips off all already allocated and to-be-allocated
> > address ranges from the rule, leaving only the:
> > - 0.0.0.0/8 self-identification network
> > - multicast addresses
> > - all three 'test' networks
> 
> AXB's comment was +1 for private use networks which doesn't make sense to me
> since theoretically those should always be trusted, yes?
> 
> Since your rule doesn't hit 192.168.X or 10.X, I think you covered what makes
> sense to me.
> 
> +1 KAM

you're right, should have specified:
+1 not including non allocated IANA space in the rule.
Comment 15 Mark Martinec 2010-12-04 18:59:35 UTC
(In reply to comment #12)
> trunk:
>   Bug 6460: RCVD_ILLEGAL_IP false positives
> Sending rules/20_head_tests.cf
> Committed revision 1040826.
> 
> I keep forgetting: is the rules directory now supposed to be
> common between branches? If so, I wonder why Günther's previous
> fix to this rule is only seen in trunk.

Apparently the 3.3 rules are now decoupled from trunk rules !?

Ending this frustration with the RCVD_ILLEGAL_IP rule misfiring
by manually backporting this rule change to 3.3:

3.3:
  Bug 6460: RCVD_ILLEGAL_IP false positives
Sending rules/20_head_tests.cf
Committed revision 1042265.

If this change ends up in 3.3 sa-updates, this bug report can be closed,
otherwise it should be investigated as soon as possible.
Bumping up priority.
Comment 16 Warren Togami 2010-12-26 01:45:13 UTC
What will it take to make this go into 3.3 sa-updates?
Comment 17 Mark Martinec 2010-12-28 09:27:40 UTC
> What will it take to make this go into 3.3 sa-updates?

As far as I can tell, the fix is already in 3.3 and 3.4 updates.
Closing.  Please reopen if someone thinks otherwise.