skip to content

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%

answer

  1. no key, no comparison
  2. no answer versus no record
  3. TEMPFAIL may be retried later
  4. 451 4.7.5, never 4xx for crypto

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.

solid answer

~50 s

A signature can only fail once the verifier holds the key and has compared hashes. When the TXT query for the key gets no response, RFC 6376 section 6.1.2 says the verifier MAY return TEMPFAIL (key unavailable) and try later; RFC 8601 records that as `temperror`. Contrast PERMFAIL: an authoritative answer that the record does not exist, a malformed record, or an empty `p=`. The gateway has two honest options: accept the message and treat it as unverified, since RFC 6376 section 6.3 says acceptability SHOULD NOT rest solely on an unverifiable signature, or defer it with `451 4.7.5` so the partner's MTA retries. RFC 6376 reserves 4xx for such temporary conditions, and verification failures MUST NOT get one. Then diagnose: read the logged reason, query the key name from your own resolver and from elsewhere, and tell the partner which name times out.

go deeper

for a junior

Recall the difference: fail means the signature was checked and did not match; temperror means the key could not be fetched, so nothing was checked.

for a middle

Explain which DNS outcomes give TEMPFAIL and which give PERMFAIL: no answer against no record, a malformed record and an empty p=.

for a senior

Show the diagnosis and the response: read the logged reason, separate the partner's DNS from your own resolver, and choose between 451 4.7.5 deferral and treating the mail as unverified.

for a principal

Weigh the receiving policy: how long to defer on temperror before accepting, and why turning DNS outages into rejections costs more than it protects.

## Three outcomes, and why the third exists RFC 6376 (September 2011) ends the evaluation of every DKIM signature in one of three states: **SUCCESS**, **PERMFAIL** ('a permanent, non-recoverable error such as a signature verification failure') and **TEMPFAIL** ('a temporary, recoverable error such as a DNS query timeout'). RFC 8601 (May 2019) records results in `Authentication-Results` with finer names: | RFC 8601 result | Meaning | Will a later attempt help? | |---|---|---| | `pass` | the signature verified | not needed | | `fail` | the signature was checked and did not verify | no | | `permerror` | could not be verified, for an unrecoverable reason | unlikely | | `temperror` | could not be verified, for a likely transient reason such as a key that could not be retrieved | possibly | The split matters because a signature can only **fail** once the verifier holds the key and has compared hashes. Without the key there is no comparison, so there is nothing to say about authenticity either way. ## Where a key lookup can end The verifier asks DNS for the TXT record at the selector, the `_domainkey` label and the `d=` domain, for example `s2026a._domainkey.example.net`. RFC 6376 section 6.1.2 sorts the outcomes: 1. **No response**: the query times out or the name servers cannot be reached. The verifier MAY return TEMPFAIL (key unavailable) and seek a later attempt. 2. **The record does not exist**: the domain's servers answer that there is no such record. The verifier MUST return PERMFAIL (no key for signature). 3. **A malformed record**, or a version or key type the verifier does not support: PERMFAIL. 4. **An empty `p=`**: the key has been revoked, PERMFAIL. RFC 6376 defines no difference between a revoked key and a removed one. 5. **A usable key**: verification continues to the hashes. Case 1 is the partner's problem in this scenario. Case 2 can look similar in a log but is the opposite kind: the partner's DNS answered, and the answer is that the key is not there, perhaps because of a selector typo, a deleted record or a key retired too early. ## Why a timeout is not a forgery - The cryptographic check never ran, so the signature has not been shown false. - The cause sits in DNS, at the partner's name servers, on a network path or in the receiver's own resolver, not in the message. - The same message may verify an hour later, once the lookup succeeds. - RFC 6376 section 6.3 says modules consuming DKIM output SHOULD NOT decide acceptability solely on an unverifiable signature, because 'such rejection would cause severe interoperability problems'. Treating a temperror as a forgery turns a DNS outage into lost mail. ## The gateway's choices When no signature verified and at least one ended in TEMPFAIL, RFC 6376 gives a receiver two honest options: 1. **Accept and treat as unverified.** The message is handled like any mail without a valid signature; this time it gets no benefit from the partner's reputation. 2. **Defer.** A verifier integrated in the MTA MAY answer with `451 4.7.5`, as in RFC 6376's own example, `451 4.7.5 Unable to verify signature - key server unavailable`, so the partner's MTA queues the message and retries. RFC 6376 limits deferral: temporary failures such as an unreachable key server are the **only** conditions that SHOULD use a 4xx reply, and cryptographic verification failures **MUST NOT** provoke one. A gateway that defers on temperror should cap how long it does so, because a message deferred for days behind a persistently broken DNS will eventually bounce at the sender; accepting and relying on other evidence is the gentler choice. What DMARC does with a temporary error is covered with DMARC enforcement; at the DKIM layer the result is simply 'not verified yet'. ## Working the partner case - Pull the verifier's logged reason; RFC 6376 says the exact cause SHOULD be made available for diagnosis. Confirm it is 'key unavailable', not 'no key for signature'. - Note the selector and domain each time. Intermittent failures on a single name suggest one misbehaving name server among several. - Resolve the key name from the gateway's own resolver and from a resolver elsewhere, to separate the partner's DNS from your resolver or network path. - Check whether the messages carry a second signature that did verify; if so, the message already has a valid signature. - Tell the partner which name times out and when; the fix is on their side. ## What not to do - Do not reject with a 5xx on temperror. - Do not record it as `fail`: the hashes were never compared. - Do not treat permanent causes such as an empty `p=` or a missing record as transient; retrying will not create a key.

  • The same partner's logs suddenly show PERMFAIL (no key for signature) instead; what changed?
    The partner's DNS now answers, and the answer is that no key record exists at that selector name. That is permanent, so retrying will not help. Likely causes are a deleted or renamed record, a selector typo in the signer's configuration, or a key retired while mail signed with it was still in flight; the partner must publish the record the signatures name.
  • Why does RFC 6376 forbid a 4xx reply for a DKIM signature that did not verify?
    A 4xx tells the sending MTA to retry, and retrying cannot change a cryptographic result: the same bytes give the same mismatch. Deferring would only delay mail and fill queues. RFC 6376 reserves 4xx for temporary conditions such as an unreachable key server, the one case where a later attempt can give a different answer.

  • A DKIM temperror means the signature was forged.
  • A temperror should be rejected with a 5xx like any failed signature.
  • A missing key record is a temporary error that will fix itself.
  • Deferring with a 4xx is right for any DKIM failure.
  • temperror and fail mean the same thing in Authentication-Results.