Homoglyph Guard

Flags look-alike, mixed-script, styled and invisible characters in usernames and domains, such as pаypal.com with a Cyrillic а.

StopsHelps catch a spoofed username with Cyrillic letters

Installation

pnpm dlx shadcn@latest add https://bollard-ui.vercel.app/r/homoglyph-guard.json

The files land in your project. They're yours to edit.

Usage

homoglyph-guard-usage.tsx
import { HomoglyphGuard } from "@/components/ui/homoglyph-guard"

<HomoglyphGuard label="Payout domain" defaultValue={"p\u0430ypal.com"} protectedNames={["paypal"]} />

What it catches

  • Cyrillic, Greek and other cross-script look-alikes mixed into Latin text
  • Styled Unicode letters that fold to ASCII (fullwidth, mathematical)
  • Zero-width and other invisible characters
  • Imitations of names you protect, such as paypa1 or rnicrosoft

Props

HomoglyphGuard props
PropTypeDefault
label

Visible label.

string"Username"
hint

Helper text shown while nothing looks suspicious.

string—
value

Controlled value.

string—
defaultValue

Initial value when uncontrolled.

string""
onValueChange

Called with the new value on every change.

(value: string) => void—
protectedNames

Names this field must not imitate (your brand, staff handles). "paypa1" or "rnicrosoft" is flagged against them.

string[]NO_NAMES
warningMessage

Shown when look-alike, styled or invisible characters are found.

string"Contains characters that only look like plain letters."
impersonationMessage

Shown before a protected name the value imitates.

string"Looks like"
fixLabel

Text on the fix button, before the plain-ASCII value.

string"Use"
misreadMessage

Shown when only ambiguous plain characters (0/O, 1/l/I) are present.

string"Easy to misread when someone reads or types it:"
looksLikeLabel

Text before the character each finding imitates.

string"looks like"

* required. Also accepts the native props of <input> (className, aria-*, data-*…), passed through to it.

Accessibility

  • Visible label tied to the input, described by the report
  • Report is a polite live region; flagged characters are <mark> elements with their Unicode name as title
  • Fix button's aria-label includes the ASCII value it will set

Only what the source does. Test with your own screen reader and content before shipping.

Limitations

This is a UX guard rail. Enforce on the server: Normalise and run confusable checks on the server at registration and before display; client-side checks are easy to bypass.

  • Uses a curated look-alike table, not the full Unicode confusables.txt; rarer confusables are missed
  • Legitimate non-Latin names can be flagged as mixed-script
  • Advisory only; it does not reserve or block names

What it stops

Helps catch a spoofed username with Cyrillic letters

Also known as

homoglyph · homograph · lookalike · unicode spoofing · username · domain · punycode · impersonation

Field type

Dependencies

Pairs well with