SPF, DKIM and DMARC alignment at the protocol level
How SPF evaluation, DKIM canonicalization and DMARC identifier alignment behave on the wire, checked against RFC 9989 and a reproducible lab.
Three identifiers and one comparison
DMARC authenticates nothing. It takes results that two other protocols have already produced, SPF on the SMTP envelope and DKIM on a signature, and asks one question: does either authenticated domain match the domain the reader sees in the From header? Most of the confusion around email authentication comes from treating the three as layers of the same thing. They are not. They authenticate different identifiers, chosen by different parties, and only DMARC connects any of them to what a person reads.
- The
RFC5321.MailFromdomain is the envelope sender, the bounce address given inMAIL FROM. SPF checks whether the connecting IP address may use it. DMARC uses only this SPF identity; SPF can also check the HELO name, but DMARC ignores that result except when the reverse path is null, where the identity becomespostmaster@the HELO domain.12 - The DKIM
d=domain is whatever domain the signer chose to sign as. Any party that controls DNS for a domain can sign any message with it.3 - The
RFC5322.Fromdomain, the Author Domain, is what the mail client shows. Neither SPF nor DKIM says anything about it.
A phishing message sent from an attacker's own infrastructure can therefore pass SPF for attacker.example and carry a valid DKIM signature from attacker.example while showing From: [email protected]. Both checks are green and both are irrelevant. DMARC exists to close exactly that gap, and its whole contribution is the alignment check.
The DMARC specification changed this year. RFC 9989, published in May 2026 as a Proposed Standard, obsoletes the Informational RFC 7489 and the experimental Public Suffix Domain extension RFC 9091; aggregate reporting moved to its own document, RFC 9990.45 The changes that matter for alignment are structural: the Public Suffix List gives way to a DNS Tree Walk, the pct tag is gone, and psd, np and t are part of the core record.2 We read everything below against RFC 9989, because the places where it differs from RFC 7489 are exactly where real deployments now behave differently from what older guides describe.
Production failures come from three places: the SPF evaluation budget, what DKIM canonicalization covers and what it leaves open, and which domain DMARC decides is the Organizational Domain. The lab below reproduces each of them.
The lab
Everything runs on Fedora 43 with Python 3.14.8 and OpenSSL 3.5.9, using dkimpy 1.1.8, pyspf 2.0.14, dnspython 2.9.2, PyNaCl 1.6.2 and authres 1.2.0 from PyPI.67 No query leaves the machine. pyspf resolves through a module-level DNSLookup function and dkimpy's verify takes a dnsfunc argument, so an in-memory zone replaces the resolver for both. Names come from the reserved example domains and addresses from the documentation and benchmarking ranges. Every output block in this article is copied from a run of these commands; only the t= timestamps, the b= values and the generated keys differ between runs.
mkdir -p ~/mailauth-lab && cd ~/mailauth-lab
python3 -m venv venv && . venv/bin/activate
pip install -q dkimpy==1.1.8 pyspf==2.0.14 dnspython==2.9.2 pynacl==1.6.2 authres==1.2.0
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out k2026a.pem
openssl pkey -in k2026a.pem -pubout -outform DER | base64 -w0 > k2026a.pub
openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out arc2026.pem
openssl pkey -in arc2026.pem -pubout -outform DER | base64 -w0 > arc2026.pub
dknewkey --ktype ed25519 e2026b
wc -c < k2026a.pub; cat e2026b.dns; echo392
v=DKIM1; k=ed25519; p=Oh+BASwhB6yp7/KPocSwje8La5Kcq3MZNhOptUTeh3A=cat > zone.py <<'EOF'
# Every DNS answer in the lab comes from this dict; nothing leaves the machine.
import spf
ZONE = {
("example.com", "TXT"): ["v=spf1 ip4:192.0.2.0/24 include:_spf.example.net -all"],
("_spf.example.net", "TXT"): ["v=spf1 ip4:203.0.113.0/24 -all"],
("bloated.example", "TXT"): ["v=spf1 " + " ".join(
f"include:s{i}.bloated.example" for i in range(1, 12)) + " -all"],
}
for i in range(1, 12):
ZONE[(f"s{i}.bloated.example", "TXT")] = [f"v=spf1 ip4:198.18.{i}.0/24 -all"]
QUERIES = []
def lookup(name, qtype, strict=True, timeout=20):
name = name.rstrip(".").lower()
QUERIES.append((name, qtype))
return [((name, qtype), [v.encode()]) for v in ZONE.get((name, qtype), [])]
spf.DNSLookup = lookup # pyspf resolves through this module-level hook
def dkim_txt(name, timeout=5): # the dnsfunc that dkimpy accepts
vals = ZONE.get((name.decode().rstrip(".").lower(), "TXT"), [])
return vals[0].encode() if vals else None
EOF
cat > msg.eml <<'EOF'
From: Alice <[email protected]>
To: [email protected]
Subject: Quarterly figures
Date: Fri, 06 Nov 2026 09:00:00 +0000
Message-ID: <[email protected]>
The numbers are attached.
EOFSPF is a small interpreter with a budget
RFC 7208 defines SPF as a function, check_host(<ip>, <domain>, <sender>), that returns one of none, neutral, pass, fail, softfail, temperror or permerror.1 Record selection comes first: the function fetches TXT records for the domain and keeps those that begin with exactly v=spf1. No record gives none. More than one gives permerror, which is why two teams each adding "their" SPF record breaks both. The surviving record is a sequence of terms evaluated left to right; the first mechanism that matches decides the result through its qualifier, and if nothing matches and there is no redirect, the result is neutral, as if the record ended in ?all.
Some terms cost DNS queries at evaluation time and some do not. Section 4.6.4 caps the costly ones: "SPF implementations MUST limit the total number of those terms to 10 during SPF evaluation", and exceeding the limit MUST return permerror. Separately, lookups that return no answer or NXDOMAIN are void lookups, which implementations SHOULD limit to two, again with permerror as the result.1
| Term | DNS query during evaluation | Counts toward the 10 | Additional limit |
|---|---|---|---|
include | Yes, then a recursive check_host() | Yes | Result mapping in section 5.2, see below |
a, exists, redirect | Yes | Yes | None beyond the void lookup limit |
mx | Yes | Yes | At most 10 address records per MX evaluation, otherwise permerror |
ptr | Yes | Yes | Only the first 10 names are used; section 5.5 is titled "do not use" |
ip4, ip6, all | No | No | None |
exp | Only later, to build a rejection text | No | None |
The include mechanism is the one that surprises people. Section 5.2 maps the result of the recursive check onto the outer evaluation: pass means the include matches; fail, softfail and neutral all mean it does not match and evaluation continues; temperror propagates; and both permerror and none become permerror.1 So an include that points at a vendor domain whose SPF record has disappeared does not fall through quietly. It turns your entire record into permerror for every sender evaluated past that point.
The budget is spent along the evaluation path
The zone gives bloated.example a record with eleven includes, each authorizing a different /24. The script prints the result, the number of terms pyspf counted against the limit, and the number of DNS queries it actually made.
cat > spf_lab.py <<'EOF'
import sys, spf, zone
ip, mailfrom, helo = sys.argv[1:4]
q = spf.query(i=ip, s=mailfrom, h=helo, strict=True)
print(ip, q.check()[0], "terms_counted=%d" % q.lookups, "dns_queries=%d" % len(zone.QUERIES))
EOF
python spf_lab.py 192.0.2.25 [email protected] mx1.example.com
python spf_lab.py 203.0.113.9 [email protected] mx1.example.com
python spf_lab.py 198.51.100.7 [email protected] fwd.example.org
for ip in 198.18.1.5 198.18.10.5 198.18.11.5; do
python spf_lab.py $ip [email protected] mx.bloated.example
done192.0.2.25 pass terms_counted=0 dns_queries=1
203.0.113.9 pass terms_counted=1 dns_queries=2
198.51.100.7 fail terms_counted=1 dns_queries=2
198.18.1.5 pass terms_counted=1 dns_queries=2
198.18.10.5 pass terms_counted=10 dns_queries=11
198.18.11.5 permerror terms_counted=11 dns_queries=11The limit applies to terms evaluated, not terms written. A sender covered by the first include passes after one counted term. A sender covered by the tenth passes at exactly ten. A sender covered by the eleventh gets permerror, and pyspf never fetches that record: eleven queries are the policy record itself plus ten includes, and the counter in query.check_lookups() raises before the eleventh include is resolved. In other words, a record that is over budget looks healthy from every sender early in the list. It breaks only for senders late in the list and for every address that matches nothing, which is precisely the traffic you published -all for. A forged message from an unlisted address walks the whole record, spends the whole budget, and earns permerror instead of fail.
That is how we audit SPF: count the worst-case path, the one a non-matching address takes, because that is the path an attacker's address takes. Flattening includes into literal ip4 ranges saves lookups but freezes a vendor's address list into your zone, and the record goes stale the moment the vendor renumbers. The better fix is structural. Give each sending service its own envelope domain, such as bounces.example.com, with its own record. Each RFC5321.MailFrom domain is evaluated from its own record with its own budget, and under relaxed alignment a subdomain still aligns with example.com.
What SPF does not survive
The third line of the output is the forwarding case. 198.51.100.7 is a forwarder that relays the message without rewriting MAIL FROM, and SPF fails, correctly: the forwarder is not authorized to send for example.com. RFC 7208 Appendix D.2 describes the alternative, in which the mediator rewrites MAIL FROM into its own domain.1 SPF then passes, but for the forwarder's domain, which does not align with example.com. Either way SPF cannot carry a DMARC pass through a forwarder. RFC 9989 draws the operational conclusion directly: domains that publish p=reject "MUST NOT rely solely on SPF to secure a DMARC pass and MUST apply valid DKIM signatures to their messages."2
DKIM signs a canonical form, not the message
Here is the header dkimpy produces for the test message with relaxed canonicalization and an explicit list of signed fields.
cat > dkim_lab.py <<'EOF'
import sys, dkim, zone
from dkim.canonicalization import Relaxed
zone.ZONE[("k2026a._domainkey.example.com", "TXT")] = [
"v=DKIM1; k=rsa; p=" + open("k2026a.pub").read().strip()]
key = open("k2026a.pem", "rb").read()
msg = open("msg.eml", "rb").read().replace(b"\n", b"\r\n")
H = (b"from", b"to", b"subject", b"date", b"message-id")
def signature(m, c=b"relaxed/relaxed", l=False, h=H):
return dkim.sign(m, b"k2026a", b"example.com", key, canonicalize=tuple(c.split(b"/")),
include_headers=list(h), length=l)
def sign(m, c=b"relaxed/relaxed", l=False, h=H):
return signature(m, c, l, h) + m
def ok(m):
return dkim.verify(m, dnsfunc=zone.dkim_txt)
case = sys.argv[1]
if case == "show":
print(signature(msg).decode(), end="")
elif case == "canon":
print(Relaxed.canonicalize_headers([(b"SubJect ", b" Quarterly \t figures \r\n\tagain ")]))
print(Relaxed.canonicalize_body(b"line one \t\r\nline two\r\n\r\n\r\n"))
elif case == "refold":
for c in (b"relaxed/relaxed", b"simple/simple"):
s = sign(msg, c)
t = s.replace(b"Subject: Quarterly figures", b"Subject: Quarterly\r\n figures")
print(c.decode(), "untouched:", ok(s), "refolded Subject:", ok(t))
elif case == "length":
for l in (False, True):
s = sign(msg, l=l)
t = s + b"\r\nUpdated bank details: see https://pay.attacker.example/\r\n"
print("l=" + str(l), "original:", ok(s), "text appended:", ok(t))
elif case == "oversign":
for h in ((b"from", b"subject"), (b"from", b"subject", b"reply-to")):
s = sign(msg, h=h)
t = s.replace(b"From: Alice", b"Reply-To: [email protected]\r\nFrom: Alice", 1)
print("h=" + b":".join(h).decode(), "original:", ok(s), "Reply-To added:", ok(t))
s = sign(msg, h=(b"from", b"subject"))
t = s.replace(b"From: Alice", b"From: CEO <[email protected]>\r\nFrom: Alice", 1)
print("h=from:subject", "second From added:", ok(t))
elif case == "revoke":
s = sign(msg)
print("key published:", ok(s))
zone.ZONE[("k2026a._domainkey.example.com", "TXT")] = ["v=DKIM1; k=rsa; p="]
print("p= emptied:", ok(s))
EOF
for c in show canon refold length oversign revoke; do echo "== $c"; python dkim_lab.py $c; doneDKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=example.com;
[email protected]; q=dns/txt; s=k2026a; t=1793915285; h=from : to :
subject : date : message-id;
bh=FtLXe5HaBbjUgCL1i5HU585ts1Mjd1MXuuiuyglfEpU=;
b=IUasUaJdUWHb3qL7GOyQD86rp2daJOy6+KeYBK8T8/MrQB0l4phXVNetSUlK4rt5Lse78
iVQM418qyYeFlefsOwGh5TlRcdfEz9gGyKrMMzdxN8tLeeqb5B7E/09wDgXvjsg2UfUUvss
C5p0iGcLlQj8h+aYMcya90KdGC9KJJ0Lzvsfv5vz92iEWhJ5obOPRaz+wintVkvFU1USAB9
EvQ1n/E5nl45V1LvlrnzwYcuGskk8NyPmhdEfLkXjbce5iDj14IWAMkpusAlH9m0RBhCsbX
pqOlfBvuHcP0dcCuQusybz1HIYgO2ZfrM6S4KqlEinBrk5Oulmr2NYWvXp+Q==| Tag | Meaning | Notes |
|---|---|---|
v, a, d, s, h, bh, b | Version, algorithm, signing domain, selector, signed header list, body hash, signature | Required; dkimpy's validate_signature_fields rejects a signature missing any of them |
c | Header and body canonicalization | Default simple/simple when absent |
i | Agent or user identifier | Must be in d= or a subdomain of it; defaults to @ plus d= |
q | Key query method | dns/txt is the only method defined |
t | Signature timestamp | Seconds since the epoch |
l | Body length count | Absent here, and should stay absent |
Section 3.7 of RFC 6376 defines two hashes, computed in a fixed order.3 The body hash comes first: the body is canonicalized, truncated to l= octets if that tag is present, and hashed into bh=. The header hash then covers the fields listed in h=, canonicalized and in h= order, followed by the DKIM-Signature field itself with the value of b= deleted and without a trailing CRLF. That second hash is what the private key signs. dkimpy's hash_headers() in dkim/__init__.py does exactly this: it removes the b= value with the RE_BTAG expression, strips the trailing line break, and feeds the selected fields and then the signature field to the hasher. Because the signature covers its own tags, nobody downstream can raise l=, drop a name from h=, or change d= without invalidating b=.
Field selection has one rule that matters for security. When a name appears several times in h=, the instances are taken from the bottom of the header block upwards (section 5.4.2), and a name can be listed more times than the field occurs. A missing instance is hashed as the null string, so if someone adds that field later the signature fails. dkimpy's select_headers() implements the bottom-up walk with a per-name index into the header list.
Canonicalization
The c= tag names a header algorithm and a body algorithm. simple header canonicalization changes nothing. relaxed lowercases field names, unfolds continuation lines, collapses every run of whitespace to one space, and deletes whitespace at the end of the value and around the colon. simple body canonicalization only ignores empty lines at the end of the body. relaxed body canonicalization also strips whitespace at the end of each line and collapses runs inside lines.3 The canon and refold cases show both on real bytes.
== canon
[(b'subject', b'Quarterly figures again\r\n')]
b'line one\r\nline two\r\n'
== refold
relaxed/relaxed untouched: True refolded Subject: True
simple/simple untouched: True refolded Subject: FalseHeader field line rewrapping is one of the "common modifications" RFC 6376 names as the reason relaxed exists, and it breaks a simple header signature while leaving a relaxed one intact.3 The normalizations in relaxed touch only whitespace and the case of field names, and neither carries meaning a reader acts on. We sign relaxed/relaxed and see no argument for simple headers that holds up once mail has crossed a real transport.
The l= tag signs a prefix
l=False original: True text appended: False
l=True original: True text appended: TrueWith l= the body hash covers only the first l octets of the canonicalized body, so anything appended afterwards is outside the signature and the signature still verifies. RFC 6376 section 8.2 is blunt: the tag "might allow display of fraudulent content without appropriate warning to end users", signers "should be extremely wary of using this tag, and Assessors might wish to ignore signatures that use the tag."3 The DMARC consequence is worse than the DKIM one. The signature still verifies and d=example.com still aligns, so the appended text arrives with a DMARC pass for example.com. We never set l=, and we treat a signature that carries it as unsigned when a decision depends on the body.
Oversigning
h=from:subject original: True Reply-To added: True
h=from:subject:reply-to original: True Reply-To added: False
h=from:subject second From added: FalseA Reply-To added after signing passes when h= does not name it, and fails when h= names it even though the original message had none. That is the null-instance rule at work, and it is the cheapest defence against a replayed message with a redirected reply path. The third line is more interesting than it looks. The signature listed from once, yet adding a second From broke it. RFC 6376 does not require that. It happens because dkimpy's verifier appends an extra from to the header list before hashing, in DomainSigner.verify_sig_process(), with a comment pointing at an old bug report. That is a verifier choice, not protocol behaviour, so we list from twice when signing rather than depend on every receiver making the same choice. The same goes for the other fields a reader acts on: Reply-To, Subject, To and Cc.
Keys and algorithms
RFC 8301 removed rsa-sha1 from DKIM entirely, for both signing and verifying. Signers MUST use RSA keys of at least 1024 bits and SHOULD use at least 2048, and verifiers MUST handle 1024 to 4096 bits and MUST NOT accept anything under 1024.8 RFC 8463 added ed25519-sha256, which verifiers MUST implement and signers SHOULD; its key record carries k=ed25519, and since an Ed25519 public key is 256 bits, the base64 text is 44 octets and "will generally fit in a single 255-byte TXT string".9 The RSA key in the lab is 392 base64 characters, so its TXT record has to be published as at least two strings, which section 3.6.2.2 of RFC 6376 says verifiers concatenate with no intervening whitespace.3
cat > ed_lab.py <<'EOF'
# Two signatures, two selectors, one d=: the transition RFC 8463 section 6 describes.
import re, dkim, zone
zone.ZONE[("k2026a._domainkey.example.com", "TXT")] = [
"v=DKIM1; k=rsa; p=" + open("k2026a.pub").read().strip()]
zone.ZONE[("e2026b._domainkey.example.com", "TXT")] = [open("e2026b.dns").read().strip()]
H = [b"from", b"to", b"subject", b"date", b"message-id"]
msg = open("msg.eml", "rb").read().replace(b"\n", b"\r\n")
rsa = dkim.sign(msg, b"k2026a", b"example.com", open("k2026a.pem", "rb").read(),
canonicalize=(b"relaxed", b"relaxed"), include_headers=H)
ed = dkim.sign(rsa + msg, b"e2026b", b"example.com", open("e2026b.key", "rb").read(),
canonicalize=(b"relaxed", b"relaxed"), include_headers=H,
signature_algorithm=b"ed25519-sha256")
d = dkim.DKIM(ed + rsa + msg)
for idx in range(2):
ok = d.verify(idx=idx, dnsfunc=zone.dkim_txt)
sig = d.signature_fields
print(sig[b"a"].decode(), "s=" + sig[b"s"].decode(), "verified:", ok,
"b= chars:", len(re.sub(rb"\s+", b"", sig[b"b"])))
EOF
python ed_lab.pyed25519-sha256 s=e2026b verified: True b= chars: 88
rsa-sha256 s=k2026a verified: True b= chars: 344Section 6 of RFC 8463 describes this transition: because a selector holds one key record, an old and a new algorithm need different selectors under the same d=.9 A verifier that does not implement Ed25519 ignores that signature and evaluates the RSA one. Until you can show that the receivers you care about verify Ed25519, keep both.
DMARC alignment after RFC 9989
RFC 9989 defines the result in one sentence: if one or more of the Authenticated Identifiers align with the Author Domain, the message passes. Strict alignment means the two domains are identical. Relaxed alignment, the default for both adkim and aspf, means they share an Organizational Domain.2 Everything interesting is in how a receiver finds the policy record and the Organizational Domain.
Policy discovery (section 4.10.1) queries _dmarc. plus the Author Domain first. If a valid record is there, it is the policy. Otherwise the receiver performs a DNS Tree Walk to find the Organizational Domain's record or, failing that, the Public Suffix Domain's. A record taken from a parent domain applies sp to existing subdomains and np to non-existent ones, falling back to p. If the walk finds nothing, DMARC does not apply to the message at all. How to treat DNS errors is left to the receiver, which may fail open and deliver, or fail closed with a temporary 4xx rejection.2
The DNS Tree Walk
The walk replaces RFC 7489's dependence on a Public Suffix List, which RFC 7489 itself described as heuristic.10 The receiver queries _dmarc at the starting name, discards records that do not begin with the DMARC version tag, discards every record if more than one remains, and stops if the single remaining record carries psd=n or psd=y. Otherwise it removes the leftmost label and repeats. To bound the cost of an Author Domain with dozens of labels, a name with eight or more labels is first cut down to seven, so no walk exceeds eight queries.2 The lab's walk() follows those steps, and its query log for the RFC's own example name matches the eight queries listed in section 4.10.
cat > dmarc_lab.py <<'EOF'
# DMARC policy discovery and alignment with the DNS Tree Walk of RFC 9989, section 4.10.
import sys, zone
zone.ZONE.update({
("_dmarc.example.com", "TXT"): ["v=DMARC1; p=reject; rua=mailto:[email protected]"],
("_dmarc.strict.example", "TXT"): ["v=DMARC1; p=reject; adkim=s; aspf=s"],
("_dmarc.shop.example", "TXT"): ["v=DMARC1; p=reject"],
("_dmarc.example", "TXT"): ["v=DMARC1; p=none; psd=y"],
("_dmarc.shop.test", "TXT"): ["v=DMARC1; p=reject"],
("_dmarc.test", "TXT"): ["v=DMARC1; p=none"],
})
def record(domain):
zone.QUERIES.append("_dmarc." + domain)
recs = [r for r in zone.ZONE.get(("_dmarc." + domain, "TXT"), []) if r.startswith("v=DMARC1")]
if len(recs) != 1: # none, or several: both mean no record
return None
return dict(kv.strip().split("=", 1) for kv in recs[0].split(";") if "=" in kv)
def walk(domain):
"""Valid records seen on the walk, longest name first."""
found, labels = [], domain.split(".")
while labels:
name = ".".join(labels)
rec = record(name)
if rec:
found.append((name, rec))
if rec.get("psd") in ("y", "n"):
break
labels = labels[1:] if len(labels) < 8 or name != domain else labels[-7:]
return found
def org_domain(domain):
found = walk(domain)
for name, rec in found:
if rec.get("psd") == "n":
return name
if rec.get("psd") == "y" and name != domain:
return ".".join(domain.split(".")[-(name.count(".") + 2):])
return found[-1][0] if found else domain
def aligned(author, ident, mode):
return author == ident if mode == "s" else org_domain(author) == org_domain(ident)
def evaluate(author, spf_domain, dkim_domains):
recs = dict(walk(author))
if not recs:
return "none: DMARC does not apply"
org = org_domain(author)
name = author if author in recs else org if org in recs else min(recs, key=len)
rec = recs[name]
spf_ok = spf_domain is not None and aligned(author, spf_domain, rec.get("aspf", "r"))
dkim_ok = any(aligned(author, d, rec.get("adkim", "r")) for d in dkim_domains)
policy = rec.get("p") if name == author else rec.get("sp", rec.get("p"))
return "%s spf_aligned=%s dkim_aligned=%s record=_dmarc.%s p=%s" % (
"pass" if spf_ok or dkim_ok else "fail", spf_ok, dkim_ok, name, policy)
cases = { # author domain, SPF-pass domain or None, DKIM-pass d= values
"direct": ("example.com", "mail.example.com", ["example.com"]),
"esp": ("example.com", "bounces.esp.example.net", ["esp.example.net"]),
"forwarded": ("example.com", None, ["example.com"]),
"list": ("example.com", "lists.example.org", []),
"strict": ("strict.example", "strict.example", ["mail.strict.example"]),
"psd-y": ("shop.example", None, ["other.example"]),
"psd-absent": ("shop.test", None, ["other.test"]),
}
for name, args in cases.items():
print("%-10s %s" % (name, evaluate(*args)))
zone.QUERIES.clear()
walk("a.b.c.d.e.f.g.h.i.j.mail.example.com")
print(len(zone.QUERIES), "queries:", " ".join(zone.QUERIES))
EOF
python dmarc_lab.pydirect pass spf_aligned=True dkim_aligned=True record=_dmarc.example.com p=reject
esp fail spf_aligned=False dkim_aligned=False record=_dmarc.example.com p=reject
forwarded pass spf_aligned=False dkim_aligned=True record=_dmarc.example.com p=reject
list fail spf_aligned=False dkim_aligned=False record=_dmarc.example.com p=reject
strict pass spf_aligned=True dkim_aligned=False record=_dmarc.strict.example p=reject
psd-y fail spf_aligned=False dkim_aligned=False record=_dmarc.shop.example p=reject
psd-absent pass spf_aligned=False dkim_aligned=True record=_dmarc.shop.test p=reject
8 queries: _dmarc.a.b.c.d.e.f.g.h.i.j.mail.example.com _dmarc.g.h.i.j.mail.example.com _dmarc.h.i.j.mail.example.com _dmarc.i.j.mail.example.com _dmarc.j.mail.example.com _dmarc.mail.example.com _dmarc.example.com _dmarc.comSelecting the Organizational Domain from the records found, longest name first, follows three rules in section 4.10.2: a record with psd=n is the Organizational Domain; a record with psd=y, other than at the starting name, makes the domain one label below it the Organizational Domain; otherwise the record at the name with the fewest labels wins.2 The last two cases in the output show what that means. Under example, which publishes psd=y, shop.example and other.example are separate Organizational Domains, so a DKIM signature from other.example does not align with mail from shop.example. Under test, which publishes a record without psd, the shortest-name rule makes test the Organizational Domain of both, and the same signature aligns.
Under RFC 9989 the Organizational Domain is a property of where DMARC records exist in DNS, not of a list maintained somewhere else. That gives domain owners a tool they did not have. A group that delegates brand.example.com to a separately run business unit can publish psd=n at _dmarc.brand.example.com. Walks starting below it stop there, and mail from that unit no longer aligns, under relaxed rules, with signatures from the rest of example.com. It also creates a transition hazard. RFC 9989 notes that implementations still built on RFC 7489 and a Public Suffix List may reach different results, so for a while two receivers can disagree about the same message.2 The lab simplifies one thing: it does not test whether the Author Domain exists, so it never selects np.
What changed in the record
| Tag | RFC 7489 | RFC 9989 |
|---|---|---|
p | Required | Recommended; a record with no valid p but a valid rua is treated as p=none |
sp, np | sp only; np came from RFC 9091 | Both in the core; np covers non-existent subdomains |
pct | Sampling percentage, 0 to 100 | Removed and registered as historic |
t | Not defined | Test mode: t=y asks receivers to apply one level below p |
psd | Not defined | y, n or u (default); steers the Tree Walk |
rf, ri | Report format and interval | Historic |
adkim, aspf | r or s, default r | Unchanged |
Appendix A.6 explains why pct went: in practice only 0 and 100 were applied accurately, and intermediaries had started treating pct=0 as a signal to rewrite the From header. The t tag keeps that signal and drops the false precision.2 A record that still says pct=100 is harmless. RFC 9989 no longer lists pct among the valid tags in section 4.7 and keeps it in the DMARC Tags registry only with the status "historic" (section 9.3), and 100 was the RFC 7489 default, so a receiver built on either specification treats the record the same way.2 A value between 1 and 99 was, by the RFC's own account, applied inconsistently from one implementation to the next.
Section 7.4 places obligations on both sides. Receivers "MUST NOT reject incoming messages solely on the basis of a "p=reject" policy by the sending domain" and, without other analysis, treat such mail as quarantine. Domains whose users post to mailing lists SHOULD NOT publish p=reject. A domain that wants it anyway SHOULD first publish p=none for at least a month, then p=quarantine for an equally long period, comparing aggregate results.2 We follow that sequence because it is the only way to see the indirect flows before they break.
The esp case is worth dwelling on, because nothing in it looks broken until DMARC runs. A sending service authenticates as itself: SPF passes for bounces.esp.example.net and DKIM passes for esp.example.net. Both identifiers are authenticated and neither aligns, so DMARC fails at p=reject. The fix is never to loosen the policy. Have the service sign with a key under your d=, published at a selector you control or delegate, and use a custom envelope domain under yours if you want SPF alignment too.
Forwarding, mailing lists and ARC
| Flow | SPF | DKIM `d=example.com` | DMARC |
|---|---|---|---|
| Direct delivery | Pass, aligned | Pass, aligned | Pass |
| Forwarder, envelope unchanged | Fail | Pass, aligned | Pass |
| List tags Subject, appends footer | Pass for the list domain, not aligned | Fail | Fail |
| Same list, ARC-sealed | As above | Fail | Fail; ARC cv=pass is input to local policy |
Plain forwarding is DKIM's case to win, and the lab shows it winning. Mailing lists are different, because they modify the message. RFC 7960 lists the usual edits, a subject tag, a footer, stripped MIME parts, and states that "any such modifications would invalidate a DKIM signature".11 It also records the second-order damage. Subscribers whose receivers reject on DMARC bounce the list's copies, and list software reads the bounces as dead addresses and unsubscribes them. RFC 9989 accepts that lists have settled on rewriting the From header to their own domain, and calls the workarounds "far from ideal" but firmly established.2
ARC, RFC 8617, is the attempt to carry the original verdict across the modification.12 Each participating intermediary adds an ARC Set of three header fields with the same instance number i=, from 1 to 50. The ARC-Authentication-Results field copies the authentication results the intermediary saw on arrival. The ARC-Message-Signature field is a DKIM-style signature over the message as the intermediary sends it. The ARC-Seal field signs the ARC header fields themselves: it uses only relaxed header canonicalization, covers no body, must not carry an h= tag, and records the chain validation status in cv= as none, pass or fail.
cat > arc_lab.py <<'EOF'
# A list that tags the Subject and appends a footer, then seals what it saw with ARC.
import dkim, zone
zone.ZONE[("k2026a._domainkey.example.com", "TXT")] = [
"v=DKIM1; k=rsa; p=" + open("k2026a.pub").read().strip()]
zone.ZONE[("arc2026._domainkey.lists.example.org", "TXT")] = [
"v=DKIM1; k=rsa; p=" + open("arc2026.pub").read().strip()]
H = [b"from", b"to", b"subject", b"date", b"message-id"]
msg = open("msg.eml", "rb").read().replace(b"\n", b"\r\n")
signed = dkim.sign(msg, b"k2026a", b"example.com", open("k2026a.pem", "rb").read(),
canonicalize=(b"relaxed", b"relaxed"), include_headers=H) + msg
print("list ingress, author DKIM:", dkim.verify(signed, dnsfunc=zone.dkim_txt))
ar = (b"Authentication-Results: lists.example.org; dkim=pass header.d=example.com;"
b" spf=pass smtp.mailfrom=example.com\r\n")
out = (ar + signed).replace(b"Subject: Quarterly", b"Subject: [team] Quarterly")
out += b"--\r\nYou are subscribed to [email protected]\r\n"
print("list egress, author DKIM:", dkim.verify(out, dnsfunc=zone.dkim_txt))
arc = b"".join(dkim.arc_sign(out, b"arc2026", b"lists.example.org",
open("arc2026.pem", "rb").read(), b"lists.example.org",
include_headers=H))
for line in arc.decode().splitlines():
if line.startswith("ARC-"):
print(line)
cv, results, reason = dkim.arc_verify(arc + out, dnsfunc=zone.dkim_txt)
print("receiver: cv=%s (%s)" % (cv.decode(), reason))
EOF
python arc_lab.pylist ingress, author DKIM: True
list egress, author DKIM: False
ARC-Seal: i=1; cv=none; a=rsa-sha256; d=lists.example.org; s=arc2026;
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed;
ARC-Authentication-Results: i=1; lists.example.org;
receiver: cv=pass (success)The author's signature dies at the list, and the chain verifies at the receiver. What the receiver learns from cv=pass is narrow and exact: lists.example.org attests that it saw dkim=pass for example.com before changing the message, and nobody altered that attestation afterwards. It learns nothing about whether lists.example.org deserves to be believed. RFC 8617 leaves that to local policy: a DMARC processor "MAY choose to accept" the ARC assessments, a chain with cv=fail is treated as no chain, and an override can be reported with the local_policy reason.12 The protocol is still Experimental, and RFC 9989 states that none of the methods invented to let lists work without rewriting From, ARC being the prominent one, has become widely used.2
Our position follows from that. As a domain owner, do not plan on ARC to rescue mail that p=reject would otherwise lose. As a receiver, use ARC as input to an allowlist of intermediaries you already trust for other reasons. The longer-term answer is being written in the IETF DKIM working group. The DKIM2 draft, at revision 09 dated 1 November 2026, binds the envelope into the signature with mf= and rt= tags and describes intermediary changes as recipes in a Message-Instance field, so that a verifier can reconstruct earlier versions of the message.13 It is a working group draft, not a standard, and there is nothing to deploy yet.
Rotating DKIM keys in DNS
A verifier finds the key at <s>._domainkey.<d> from the signature's s= and d= tags. Because each selector holds exactly one key record, rotating a key means moving to a new selector, not editing a record in place.9 Old keys need care. Mail is verified on arrival, but messages are also validated again later, which is why the M3AAWG practice warns against reusing selector names.14 RFC 6376 makes no distinction between a revoked key and a deleted record: an empty p= means revoked, and the verifier fails the signature.3
key published: True
p= emptied: FalseThe M3AAWG key rotation practice, revised in March 2019, recommends rotating at least every six months; the earlier version said quarterly.14 The order of a rotation follows from when verification happens. The verifier looks the key up when the message arrives, so the new selector has to resolve before the first message carries its s=: a verifier that asks too early gets no record and, under RFC 6376 section 6.1.2 step 3, MUST return PERMFAIL (no key for signature), and its resolver may keep that negative answer for the lesser of the zone's SOA TTL and SOA MINIMUM.315 That is why M3AAWG says to wait for the new key to propagate before signing with it. Verification also happens late: messages still in transit on the signer's own servers carry the old s=, and the operations advice in RFC 6376 section 5.2, which M3AAWG quotes, expects verifiers to defer validation, possibly until the recipient reads the message. M3AAWG therefore keeps the old public key unchanged for at least seven and up to 30 days after the switch. It then retires the key by emptying p= rather than deleting the record. A verifier that still meets the selector returns PERMFAIL (key revoked) under step 7, as the revoke case shows. A removed record would fail just as permanently, so the empty p= exists so that the selector stays discoverable as intentionally retired rather than looking like a broken zone. The name is never reused, because a reused selector makes old messages fail any re-validation against the new key and can collide with stale cached values.14
When a provider holds the private key, the selectors are CNAMEs into the provider's DNS. Microsoft 365 uses two, selector1._domainkey and selector2._domainkey, signs with one while the other waits, and documents that after a rotation it takes four days (96 hours) before the new key starts signing. Its New-DkimSigningConfig cmdlet defaults to a 1024-bit key and offers 2048.16 Choose 2048: RFC 8301 says signers SHOULD use RSA keys of at least 2048 bits, and 1024 is only the floor.8 The domain owner's job in this model is small but strict: both CNAMEs must exist before anyone presses rotate.
At Korur, DNS zones live in Cloudflare and are managed with Terraform, so a selector is a resource in a reviewed change: the plan shows the exact TXT value before it is applied, and the retirement step is a second reviewed change, not a forgotten console edit. The Ed25519 record from the lab, in that form:
resource "cloudflare_dns_record" "dkim_e2026b" {
zone_id = var.zone_id
name = "e2026b._domainkey.example.com"
type = "TXT"
content = "\"v=DKIM1; k=ed25519; p=Oh+BASwhB6yp7/KPocSwje8La5Kcq3MZNhOptUTeh3A=\""
ttl = 3600
comment = "DKIM Ed25519 selector for example.com"
}Reading aggregate reports with this model
RFC 9990 aggregate reports make sense once you keep the identifiers apart. Each record carries a row with the source_ip, a count and policy_evaluated, whose dkim and spf values are DMARC alignment results. Its identifiers give the header_from domain and optionally envelope_from. Its auth_results hold the raw DKIM results, each with domain, selector and result, and the SPF result with its domain and scope, which RFC 9990 describes as "uninterpreted with respect to DMARC".5
Every case in this article leaves its own signature in those fields. The esp case shows auth_results with a DKIM pass for esp.example.net next to policy_evaluated with dkim fail. A forwarder shows an unfamiliar source_ip, an SPF fail and an aligned DKIM pass. A mailing list shows a DKIM fail for your domain from a list server's address. An SPF record over budget shows permerror only from some sources, which is the pattern the lab predicts for senders late in the include list. Read the reports this way and the dashboard becomes a list of specific DNS and signer changes.
References
- RFC 7208: Sender Policy Framework (SPF) for Authorizing Use of Domains in Email, Version 1 IETF, RFC Editor
- RFC 9989: Domain-Based Message Authentication, Reporting, and Conformance (DMARC) IETF, RFC Editor
- RFC 6376: DomainKeys Identified Mail (DKIM) Signatures IETF, RFC Editor
- RFC 9989 information page: status, obsoleted documents and related RFCs RFC Editor
- RFC 9990: Domain-Based Message Authentication, Reporting, and Conformance (DMARC) Aggregate Reporting IETF, RFC Editor
- dkimpy 1.1.8 Python Package Index
- pyspf: SPF (Sender Policy Framework) implemented in Python GitHub, sdgathman/pyspf
- RFC 8301: Cryptographic Algorithm and Key Usage Update to DomainKeys Identified Mail (DKIM) IETF, RFC Editor
- RFC 8463: A New Cryptographic Signature Method for DomainKeys Identified Mail (DKIM) IETF, RFC Editor
- RFC 7489: Domain-based Message Authentication, Reporting, and Conformance (DMARC) IETF, RFC Editor
- RFC 7960: Interoperability Issues between DMARC and Indirect Email Flows IETF, RFC Editor
- RFC 8617: The Authenticated Received Chain (ARC) Protocol IETF, RFC Editor
- DomainKeys Identified Mail Signatures v2 (DKIM2), draft-ietf-dkim-dkim2-spec-09 IETF Datatracker
- M3AAWG DKIM Key Rotation Best Common Practices (revised March 2019) M3AAWG
- RFC 2308: Negative Caching of DNS Queries (DNS NCACHE) IETF, RFC Editor
- How to use DKIM for email in your custom domain Microsoft Learn