Lookalike Email Domains: Detect Unicode Homographs Safely
security@acme.example and security@аcme.example do not have the same domain. The first character in the second domain is Cyrillic а (U+0430), not Latin a (U+0061).
A safe detector should convert the domain through IDNA, inspect its scripts, and compare a Unicode confusable skeleton with domains your users already trust. Punycode or mixed scripts can raise the priority, but neither one proves abuse.
That last boundary matters. Legitimate internationalized domains also become xn-- labels. Blocking every one would turn a useful security control into an internationalization bug.
Why can two sender domains look the same?
Unicode contains characters from different writing systems that can look alike. In the example above, the two code points render almost identically in many fonts:
acme.example U+0061 LATIN SMALL LETTER A
аcme.example U+0430 CYRILLIC SMALL LETTER A
The Unicode Consortium's UTS #39 confusable-detection model calls strings confusable when their computed skeletons match. Its own mixed-script example compares Latin paypal with a version whose two a characters are Cyrillic.
The companion confusables data file maps U+0430 to U+0061 for that comparison. This is not visual guesswork and it is not a homemade alphabet swap. It is versioned Unicode data.
Email authentication does not collapse these names into one identity. DMARC can protect acme.example from unauthorized use of that exact From domain, but a separately registered lookalike is outside the original domain's policy. I covered that boundary in what DMARC blocks and what it misses.
Punycode is a transport form, not a threat verdict
Internationalized domain names have a Unicode form for people and an ASCII-compatible form for DNS. RFC 5890 calls them U-labels and A-labels. An A-label starts with xn-- and carries a Punycode encoding.
That means both a deceptive lookalike and an ordinary internationalized domain can contain xn-- on the wire:
аcme.example → xn--cme-5cd.example
bücher.example → xn--bcher-kva.example
The first domain collides visually with a protected ASCII name. The second is a single-script Latin label and does not collide with either protected name in my test. A rule that says “Punycode equals phishing” loses this distinction.
UTS #46 uses Bücher.de → xn--bcher-kva.de → bücher.de to show the normal round trip. IDNA conversion answers how to represent and validate the domain. Confusable detection answers a different question: could another identifier be mistaken for one you care about?
A useful detector needs a reference set
Similarity becomes actionable only in context. Compare an incoming sender domain with your own domains, important partner domains, and other names your users are expected to trust. Comparing every domain with every possible string creates noise without a decision.
I use four stages:
- Convert the submitted U-label or A-label to one validated ASCII form, then recover its Unicode form for inspection.
- Record whether the Unicode form mixes scripts. Treat digits, punctuation, and other Common or Inherited characters according to Unicode's resolved-script rules.
- Compute a skeleton using a pinned release of the Unicode confusables data.
- Compare that skeleton with skeletons precomputed for the protected-domain set.
A skeleton collision is the strongest signal in that sequence because it relates the observed name to a specific trusted name. It is still a review signal, not a verdict about the sender's intent.
Mixed-script checks are useful, but they are not complete. UTS #39 defines single-script, mixed-script, and whole-script confusables. An all-Cyrillic lookalike can therefore evade a simple “more than one script” rule. ASCII substitutions such as 1 for l also need typo or confusable logic even though every character is ASCII or Common.
I ran a four-domain fixture
The fixture below keeps three Unicode mappings visible so the example can be audited. Production code should load the complete, versioned confusables.txt file or use a maintained implementation. Its script helper is also a deliberately small Latin, Cyrillic, and Greek subset, not a full implementation of UTS #39's resolved-script algorithm.
import { domainToASCII, domainToUnicode } from 'node:url'
const confusables = new Map([
['\u0430', 'a'], // Cyrillic small a
['\u03bf', 'o'], // Greek small omicron
['\u04cf', 'l'], // Cyrillic small palochka
])
const protectedDomains = new Set(['acme.example', 'portal.example'])
function skeleton(value) {
return [...value.normalize('NFD')]
.map(character => confusables.get(character) ?? character)
.join('')
.normalize('NFD')
.toLowerCase()
}
function scripts(value) {
const found = new Set()
for (const character of value) {
if (/\p{Script=Latin}/u.test(character)) found.add('Latin')
else if (/\p{Script=Cyrillic}/u.test(character)) found.add('Cyrillic')
else if (/\p{Script=Greek}/u.test(character)) found.add('Greek')
}
return [...found]
}
function inspectDomain(input) {
const ascii = domainToASCII(input).toLowerCase()
if (!ascii) return { input, decision: 'invalid_domain' }
const unicode = domainToUnicode(ascii).toLowerCase()
const scriptSet = scripts(unicode)
const candidate = skeleton(unicode)
const collision = [...protectedDomains].find(
domain => skeleton(domain) === candidate && domain !== unicode
)
const signals = []
if (ascii.startsWith('xn--') || ascii.includes('.xn--')) signals.push('idn')
if (scriptSet.length > 1) signals.push('mixed_script')
if (collision) signals.push(`confusable_with:${collision}`)
return {
input,
ascii,
scripts: scriptSet,
skeleton: candidate,
signals,
decision: collision ? 'review' : 'continue_normal_checks',
}
}
Node's current domainToASCII() documentation says an invalid domain returns an empty string. The inverse domainToUnicode() lets the detector inspect the same A-label whether the input arrived in Unicode or Punycode form.
I ran four hypothetical .example domains through this function. The output was:
acme.example
ascii=acme.example
scripts=Latin
signals=[]
decision=continue_normal_checks
аcme.example
ascii=xn--cme-5cd.example
scripts=Cyrillic,Latin
signals=idn,mixed_script,confusable_with:acme.example
decision=review
bücher.example
ascii=xn--bcher-kva.example
scripts=Latin
signals=idn
decision=continue_normal_checks
xn--bcher-kva.example
ascii=xn--bcher-kva.example
scripts=Latin
signals=idn
decision=continue_normal_checks
The Unicode and A-label forms of bücher.example converge on the same inspection result. The lookalike converges on a skeleton collision with acme.example. That is the behavior worth preserving when this becomes a service or an inbound-mail rule.
What should happen after a collision?
Keep the evidence and the action separate. Store the original domain, canonical A-label, Unicode display form, scripts, Unicode-data version, matched protected domain, and the rule that raised the signal. That makes a later review explainable.
For an inbound message, a high-confidence collision can add a warning, increase authentication and content scrutiny, or hold a sensitive workflow for human review. Do not silently rewrite the From domain to the protected one. Do not claim the address belongs to the protected organization.
For signup, a lookalike signal may justify added friction when a person claims an affiliation, but it says nothing about mailbox existence or inbox ownership. Run ordinary syntax, DNS, verification, and confirmation checks as separate stages. The SMTPUTF8 guide explains why Unicode domains and Unicode local parts also need separate handling.
The strongest objection is that legitimate names can still collide. That is true. Unicode itself warns that broad confusable matching can flag many legitimate strings. A detector is useful when it narrows a specific trust decision, preserves its evidence, and gives legitimate internationalized domains a path through normal checks.
The practical rule is small: compare canonical domains and skeletons against a protected set, escalate collisions, and let Punycode or script mixing contribute evidence without becoming a verdict.