fix(emailauth): IDNA-encode domains before DMARC DNS lookups - #931
Merged
jiashuoz merged 1 commit intoAug 23, 2026
Merged
Conversation
normDomain lowercased and trimmed a domain but never converted it to its ASCII/punycode form. Every "_dmarc."+domain TXT lookup in the DMARC tree walk is built from that value, so a message with an internationalized From domain queried the raw Unicode label instead of the label the DNS zone actually publishes records under, and silently fell back to policy=none. internal/identity already has the same lowercase+idna.Lookup.ToASCII pattern for stored domains; this applies it to the inbound auth path too, with the same fallback to the unmodified string on an encoding error. Fixes tokencanopy#608
jiashuoz
approved these changes
Aug 23, 2026
jiashuoz
left a comment
Member
There was a problem hiding this comment.
Thanks for your contribution!!
Contributor
Author
|
Thanks for the quick review and merge. Glad the IDNA fix lines up cleanly with the pattern already in identity/store.go. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
normDomainlowercased and trimmed a domain but never converted it toits ASCII/punycode form. The DMARC tree walk builds every
_dmarc.<domain>TXT lookup from that value (discoverDMARCRecordWithEvaluator,walkDMARCTree), so a message with an internationalized From domainqueried the raw Unicode label instead of the label the DNS zone
actually publishes records under, and evaluation silently degraded to
policy=none.internal/identity.normalizeDomainalready doeslowercase +
idna.Lookup.ToASCIIfor stored domains; this applies thesame pattern to the inbound auth path, with the same fallback to the
unmodified string on an encoding error.
Operational risk
None outside the emailauth package.
normDomainalso feeds thedisplayed SPF/DKIM domain fields; those are already-ASCII values in
practice (SMTP HELO and DKIM
d=tags), and the full existing suitefor this package (including those cases) is unchanged by this diff.
Test plan
TestEvaluateDMARCEncodesUnicodeFromDomainForLookup(new):fails on
main(queries_dmarc.münchen.example, the recordunder the punycode name is never found), passes on this branch.
go test ./internal/emailauth/...: full package suite green.go build ./...andgo test ./...: unaffected elsewhere.domain (
fakeTXTResolveronly); the query-name construction is whatthis fix changes and what the test asserts.
Fixes #608