Skip to content

Proposal: Add homoglyph and keyboard-adjacent checks #7

@andrew

Description

@andrew

While researching typosquatting across package registries, I found two attack vectors not currently covered by typomania that have been used in documented malicious packages.

Proposed checks

1. Homoglyph

Replaces characters with visually similar alternatives:

  • l1, i, I, |
  • o0
  • e3
  • a4
  • s5
  • rnm
  • vvw

Documented attacks:

2. Keyboard-adjacent

Replaces characters with adjacent keys on QWERTY:

  • sa, z, w, d
  • ew, r, d
  • oi, p, k, l
  • etc.

This is distinct from the existing typos check which targets common misspellings. Keyboard-adjacent systematically generates all single-character replacements based on physical key proximity.

Documented attacks:

All examples above are from the ecosyste-ms/typosquatting-dataset.

Variant generation

For a 10-character package name, keyboard-adjacent generates roughly 50-80 single-character variants (depends on which characters appear). This is comparable to the existing omitted check which generates n * alphabet_size candidates.

I ran both checks against critical packages on RubyGems and crates.io (~2000 packages). After filtering out packages with high download counts or that predate their targets, the results were manageable - dozens of candidates per registry, not thousands.

Implementation

Both checks are lookup tables. Reference implementations in Ruby:

Happy to submit PRs if there's interest.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions