Link-safety on click: warn when visible link text is a URL that differs from the real destination #122

Closed
opened 2026-09-17 15:43:35 -04:00 by jared · 1 comment
Owner

Classic phishing shape: <a href="https://evil.example/login">https://matrix.lotusguild.org/login</a>. The timeline renders the visible text; the click goes elsewhere.

Scope

  • At render (react-custom-html-parser <a> branch): if the anchor's visible text parses as a URL (or looks like a hostname) and its origin differs from href's origin, mark the anchor. On click: intercept and show a small confirm — "This link shows matrix.lotusguild.org but goes to evil.example. Open anyway?" — with Open / Cancel. No confirm for honest links; no setting.
  • Also cover the "IDN homograph" case cheaply: if href hostname contains non-ASCII / punycode (xn--), show the punycode form in the confirm.
  • Exempt: matrix.to / permalinks, mailto:, links whose text is a shortened form of the same origin (e.g. text youtube.com/… for a www.youtube.com href — compare registrable domain, not full host).
  • Unit tests on the "text vs href" comparator (utils/linkSafety.ts).
Classic phishing shape: `<a href="https://evil.example/login">https://matrix.lotusguild.org/login</a>`. The timeline renders the visible text; the click goes elsewhere. ### Scope - At render (react-custom-html-parser `<a>` branch): if the anchor's visible text parses as a URL (or looks like a hostname) and its origin differs from `href`'s origin, mark the anchor. On click: intercept and show a small confirm — "This link shows **matrix.lotusguild.org** but goes to **evil.example**. Open anyway?" — with *Open* / *Cancel*. No confirm for honest links; no setting. - Also cover the "IDN homograph" case cheaply: if `href` hostname contains non-ASCII / punycode (`xn--`), show the punycode form in the confirm. - Exempt: matrix.to / permalinks, `mailto:`, links whose text is a *shortened* form of the same origin (e.g. text `youtube.com/…` for a `www.youtube.com` href — compare registrable domain, not full host). - Unit tests on the "text vs href" comparator (`utils/linkSafety.ts`).
jared added this to the Features 2026-Q4 milestone 2026-09-17 15:43:35 -04:00
jared added the enhancementpriority: mediumsecurityarea: messaging labels 2026-09-17 15:43:35 -04:00
jared self-assigned this 2026-09-17 15:43:35 -04:00
Author
Owner

Done in 74d8e311. utils/linkSafety.ts compares the registrable domain the visible text claims (when it looks like a URL/host) with the href's; a mismatch, or a punycode (IDN) destination, renders the anchor as SuspiciousLink, whose click opens a confirm — "It shows matrix.lotusguild.org but goes to evil.example." with the full URL, Cancel / Open anyway (new tab, noopener). Honest links are untouched: same registrable domain (youtube.com text over www.youtube.com, bbc.co.uk over news.bbc.co.uk), plain-word text, mailto:, matrix.to and Lotus permalinks, anchors with non-text children. Comparator unit-tested (incl. a Cyrillic-а paypal homograph). Verified headless: the phish and IDN messages are flagged, the honest ones are not, click shows the confirm and does not navigate, Cancel stays, Open anyway opens the real target.
confirm

Done in `74d8e311`. `utils/linkSafety.ts` compares the registrable domain the visible text claims (when it looks like a URL/host) with the href's; a mismatch, or a punycode (IDN) destination, renders the anchor as `SuspiciousLink`, whose click opens a confirm — "It shows **matrix.lotusguild.org** but goes to **evil.example**." with the full URL, *Cancel* / *Open anyway* (new tab, noopener). Honest links are untouched: same registrable domain (`youtube.com` text over `www.youtube.com`, `bbc.co.uk` over `news.bbc.co.uk`), plain-word text, `mailto:`, matrix.to and Lotus permalinks, anchors with non-text children. Comparator unit-tested (incl. a Cyrillic-а paypal homograph). Verified headless: the phish and IDN messages are flagged, the honest ones are not, click shows the confirm and does not navigate, Cancel stays, Open anyway opens the real target. ![confirm](https://code.lotusguild.org/attachments/0273d527-bd34-468a-8af4-8d9617ce5429)
jared closed this issue 2026-09-19 23:19:58 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: LotusGuild/cinny#122