A DKIM signature does not protect the whole message by default. It protects the body (through a hash) and the specific headers named in the signature's h= tag. Everything else can be changed in transit without breaking the signature. That makes the header list one of the most important and least discussed settings of a DKIM deployment: sign too little and attackers or intermediaries can alter what recipients see, sign too much and harmless changes by relays break your signatures. This guide explains how the h= tag works, which headers to include, what oversigning is and why it matters, how canonicalization affects fragility and how to audit what your platform actually signs. It builds on DKIM records, body hash failures and reading authentication results.
How h= works
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=example.com; s=s2025;
t=1738490400; bh=Zm9vYmFy...=;
h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:List-Unsubscribe;
b=AbCdEf...The h= value is a colon-separated list of header field names that the signature covers. The signer hashes those headers in the order listed, takes the instance closest to the bottom of the message for each name (reading from the last matching header upward) and then hashes the signature header itself with an empty b=. A verifier repeats the process. If any covered header differs, verification fails with a "header" mismatch. Headers not listed are not protected at all.
What to include
| Header | Sign? | Why |
|---|---|---|
| From | Always | Required by the standard and by DMARC alignment |
| To, Cc | Yes | Prevents silent change of the apparent recipients |
| Subject | Yes | Protects the message text readers see first |
| Date | Yes | Protects against replay with fake timestamps |
| Message-ID | Yes | Stable identifier; see Message-ID |
| Reply-To | Yes, if used | An attacker who changes Reply-To redirects replies |
| In-Reply-To, References | Yes, if present | Protect threading |
| MIME-Version, Content-Type, Content-Transfer-Encoding | Yes | Protect how the body is interpreted |
| List-Id, List-Unsubscribe, List-Unsubscribe-Post | Yes for bulk mail | Required to be signed for one-click unsubscribe at several providers. See List-Id |
| Sender, Resent-* | If present | Describe who submitted the message |
| Received, Return-Path, Authentication-Results | Never | Added or changed by every hop and would always break |
| X- headers added by gateways | No | Intermediaries add and remove them |
| Bcc | No | Normally removed before sending |
A good default for most senders is the list: From, To, Cc, Subject, Date, Message-ID, Reply-To, MIME-Version, Content-Type, Content-Transfer-Encoding and the List headers. Many platforms use a similar set; check yours.
Oversigning
The signature covers the instances of a header present at signing time. If you list Subject once and the message has one Subject, an attacker who later adds a second Subject header above the signed one creates a message that still verifies, because the verifier picks the bottom-most instance (the original), while many mail clients display the top-most instance (the fake). This is the header-addition attack on DKIM. Oversigning closes the gap by listing the header name one more time than it appears, so that the signature also asserts that no extra instance exists.
# The message has one From, one To and one Subject. Oversign them:
h=From:From:To:To:Subject:Subject:Date:Message-ID:MIME-Version:Content-TypeOpenDKIM, Rspamd, Exim, several cloud platforms and some commercial gateways support oversigning through a configuration option. It is a low-cost hardening step for From at the very least, and recommended for Subject, To and Date as well. Test that downstream systems do not add legitimate duplicates of those headers before enabling.
Canonicalization
| Mode | Header handling | Body handling | Fragility |
|---|---|---|---|
| simple | Exactly as is, including case and spacing | Only trailing blank lines are ignored | Very fragile; whitespace changes break it |
| relaxed | Names lowercased, whitespace folded and trimmed | Whitespace within and at the end of lines normalised | Tolerates common rewrapping; recommended |
The tag c=relaxed/relaxed selects relaxed for headers and body. Almost all senders should use it; simple canonicalization causes avoidable failures when a gateway rewraps lines or normalises spacing. Also consider the l= body length tag: signing only part of the body allows text to be appended after signing, so avoid it.
Why signatures break anyway
| Cause | What changes | What to do |
|---|---|---|
| Footer or disclaimer added by a gateway | The body | Sign after the gateway adds it, or move the footer into the original message. See body hash failures |
| Subject tag added by a mailing list ("[list]") | Subject | Expected; DMARC may rely on SPF or ARC. See ARC |
| Link rewriting or tracking added by a security gateway | The body | Allowlist or accept; the first hop signature may still pass at the first checker |
| Line-ending or encoding conversion (for example 8-bit to quoted-printable) | The body bytes | Use 7-bit-safe encodings from the start |
| Header folding changes | Headers under simple canonicalization | Use relaxed |
| Signed header removed or changed | The listed header | Do not list headers that relays touch |
| Key rotated and DNS record removed too early | The key lookup | Keep old selectors published. See key rotation |
Auditing your configuration
- Send a test message from your real path to a mailbox you control and open the source.
- Read the DKIM-Signature header and list the names in
h=. Compare with the table above. - Confirm that
Fromis present and consider oversigning it. - Confirm
c=relaxed/relaxedand that there is nol=tag. - Check that List-Unsubscribe and List-Unsubscribe-Post are signed for bulk mail.
- Look at the verifying server's Authentication-Results line to see
dkim=passwith the expectedheader.d. See reading authentication results. - Send again through a forwarding address and a mailing list to see which parts survive.
- Document the intended header list and review it when you change platforms or add gateways.
Example: reading a signature
Suppose a signature has h=from:to:subject:date:message-id. This tells you that the sender chose not to sign Reply-To, MIME-Version, Content-Type or the List headers. A relay could therefore change the Reply-To header without breaking the signature, so replies could be redirected, and it could alter the Content-Type header, changing how the body is interpreted, though the body hash would still match the original bytes. Neither change is likely in practice, but both are exactly the kind of gap a thoughtful administrator closes. Expanding the list costs nothing as long as the headers are stable between the signer and the first verifier. Watch for headers that your own mail pipeline adds after signing, such as tracking identifiers or footers; do not include these in the signed list, and where possible move the signing step to the end of the pipeline so that it sees the message exactly as it will be transmitted.
Platform notes
Many sending platforms choose the header list for you and expose little control. In that case your job is to check, not to configure: confirm the signature covers From and the important headers, verify that the signing domain is your own (for DMARC alignment; see envelope From and header From) and ask the provider about oversigning if you have strict requirements. If you run your own signer, set the header list in one place and manage it with configuration management so every server signs the same way. When two systems sign the same message, as with a gateway that adds a second signature, both signatures can coexist; receivers evaluate each and DMARC passes if any aligned signature validates.
The header list is a small field with a large effect. Always sign From, sign the headers readers rely on, avoid those relays modify, use relaxed canonicalization and oversign where you can. Then verify with real messages, because configuration that looks right can still sign something different from what you expect.
Test your DKIM setup Check your selector, key and alignment.
References and further reading
Frequently asked questions
What is the h= tag in a DKIM signature?
A list of header names covered by the signature; headers not listed are not protected.
Must From be signed?
Yes. The standard requires it and DMARC alignment depends on it.
What is DKIM oversigning?
Listing a header name more times than it appears so that adding an extra copy later invalidates the signature.
Which canonicalization should I use?
Relaxed for both headers and body, because it tolerates harmless whitespace changes by relays.
Why does my signature fail after a mailing list?
The list modifies the subject or body, so the signed content no longer matches; ARC and SPF may preserve the result.