Skip to main content

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 with normalize() 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.
ENSIP-15 allows one script per label (with defined exceptions such as common punctuation and emoji). Mixing scripts throws 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:
Because ignored characters are removed, the raw input and the normalized output can differ in length and bytes. Always resolve and display the normalized output, never the raw input.

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() or beautify(), never their raw input.
  • beautify() adds emoji presentation selectors and renders ξ as Ξ in non-Greek labels. It is for display only. Hash the normalize() output.
  • Neither function detects names that are valid but merely similar (for example vitalik.eth and vita1ik.eth). Both are valid ASCII. Confirm the resolved address with the user.

Checklist

  1. Reject empty input yourself: normalize("") returns "" without throwing.
  2. Call normalize() on every user-supplied name and catch DisallowedCharacterError.
  3. Hash only the normalized string.
  4. Store and compare normalized strings.
  5. Display normalize() or beautify() output, and show the resolved address.

See Also