Sub topic 6
Alignment: tying authentication to the visible From domain
This chapter assumes you know what SPF and DKIM records are, can read the Authentication-Results header, and can edit TXT records. It covers alignment, the check that DMARC adds on top of SPF and DKIM.
Why passing SPF or DKIM is not enough
SPF and DKIM each prove something about a domain, but not always the domain the reader sees. A recipient sees the domain in the From: header. SPF checks the domain in the envelope sender (also called the return-path or smtp.mailfrom). DKIM checks the domain in the signature's d= tag. Neither has to match the From: domain.
An attacker can therefore send mail with From: [email protected], an envelope sender at attacker.test, and a DKIM signature from attacker.test. SPF and DKIM both pass, but for the wrong domain. Alignment closes this gap. DMARC passes only when SPF or DKIM passes and the domain it authenticated matches the From: domain.
The two identifiers
| Check | Domain that must align with From | Where you see it |
|---|---|---|
| SPF | Envelope sender domain | `smtp.mailfrom=` |
| DKIM | Signing domain in `d=` | `header.d=` |
DMARC needs only one of the two to pass and align. Aligned DKIM is usually the more reliable one, because it survives forwarding, while SPF usually breaks when a message is forwarded.
Relaxed and strict alignment
A DMARC record controls how strict the match is with two optional tags: adkim for DKIM and aspf for SPF. Each is r (relaxed, the default) or s (strict).
- Relaxed: the two domains need the same organizational domain.
mail.example.comaligns withexample.com. - Strict: the two domains must be identical.
mail.example.comdoes not align withexample.com.
Use relaxed unless you have a specific reason. It lets you sign from a subdomain such as news.example.com while the visible From address stays at example.com.
Reading alignment in a header
This header comes from a message sent through an email service provider (ESP):
Authentication-Results: mx.example.net;
spf=pass smtp.mailfrom=bounce.example.com;
dkim=pass header.d=example.com header.s=mail1;
dmarc=pass (p=NONE) header.from=example.comSPF passes for bounce.example.com. That is a subdomain of example.com, so it would align under relaxed mode. If the ESP used its own bounce domain, such as bounce.esp.example.net, SPF would pass but not align. DKIM passes with header.d=example.com, which matches header.from=example.com. DMARC passes through DKIM alignment.
Common errors
- The ESP signs with its own domain. The default setup often uses a shared signing domain. Mail passes DKIM but fails alignment. Fix this by publishing the ESP's DKIM records under your domain (a custom or branded signing domain).
- SPF is configured but the return-path is the ESP's. SPF passes for the ESP's domain, so it does not align. Set up a custom return-path subdomain if your ESP supports it.
- Strict mode with subdomain sending. With
adkim=s, signing asnews.example.comfor aFrom:ofexample.comfails. - Checking only for
pass. Readsmtp.mailfromandheader.dand compare them toheader.from.
Exercise
A message has spf=pass smtp.mailfrom=bounce.esp.example.net, dkim=pass header.d=esp.example.net, and header.from=example.com. Does DMARC pass? What would you change?
Show answer
DMARC fails. SPF and DKIM both pass, but neither domain matches example.com, so neither aligns. Configure the ESP to sign with a DKIM key published under your domain (for example mail1._domainkey.example.com) so that header.d=example.com. Optionally add a custom return-path subdomain of example.com so SPF aligns too.