WHAT SPF ACTUALLY ANSWERS, AND WHAT IT DOES NOT.
check_host() answers one narrow question: did the domain that owns this
envelope sender authorise THIS IP to send for it? That is all. In particular:
- IT SAYS NOTHING ABOUT THE MESSAGE. SPF authorises a connection, not content;
the From: header a human sees is not the identity checked here, and a
"pass" on a throwaway domain is a pass. Treating an SPF pass as evidence the
mail is genuine is the single most common misuse of it - that is what DKIM
and DMARC are for, and DMARC is what ties this identity to the header one.
- A FAIL IS THE DOMAIN OWNER'S POLICY, NOT A VERDICT ON THE SENDER. Forwarded
mail fails SPF routinely, because the forwarder is not in the original
domain's policy and has not rewritten the envelope. A receiver that rejects
on fail alone breaks mailing lists and forwarding; the result belongs in a
policy decision (and in a Received-SPF header), not in an automatic 5xx.
THE LIMITS ARE PART OF THE PROTOCOL, NOT AN OPTIMISATION. sec.4.6.4 caps a
single evaluation at cSpfMaxLookups DNS-querying terms and cSpfMaxVoid void
answers. Those caps exist because 'include' and 'redirect' recurse into
someone else's record: without them, a hostile - or merely careless - policy
turns one inbound message into an unbounded fan-out of queries issued BY THIS
HOST AT SOMEONE ELSE'S DIRECTION. Exceeding a limit is permerror, and that is
a security property; it is not something to raise "if it gets in the way".
EVERY ANSWER HERE IS UNAUTHENTICATED. There is no DNSSEC below this (see
StreamSec.Mail.Dns), so an attacker who can forge DNS can manufacture a pass.
SPF is a filter, not an authentication mechanism.
Resolution goes through iDnsResolver, so the whole evaluator runs against a
scripted resolver with no network at all - which is how the vectors at the
bottom pin the limit and macro behaviour that live traffic would never
exercise reproducibly.Feature notes: Mail subsystem notes (SMTP / POP3 / IMAP)
inherits from Exception
(no public members)
Kind: tSpfTermKind;
Qualifier: tSpfQualifier;
Spec: string;
Bits4: Integer;
Bits6: Integer;
Net: tBytes;
ONE EVALUATION PER INSTANCE. The lookup and void budgets are per-instance state, so reusing an evaluator across two messages would let the first one spend the second one's budget. Check() resets them; nothing else does.
constructor Create(const aResolver: iDnsResolver);
function Check(const aClientIP, aHeloName, aMailFrom: string): tSpfResult;
function CheckHelo(const aClientIP, aHeloName: string): tSpfResult;
property Explanation: string read fExplanation;
property Lookups: Integer read fLookups;
property VoidLookups: Integer read fVoids;
property TempErrorName: string read fTempErrorName;
property ReceivingDomain: string read fReceivingDomain write fReceivingDomain;
property Resolver: iDnsResolver read fResolver write fResolver;
RFC 7208 sec.2.6. The two error results are NOT interchangeable:
srTempError says "ask again later" (a 4xx if anything), srPermError says "this policy is broken and will stay broken" (never a retry).