skip to content

Signature Verification

The verifier fetches the key named by s= and d=, recomputes the body hash, then checks the signature: pass, fail, temperror or permerror. Interviewers ask why a DNS timeout is not a forgery.

on this pageshow

explore

questions

5

What does a DKIM fail result tell a receiver about a message, and why is it treated like an unsigned message?

level: juniorimportance: must knowfreq 48%

answer

  1. integrity, not identity
  2. survivability in transit not guaranteed
  3. lists and gateways edit messages
  4. RFC 6376 section 6.1 SHOULD NOT

basics

~20 s

DKIM fail means a checkable signature did not match the message as received, so it vouches for nothing. It is not proof of forgery: relays that modify mail break honest signatures, so RFC 6376 says treat it like an unsigned message.

solid answer

~50 s

When a verifier recomputes the body hash or checks the `b=` signature and the check fails, RFC 6376 returns PERMFAIL for that signature, and `Authentication-Results` (RFC 8601) records `dkim=fail`: the message was signed, the signature was acceptable, and it failed verification. The cause can be tampering, but far more often it is an intermediary that changed a signed header field or the body: a list footer, a tagged subject, a gateway that re-encodes a part. Because survivability in transit is not guaranteed, RFC 6376 section 6.1 says a verifier SHOULD NOT treat a message with only bad signatures differently from one with no signature, and section 6.3 says unverifiable mail SHOULD be treated like all unverified mail. A fail removes a positive signal; it adds no negative one. What the From domain asks receivers to do with unauthenticated mail is a separate, DMARC-level question.

go deeper

for a junior

Recall the plain meaning: a fail is a signature that did not match the message as received, and receivers treat it like no signature at all.

for a middle

Explain where the mismatch arises, the body hash or the header signature, and why list footers and gateways cause most fails on legitimate mail.

for a senior

Show you would read the verifier's logged reason and look for a second valid signature before calling a fail spoofing, and keep fail apart from temperror and permerror.

for a principal

Frame the incentive argument: penalising a fail more than unsigned mail only hurts honest mail broken in transit, so enforcement belongs in a domain-level policy, not in DKIM alone.

## What a DKIM fail means A **DKIM signature** is a `DKIM-Signature` header field that a signing domain, named in `d=`, adds to a message. A receiver, the **verifier**, fetches the public key the signature names, recomputes two hashes over the message as it arrived, and checks them against the values the signature carries. RFC 6376 (September 2011) ends the evaluation of each signature in one of three states, and RFC 8601 (May 2019) gives the names a receiver writes into `Authentication-Results`: | RFC 6376 state | Typical RFC 8601 result | Meaning | |---|---|---| | SUCCESS | `pass` | the key was found and both checks matched | | PERMFAIL | `fail`, `permerror` or `neutral` | a permanent problem: a hash mismatch, a missing or revoked key, a malformed signature | | TEMPFAIL | `temperror` | a transient problem, such as a key lookup that got no answer | RFC 8601 defines `fail` narrowly: the message was signed, the signature was acceptable to the receiving domain, and it **failed the verification test**. In practice the recomputed body hash did not match `bh=`, or the `b=` signature did not verify against the hash of the signed header fields. Something in the signed content is not what the signer hashed. ## Why honest mail fails A fail tells you the bytes changed, not who changed them or why. Most fails on legitimate mail come from intermediaries that edit messages for their own reasons: - a discussion list that appends a footer or adds a tag to the `Subject`; - a gateway or scanner that re-encodes a body part, rewrites links or adds a disclaimer; - a relay that re-folds or alters a signed header field in a way the chosen normalisation does not absorb; - a forwarder that edits the message instead of passing it on unchanged. A message relayed **without** modification keeps a valid signature, because the signature travels inside the message and does not depend on which server delivered it. That is why DKIM usually survives plain forwarding, and why a fail points at modification rather than at the delivery path. Which normalisation choices tolerate which edits is covered with DKIM canonicalization. ## Why a fail is treated like no signature RFC 6376 section 6.1 says that because 'survivability of signatures after transit is not guaranteed', a verifier **SHOULD NOT** treat a message that has one or more bad signatures and no good signature differently from a message with no signature at all. Section 6.3 repeats it: mail that cannot be verified SHOULD be treated the same as all unverified mail, 'regardless of whether or not it looks like it was signed'. The reasoning is about incentives: 1. Penalising a fail more than an unsigned message protects nothing, because a sender with bad intent can simply send the message unsigned. 2. The only mail the extra penalty would catch is honest mail broken in transit by lists and gateways. 3. So a fail **removes a positive signal**: the receiver cannot attach the signing domain's reputation to this message. By itself it adds no negative one. RFC 8601 makes the same point from the reporting side: a report of `fail` lets a downstream consumer decide how to handle it, while `neutral` or `none` pre-empts that choice and forces unsigned treatment. The key record carries a stricter version of the same rule. When the signer's key record has the testing flag `t=y`, verifiers **MUST NOT** treat its mail differently from unsigned mail, even when the signature fails; they MAY track the results to help the signer. ## What fail is not | Result | What happened | Same as fail? | |---|---|---| | `none` | the message carried no signature | no | | `temperror` | the key could not be fetched right now | no, a later attempt may verify | | `permerror` | an unrecoverable error, such as a missing required header field | no, no comparison was possible | | `policy` | some aspect of the signature was unacceptable to the receiving domain | no | Confusing these leads to wrong conclusions. A `temperror` is a DNS problem, not a broken signature. A `policy` result says the receiving domain found some aspect of the signature unacceptable, not that the hashes mismatched. ## What the mail operator does with a fail - Read the **reason** the verifier logged; RFC 6376 section 6.3 says the exact cause SHOULD be made available, which separates a body-hash mismatch from a header-signature mismatch. - Check for **another signature** on the same message. A list or forwarder that modifies mail often adds its own, and a signature that verifies gives the message a valid signature for that signature's domain. - Look for the intermediary in the path before assuming spoofing. - Leave the question of what the From domain asked receivers to do with unauthenticated mail to its DMARC policy, a separate evaluation built on top of this result. A DKIM fail, in short, is a statement about **integrity in transit**: the signature can no longer vouch for the message. On its own it is never proof that someone forged it.

  • Why would a verifier record permerror rather than fail for a signed message?
    `fail` is for a signature that could be checked and did not match. `permerror` is for one that could not be checked at all, for a reason that will not go away: RFC 8601's example is a required header field being absent. RFC 6376 returns PERMFAIL in both kinds of case, so both are permanent; only `fail` says the hashes were actually compared.
  • Does a DKIM fail on mail whose key record carries t=y change how the receiver may treat it?
    It makes unsigned treatment mandatory rather than recommended. `t=y` marks a domain that is testing DKIM, and RFC 6376 says verifiers MUST NOT treat such mail differently from unsigned mail, even when the signature fails; they MAY track the results to help the signer. It is a debugging signal for the signer, not a filtering signal for the receiver.

A DKIM signature is like a wax seal across the flap of a letter. A broken seal tells you the letter was opened or altered on the way; it does not tell you the letter is fake, and you would not trust it less than a letter that never had a seal. You simply cannot lean on the seal any more.

  • A DKIM fail proves the message was forged or spoofed.
  • A failed signature should score worse than an unsigned message.
  • temperror is just another name for a failed signature.
  • Forwarding a message unchanged always breaks its DKIM signature.
  • A policy result means the signature's hashes did not match.
open as a page

How does a receiver verify a DKIM-Signature header field, in order, from parsing its tags to a pass result?

level: middleimportance: must knowfreq 40%

basics

~20 s

The verifier validates the DKIM-Signature tags, fetches the public key from the TXT record at s=._domainkey.d=, recomputes the body hash and compares it with bh=, then checks the b= signature over the h= header fields and the signature field itself.

open as a page

A message carries two DKIM signatures, one rsa-sha1 and one rsa-sha256; under RFC 8301, how does a verifier evaluate them?

level: middleimportance: should knowfreq 22%

basics

~20 s

Each DKIM signature is judged on its own. Under RFC 8301 (January 2018) the rsa-sha1 one has permanently failed and is ignored; if the rsa-sha256 one verifies with an RSA key of at least 1024 bits, the message has a valid signature.

open as a page

An inbound gateway logs intermittent DKIM temperror results on a partner's mail because the partner's DNS times out; why is that not a forgery, and how should the gateway respond?

level: seniorimportance: should knowfreq 30%

basics

~20 s

A timeout means the verifier never got the key, so it learned nothing about the signature: RFC 6376 calls that TEMPFAIL, recorded as temperror. Treat the mail as unverified, optionally defer it with 451 4.7.5, and never reject it as forged.

open as a page

A legitimately DKIM-signed message is resent intact to thousands of new recipients and still passes; why does it verify, and what limits DKIM replay?

level: seniorimportance: nice to knowfreq 14%

basics

~20 s

DKIM signs the h= header fields and the body, not the SMTP envelope, so a signed message re-sent to new recipients still verifies. RFC 6376 offers only partial limits, reputation and spotting one signature on unusual volume, and x= is not one.

open as a page