Skip to content

feat: add Homoglyph and KeyboardAdjacent checks#8

Open
andrew wants to merge 1 commit into
rustfoundation:mainfrom
andrew:feat/homoglyph-keyboard-checks
Open

feat: add Homoglyph and KeyboardAdjacent checks#8
andrew wants to merge 1 commit into
rustfoundation:mainfrom
andrew:feat/homoglyph-keyboard-checks

Conversation

@andrew
Copy link
Copy Markdown

@andrew andrew commented May 11, 2026

Adds two checks for typosquatting vectors that have shown up in real attacks across npm and PyPI.

Homoglyph substitutes visually similar characters. Covers single-character confusables (1l, 0o, 5s) and multi-character sequences that render like a single glyph (rnm, vvw, cld). Catches 1odashlodash, r3questsrequests.

KeyboardAdjacent replaces single characters with physically adjacent QWERTY keys. Distinct from Typos in that it's systematic rather than a curated misspelling list. Catches requezts/requeatsrequests.

Both ship with default tables via Default and accept custom tables via new() (e.g. for non-QWERTY layouts). Both iterate with char_indices() and len_utf8() so they don't add to the UTF-8 concerns in #4.

I haven't added them to the default Harness::builder() set since that would change behaviour for existing users, though neither needs ecosystem-specific config so they'd qualify. Happy to add if preferred.

Closes #7

Adds two checks for documented typosquatting attack vectors:

- Homoglyph: visually similar character substitution (1↔l, 0↔o,
  rn↔m, vv↔w, etc). Catches attacks like 1odash→lodash and
  r3quests→requests.
- KeyboardAdjacent: single-character replacement with physically
  adjacent QWERTY keys. Catches attacks like requezts→requests.

Both ship with default lookup tables and accept custom tables via
new(). Both use char_indices()/len_utf8() so they are safe on
non-ASCII package names.

Closes rustfoundation#7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Proposal: Add homoglyph and keyboard-adjacent checks

1 participant