To SPF or not to SPF

Since many people keep asking about SPF, I thought I'd publish a few facts gathered from my own experience on servers managed by myself. These are just facts and some personal thoughts. I will not get into any "evangelistic" discussions about SPF.

Although to me it was clear from the beginning that SPF is not a solution I thought I'd give it a try to gather some real world data. In order to be able to analyse the information better, I used a server that has a decent amount of load, but is not exaggeratedly busy.

Basic components used:
Mac OS X 10.4.8 with latest security updates.
Postfix 2.1.5
amavisd 2.4.4
SpamAssassin 3.1.7
ClamAV 0.88.7 with clamd instead of clamscan

SPF related components used:
Mail::SPF and Mail::SPF::Query (tried both in seperate moments)
postfix-policyd-spf-perl (a perl script that calls above PERL script(s) and is used together with postfix' policy server)

I modified postfix-policyd-spf-perl so that it only logs it's "findings", but never actually blocks mail.


Configuration:
I lowered all SPF related SpamAssassin scores to 0.001, because I just wanted to see what gets triggered, but was not interested in action being taken.

SpamAssassin has a well trained Bayes database, all necessary fixes and some additional rules (the same rules that get installed by "spamtrainer -a").

Postfix was configured to reject as much spam as possible before even calling a content filter. (Based on what I published in my document "Frontline spam defense for Mac OS X Server")

The policy server is called after all other checks are done (this is very important, otherwise you can become an open relay if a spammer has actually published an SPF record). It is also more efficient on resources.

I configured the script to log/act on following conditions:
No SPF record = none (equals pass, because rejecting mail from domains without SPF records, basically means ludicrous amounts of false positives)

Correct SPF record and mail sender matches = pass

Correct SPF record but mail sender doesn't match = fail

DNS Errors while looking up = softfail (pass)


So much for the basic information, which is much longer than the statistical data gathered, but nonetheless important for a full picture.

Now to the data:
Test Period: 2 weeks
Average number of incoming mails per day: 32'000
Average number of rejected mails per day: 28'000
(Yes almost 90% of mail is spam or viruses)

Now the juicy bit. Out of the average of 28'000 mails caught by Postfix, ClamAV and SpamAssassin, how many do you think would NOT have been caught without SPF checking in place?:
100 or roughly 0.35%

I got "SPF fail" on an average of 208 mails. 108 of them had been caught by the other measures in place already.

So is this worth the effort and the extra hit on server and network resources? Hardly. At least not in my book.


Remarks:

Why is SPF praised, yet at the same time so inefficent?

The main problem is that it relies on domain owners publishing a voluntary SPF TXT DNS record. This record declares which servers may or may not send mail for said domain. It can be defined as a "strict" record (listing allowed machines and disallowing any other server) or as a "loose" record (listing allowed machines, but not excluding that other servers may send mail for the domain). Most published SPF records are not strict (google.com for example). Why? Because a domain's user on the move forced to use a different ISP's mail server would not be able to send mail anymore (yes I know you can always have different submission ports to prevent being blocked from accessing your own server, but not everybody does). Now when an SPF record is not "strict", rejecting mail not coming from designated servers, yields a very high risk of false positives and thus, most sysadmins will let it through (maybe with an increased SpamAssassin score, but that's about it).

Another problem is that an enormous amount of domains do not publish an SPF record at all (mac.com for example doesn't). Do you want to block those mails? Probably not.


Should I use SPF checking?

This is something you will have to decide for yourself. I am definitely not using it. On my servers it has proven to be an ineffective method of catching spam. It eats cpu cycles and does network roundtrips without a real benefit. It's not that the perl scripts and dns lookups bring my system to its knees, far from it, but I have a strict policy on wasting resources.


Should I publish an SPF record for my domain(s)?

Again, you will have to decide for yourself. Under normal circumstances a mail server will let your mail through even if you do not publish an SPF record. There are however some inept system administrators that do block mail from domains without an SPF record). In many cases, not having an SPF record is safer than having a strict one. I have decided to publish an SPF record for my domains. This doesn't mean I believe in it. It's just something that doesn't cost me any extra resources. Plus I have full control over my servers and do not rely on any ISP doing configuration work for me.


I didn't get into the technical tidbits about SPF's reliabilty, spoofing and so on. There is enough information on the internet on this. All I wanted was to illustrate a real world situation.

Feel free to post questions.

Alex

Mac OS X (10.4.8)

Posted on Jan 2, 2007 3:50 AM

Reply
20 replies

Jan 23, 2007 8:34 AM in response to pterobyte

Thanks, pterobyte, for the extensive tests on your server.

Anyway, I still feel that we should see it from an other perspective - the SPF tests could also take positive influence to the spam score of mails that are tagged by other tests as spam but aren't UCE.

So the combination of many different tests (static, network, intelligent ones) makes the accuracy of SpamAssassin in my mind. Of course, I agree to you that as more tests are running, as more network and CPU resources are required. Everybody should find its own weighting between the "amount of delivered spam" and the "required resources for fighting against".

I like to see SPF tests in combination with others as stated before; so let's take a real-world example that happened to me today (which was the reason for writing this reply 🙂

I have subscribed to XE's daily currency updates, which are regardless my efforts to fine-tune SpamAssassin, tagged with some "is-spam" tests.

Their today's mail I wouldn't have received without SPF tests installed, because as you see the overall spam score is 4.649. So the SPF tests helped to get the mail delivered (for your reference, please find the complete mail header below).

I'm not sure if you are interested in, nor if it is possible overall, to run another test drive figuring out how positive SPF tests are taking effect to spam scores (and so prevent false-positive mails).

Von: list@en.ucc.xe.net
Betreff: Today's Currency Update (EUR) CUS39DE8E7CA1E2
Datum: 23. Januar 2007 05:02:38 MEZ
An: info@starenterprise.com
Antwort an: currency@xe.com
Return-Path: <list@en.ucc.xe.net>
Received: from murder ([unix socket]) by starenterprise.com (Cyrus v2.2.12-OS X 10.4.8) with LMTPA; Tue, 23 Jan 2007 05:02:47 +0100
Received: from localhost (localhost [127.0.0.1]) by starenterprise.com (Postfix) with ESMTP id 7D60FDF32AD for <info@starenterprise.com>; Tue, 23 Jan 2007 05:02:46 +0100 (CET)
Received: from starenterprise.com ([127.0.0.1]) by localhost (starenterprise.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 24459-08 for <info@starenterprise.com>; Tue, 23 Jan 2007 05:02:41 +0100 (CET)
Received: from helium.xe.com (helium.xe.com [216.220.38.19]) by starenterprise.com (Postfix) with ESMTP id 7F481DF32A6 for <info@starenterprise.com>; Tue, 23 Jan 2007 05:02:40 +0100 (CET)
Received: from helium.xe.com (localhost [127.0.0.1]) by helium.xe.com (8.13.6/8.11.1) with SMTP id l0N42bcZ056676 for info@starenterprise.com; Mon, 22 Jan 2007 23:02:38 -0500 (EST) (envelope-from list@en.ucc.xe.net)
X-Sieve: CMU Sieve 2.2
Message-Id: <200701230402.l0N42bcZ056676@helium.xe.com>
Errors-To: Currency List <list@en.ucc.xe.net>
Content-Type: text/plain
X-Mailer: XE.com E-Mail Currency Update Service
X-Help-Page-Location: https://www.xe.com/cus/sample.htm
X-Subscriber-Id: CUS39DE8E7CA1E2
X-Spam-Status: No, hits=4.649 tagged_above=-999 required=5 tests=AWL, BAYES_99, HTML 2030, HTML_MESSAGE, HTML MISSINGCTYPE, RCVD IN_BSPTRUSTED, SPF HELOPASS, SPF_PASS
X-Spam-Level: **

Jan 23, 2007 8:48 AM in response to tobias Eichner

On a stock SA, the scores for 'good' SPF checks are probably not high enough to really make a difference to anything...

From 50_scores.cf...

# SPF
# Note that the benefit for a valid SPF record is deliberately minimal; it's
# likely that more spammers would quickly move to setting valid SPF records
# otherwise. The penalties for an incorrect record, however, are large. 😉
ifplugin Mail::SpamAssassin::Plugin::SPF
score SPF_PASS -0.001
score SPF_FAIL 0 0 0 0.875
score SPF_SOFTFAIL 0.500 0.842 0.500 0.500
score SPF HELOPASS -0.001
score SPF HELOFAIL 0 0.405 0 0.001
score SPF HELOSOFTFAIL 0 1.002 0 3.140
endif # Mail::SpamAssassin::Plugin::SPF

Whereas the BSP_TRUSTED test scores lot lower...

20 dnsbltests.cf:describe RCVD IN_BSPTRUSTED Sender is in Bonded Sender Program (trusted relay)
50_scores.cf:score RCVD IN_BSPTRUSTED 0 -4.3 0 -4.3

-david

Jan 23, 2007 8:47 AM in response to tobias Eichner

Tobias,

1. You are welcome.
2. I am not interested in running additional SPF tests.
3. If you have a particular issue you'd like to discuss or be helped with, please open a new thread.
4. If one subscribes to a mailing list which happens to send poorly formatted messages, one should whitelist the sender and not rely on SPF to bail the message out.
5. If you want to discuss 4., please open a new thread.
6.If you have comments pertinent to the testing methods (like Camelot had), you are welcome to continue in this thread.

Jan 23, 2007 8:59 AM in response to pterobyte

Thanks for your comments. Anyway, I believe that my replies are related to this topic, so why should I open a new thread ? This just confuses the reader.
The topic's headline was "To SPF or not to SPF", which refers to a general discussion not related to a specific aspect of SPF. Anyway, if you like me not replying to your threads anymore, please let me know and I try remembering it. This is absolutely no problem and really not meant offending. 🙂 I just have to know about.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

To SPF or not to SPF

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.