Try it Live
Run ENS examples in the interactive playground
ENS Security
An ENS name that looks right can resolve to an attacker’s address. The defense is one rule: normalize every untrusted name withnormalize() before you hash, store, compare, or display it. The hash functions do not do this for you.
What the module enforces
Normalize before hashing
namehash() and labelhash() hash the exact UTF-8 bytes you pass. Two spellings of one name produce two different nodes:
namehash also skips empty labels, so "a..eth" hashes like "a.eth". normalize() rejects "a..eth". Skipping normalization turns a malformed name into a real-looking node.
Homograph attacks
A homograph replaces a character with an identical-looking one from another script.DisallowedCharacterError with a cause message containing illegal mixture. Digits count too: "1١.eth" (ASCII 1 + Arabic-Indic 1) is rejected.
Whole-script confusables
A label written entirely in one script can still look like a label in another:Invisible characters
ENSIP-15 treats invisible characters in two ways. Know which applies:Look-alike dots
Only U+002E separates labels. Characters that render as a dot are rejected rather than treated as separators:The brand is not a check
from() brands any string. is() accepts any non-empty string, including " " and "VITALIK.ETH". Neither proves the name is safe. See Branded Ens.
Display
- Show users the output of
normalize()orbeautify(), never their raw input. beautify()adds emoji presentation selectors and rendersξasΞin non-Greek labels. It is for display only. Hash thenormalize()output.- Neither function detects names that are valid but merely similar (for example
vitalik.ethandvita1ik.eth). Both are valid ASCII. Confirm the resolved address with the user.
Checklist
- Reject empty input yourself:
normalize("")returns""without throwing. - Call
normalize()on every user-supplied name and catchDisallowedCharacterError. - Hash only the normalized string.
- Store and compare normalized strings.
- Display
normalize()orbeautify()output, and show the resolved address.
See Also
- ENS Overview
- Normalization
- Validation
- Errors
- ENSIP Standards
- ENSIP-15 - Normalization standard, including confusable rules

