What is an IDN homograph attack, and how do browsers and applications defend against it?
Answer
A homograph attack uses characters from different scripts that look identical, such as the Cyrillic а (U+0430) and the Latin a (U+0061), to register a domain that is visually indistinguishable from a real one. A victim sees what looks like apple.com or paytm.com in a link or address bar, but it is a completely different domain owned by the attacker. It is a phishing technique, and the defences are browser display rules, Unicode confusable detection, and not relying on how a URL looks.
How internationalized domains make this possible
Internationalized Domain Names (IDNs) let domains contain non-ASCII characters, such as Hindi or Tamil domain names. DNS itself only handles ASCII, so IDNs are converted to Punycode, an ASCII encoding with the xn-- prefix. For example, a domain written entirely in Cyrillic letters that resemble apple encodes to xn--80ak6aa92e.com. To DNS and the certificate authority it is just another domain, so the attacker can get a valid TLS certificate and the padlock appears.
In 2017 a researcher demonstrated exactly this with an all-Cyrillic apple.com lookalike that Chrome and Firefox displayed as apple.com, which led browsers to tighten their rules.
How browsers decide what to show
Modern browsers display the Unicode form only when it looks safe, and fall back to showing raw Punycode otherwise. Chromium's rules include:
Mixing scripts in one label (Latin plus Cyrillic) is shown as Punycode, with exceptions for common legitimate combinations such as Latin with Han and Japanese kana.
Whole-script confusables, where every letter is Cyrillic but the label looks like a Latin word, are shown as Punycode, especially when it matches a top domain.
Labels that resemble a popular domain in skeleton form (per Unicode TS #39 confusables) are flagged.
Firefox uses a similar algorithm based on Unicode restriction levels. Rules differ between browsers and apps, and email clients, chat apps and SMS often render Unicode freely, which is where most of these phishing links arrive.
Beyond domains
The same trick shows up in other places:
Usernames and display names: admin vs аdmin letting someone impersonate staff.
Package names: typosquatting and lookalike packages on npm and PyPI.
Source code: Trojan Source (CVE-2021-42574) used bidirectional control characters to make code display differently from how it compiles.
Simple ASCII lookalikes: rn vs m (rnicrosoft), 0 vs o, l vs I. No Unicode needed.
How applications should defend
Normalize identifiers with Unicode NFKC and compare using a confusable skeleton (Unicode TS #39) before allowing new usernames or org names.
Restrict usernames to a single script or to ASCII if your user base allows.
When displaying links in emails or chat, show the Punycode form for mixed-script or suspicious domains.
Register obvious lookalike domains of your own brand defensively and monitor certificate transparency logs for new certificates that resemble it.
For users: rely on bookmarks and password managers, which autofill only on the exact domain, and on phishing-resistant MFA like passkeys, which are bound to the real origin.
From lookalike text to attacker's server. Every step after the first sees a different domain; only the human is fooled.
Link shows аpple.com: First letter is Cyrillic U+0430.
Converted to Punycode: Domain becomes an xn-- ASCII label.
DNS lookup: Resolves to the attacker's IP address.
Valid TLS certificate: Issued for the xn-- domain, padlock shows.
Phishing login page: Victim enters real credentials.
Code examples
Revealing the real domain with Punycode (Node.js)
import { domainToASCII } from 'node:url';
const real = 'apple.com';
const fake = '\u0430pple.com'; // Cyrillic small a + 'pple.com'
console.log(real === fake); // looks the same, is not
console.log(domainToASCII(real));
console.log(domainToASCII(fake));
// Simple mixed-script check for a label
const hasLatin = /\p{Script=Latin}/u.test(fake);
const hasCyrillic = /\p{Script=Cyrillic}/u.test(fake);
console.log('mixed script:', hasLatin && hasCyrillic);
Converting to ASCII shows the true xn-- domain. A Unicode script check catches mixed-script labels before you display them or accept them as usernames.
Key points
Homographs use visually identical characters from different scripts, such as Cyrillic а vs Latin a
IDNs are encoded as Punycode (xn--) for DNS, and attackers can get valid TLS certificates
Browsers show Punycode for mixed-script and confusable labels, but rules vary by app
Unicode TS #39 defines confusable skeletons for detecting lookalikes
Passkeys and password managers resist homograph phishing because they bind to the exact origin
Common follow-up questions
What is Punycode and why do IDNs need it?
How would you stop users from registering a username that looks like 'admin'?
Why do passkeys resist phishing that fools humans?
What is the Trojan Source attack?
Interview tips
Show the Punycode conversion; it proves you understand that DNS sees a totally different name
Mention that a valid HTTPS padlock does not mean the domain is the real one
Extend the idea to usernames and package names to show you can apply it to your own app