WHY THIS EXISTS AT ALL: ALIGNMENT. SPF and DKIM each authenticate an identifier that a reader never sees. SPF authenticates the SMTP envelope sender; DKIM authenticates whatever domain put its name in d=. NEITHER of them says anything about the From: header, which is the only identity a human is shown. So a DKIM "pass" on its own is worth almost nothing as a policy input. An attacker registers attacker.example, publishes a key, signs their message perfectly, and puts "From: security@yourbank.example" in the header. Every signature check passes. RFC 7489 sec.3.1.1 puts it plainly: a message can bear a valid signature from ANY domain. DMARC is the missing half. It requires that an authenticated identifier be ALIGNED with the RFC5322.From domain, and it lets that domain publish what a receiver should do when nothing aligns. THE ALIGNMENT IS THE SECURITY PROPERTY; the signature check is only an input to it. A DMARC pass needs just ONE aligned pass - DKIM or SPF. That matters in both directions: rejecting on a DKIM failure alone would reject forwarded mail that SPF still covers, and accepting on an unaligned DKIM pass would accept the attack above. THE ORGANIZATIONAL DOMAIN IS THE WEAK SPOT. Relaxed alignment compares organizational domains, which formally requires the Public Suffix List. A compiled-in list would be stale the day it shipped, so this unit ships a short table of the common multi-label suffixes and an OnOrganizationalDomain hook for a real PSL. THE TABLE ERRS TOWARDS TREATING A SUFFIX AS PUBLIC, because the dangerous direction is the other one: if 'co.uk' were mistaken for an organizational domain, then evil.co.uk and victim.co.uk would align and one could sign for the other. Getting it wrong the safe way merely fails to align. Policy discovery, alignment and disposition are pure functions of their inputs plus one DNS lookup, so the whole of it runs against a scripted resolver with no network - which is how the vectors at the bottom test it.
Feature notes: Mail subsystem notes (SMTP / POP3 / IMAP)
inherits from Exception
(no public members)
constructor Create;
destructor Destroy; override;
function Parse(const aText: string): Boolean;
property Tags[const aName: string]: string read GetTag;
Result: tDmarcResult;
Disposition: tDmarcDisposition;
FromDomain: string;
PolicyDomain: string;
Policy: tDmarcPolicy;
DkimAligned: Boolean;
SpfAligned: Boolean;
DkimDomain: string;
Reason: string;
TempErrorName: string;
SpfUndecided: Boolean;
DkimUndecidedDomain: string;
constructor Create(const aResolver: iDnsResolver);
function Evaluate(const aFromDomain: string; const aDkim: tDkimVerdictArray; aSpf: tSpfResult; const aSpfDomain: string): tDmarcVerdict;
property OnOrganizationalDomain: tDmarcOrgDomainEvent read fOnOrgDomain write fOnOrgDomain;
property FailClosedOnTempError: Boolean read fFailClosedOnTempError write fFailClosedOnTempError;
property Resolver: iDnsResolver read fResolver write fResolver;
RFC 7489 sec.6.3 p= / sp=.
sec.3.1: relaxed compares ORGANIZATIONAL domains, strict compares the whole FQDN.
WHY there is no From domain, which decides what a receiver may do about it.
dfsAmbiguous is categorically different from the other two: a message with two From: fields is not merely unusable, it is a message engineered so that a filter and a mail client can be made to disagree about who sent it.
What the receiver should DO. Kept separate from the result because the two are not the same thing: a fail under p=none is still a delivery.