Exclusifbêta

Lookalike <mv-lookalike>

Détection des sosies pour tout ce qui prétend venir de quelqu’un de confiance : enveloppez e-mails, fils de discussion, formulaires ou zones de collage, donnez-lui vos identités de confiance (trusted="Acme Bank <acme-bank.com>, @stripe.com, @northwind, Payroll <DE89 3704 …>") et chaque lien, expéditeur, adresse e-mail, @identifiant, nom de paquet ou d’utilisateur, IBAN et adresse de portefeuille du périmètre, y compris le texte brut et les champs pendant la saisie ou le collage, est comparé avec elles. Il repère les homoglyphes grâce à une table compacte de caractères confusables (un « а » cyrillique, un chiffre « 0 » à la place d’un « o », un « I » majuscule à la place d’un « l », « rn » pour « m », les lettres pleine chasse et accentuées), le punycode, les fautes de frappe (lettres en trop, manquantes, interverties ou remplacées, par distance d’édition pondérée), les mots ajoutés (« acme-bank-secure.com », mots d’appât signalés), les changements de TLD, les ruses de la marque en sous-domaine et du userinfo « [email protected] », les noms affichés et textes de lien qui revendiquent une marque à laquelle la vraie adresse n’appartient pas, et l’empoisonnement d’adresse de portefeuille (même début et même fin, milieu différent). Les éléments suspects reçoivent un soulignement ondulé et un bouton de signalement en ligne, avec des mots ; son panneau superpose la chaîne suspecte à celle de confiance, chaque caractère différent surligné et numéroté, puis explique un à un, en termes simples, chaque détail qui ne colle pas (« The “а” here is Cyrillic (U+0430), not the Latin letter “a”. »), avec un niveau de verdict (probably fine, looks like X, impersonates X) et des actions : Go to the real X, Use the real value pour les champs, Continue anyway (mv-lookalike-proceed annulable) et Report. Les clics sur les liens signalés sont interceptés avec cette confirmation, puis rejoués nativement. L’analyse est pure et indépendante du DOM (compare(a, b), check(value, trusted), checkLink(href, text, trusted), aussi disponible en MvLookalike.compare), si bien que les mêmes règles tournent sur le serveur.

CatégorieFeedback
TypeWeb Component (<mv-lookalike>)
Statutbêta
KitConfiance et vie privée
Installe aussibutton
Keywordsexclusive, culture, phishing, spoofing, impersonation, homoglyph, confusables, punycode, idn, typosquatting, lookalike-domain, link-safety, email-security, sender-verification, display-name, iban, wallet, address-poisoning, edit-distance, diff, security, trust

When to use

  • An inbox, support desk or chat shows links and senders that could impersonate your brand, your bank or your vendors
  • A payout or wire form must catch a payee email, IBAN or wallet address that is one character off a saved one
  • Admins paste domains, package names or usernames into allowlists and a near miss would open a hole
  • A server check and the UI must explain a spoofed link with the same rules and the same wording

Avoid when

  • The problem is hidden characters inside a typed value (zero-width spaces, exotic spaces, bidi controls), not imitation of a known name → use Invisibles instead
  • There is no list of trusted identities to compare against: generic phishing detection needs a server-side reputation service
  • A critical form value just needs to be echoed back for confirmation before submitting → use Read Back instead

Installation

node scripts/add.mjs lookalike --out ./src/marvelous

Agent IA avec le serveur MCP de Marvelous UI : install_components({ slugs: ["lookalike"], target_dir: "<absolute path>/src/marvelous", framework: "react" }).

Fichiers copiés (dépendances comprises) : tokens/tokens.css, core/base.css, core/dismiss.js, core/dom.js, core/element.js, core/position.js, components/lookalike/lookalike.js, components/lookalike/lookalike.css, components/button/button.css.

Utilisation

Démarrage rapide, le balisage minimal qui fonctionne :

<mv-lookalike trusted="Acme Bank <acme-bank.com>">
  <p>Your card is locked. Unlock it at <a href="https://acme-bank-secure.com/login">acme-bank-secure.com</a>.</p>
</mv-lookalike>

Balisage de référence : partez de celui-ci et personnalisez-le avec les attributs, data-* et les variables CSS :

<div id="lk-demo" style="width:min(100%,64rem);margin-inline:auto">
  <style>
    #lk-demo { display:grid; gap:1rem; align-content:start; font-size:.875rem }
    #lk-demo .lk-grid { display:grid; grid-template-columns:minmax(0,1.35fr) minmax(0,1fr); gap:1rem; align-items:start }
    #lk-demo .lk-card { min-width:0; border:1px solid var(--mv-border); border-radius:var(--mv-radius-xl); background:var(--mv-surface); box-shadow:var(--mv-shadow-sm); overflow:hidden }
    #lk-demo .lk-bar { display:flex; align-items:center; gap:.5rem; height:2.75rem; padding:0 1rem; border-bottom:1px solid var(--mv-border); color:var(--mv-fg-muted); font-size:.75rem; font-weight:500 }
    #lk-demo .lk-bar strong { color:var(--mv-fg); font-size:.8125rem; font-weight:600 }
    #lk-demo .lk-bar .mv-badge { margin-inline-start:auto }
    #lk-demo .lk-mail-head { display:grid; grid-template-columns:auto minmax(0,1fr); gap:.875rem; padding:1rem 1.125rem .875rem; border-bottom:1px solid var(--mv-border) }
    #lk-demo .lk-avatar { display:grid; place-items:center; width:2.25rem; height:2.25rem; border-radius:50%; background:var(--mv-bg-emphasis); color:var(--mv-fg); font-size:.8125rem; font-weight:600 }
    #lk-demo .lk-subject { margin:0 0 .25rem; font-size:1rem; font-weight:650; letter-spacing:-.01em; line-height:1.3 }
    #lk-demo .lk-meta { margin:0; color:var(--mv-fg-muted); font-size:.8125rem; line-height:1.7 }
    #lk-demo .lk-meta b { color:var(--mv-fg-subtle); font-weight:500; display:inline-block; min-width:2.25rem }
    #lk-demo .lk-from { color:var(--mv-fg); font-weight:500 }
    #lk-demo .lk-body { padding:1rem 1.125rem 1.125rem; line-height:1.65; color:var(--mv-fg) }
    #lk-demo .lk-body > p { margin:0 0 .75rem }
    #lk-demo .lk-body > p:last-child { margin:0; color:var(--mv-fg-muted); font-size:.75rem }
    #lk-demo .lk-body a:not(.mv-button) { color:var(--mv-accent); text-decoration-color:color-mix(in oklab,var(--mv-accent) 40%,transparent); text-underline-offset:.2em }
    #lk-demo .lk-form { display:grid; gap:.875rem; padding:1rem 1.125rem 1.125rem }
    #lk-demo .lk-field { display:grid; gap:.375rem; min-width:0 }
    #lk-demo .lk-field > span:first-child { color:var(--mv-fg-muted); font-size:.75rem; font-weight:500 }
    #lk-demo .lk-row { display:flex; align-items:center; gap:.25rem; min-width:0 }
    #lk-demo .lk-row .mv-input { flex:1 1 auto; min-width:0 }
    #lk-demo .lk-mono { font-family:var(--mv-font-mono); font-size:.8125rem }
    #lk-demo .lk-chat { display:grid; gap:.625rem; padding:1rem 1.125rem 1.125rem; max-height:13rem; overflow:auto }
    #lk-demo .lk-msg { display:grid; grid-template-columns:auto minmax(0,1fr); gap:.625rem; align-items:start }
    #lk-demo .lk-msg .lk-avatar { width:1.75rem; height:1.75rem; font-size:.6875rem }
    #lk-demo .lk-msg-who { margin:0; font-size:.75rem; font-weight:600 }
    #lk-demo .lk-msg-who span { color:var(--mv-fg-subtle); font-weight:400; margin-inline-start:.375rem }
    #lk-demo .lk-msg-text { margin:.125rem 0 0; line-height:1.55 }
    #lk-demo .lk-controls { display:flex; align-items:center; gap:.75rem 1.25rem; flex-wrap:wrap; padding:.875rem 1.125rem; border:1px solid var(--mv-border); border-radius:var(--mv-radius-xl); background:var(--mv-bg-subtle) }
    #lk-demo .lk-controls .lk-sep { flex:1 1 0 }
    #lk-demo .lk-ctl { display:flex; align-items:center; gap:.5rem; color:var(--mv-fg-muted); font-size:.75rem; font-weight:500 }
    #lk-demo .lk-log { margin:0; min-height:1.25rem; color:var(--mv-fg-subtle); font:.75rem/1.4 var(--mv-font-mono); flex:1 1 100% }
    #lk-demo .mv-choice { font-size:.8125rem }
    @media (max-width:52rem) { #lk-demo .lk-grid { grid-template-columns:minmax(0,1fr) } }
  </style>

  <mv-lookalike id="lk-main" show-verified trusted="Acme Bank <acme-bank.com>, Lumen Pay <lumenpay.com>, Northwind <northwind.io>, @northwind, Northwind payroll <DE89 3704 0044 0532 0130 00>, Treasury wallet <0x52908400098527886E0F7030069857D2E4169EE7>">
    <div class="lk-grid">
      <!-- An inbox message: sender, links and plain-text addresses are all checked -->
      <article class="lk-card" aria-label="Email message">
        <div class="lk-bar"><strong>Inbox</strong> · Finance shared mailbox <span class="mv-badge" data-variant="outline">Sep 24, 2026</span></div>
        <header class="lk-mail-head">
          <span class="lk-avatar" aria-hidden="true">AB</span>
          <div style="min-width:0">
            <h3 class="lk-subject">Unusual sign-in on your business account</h3>
            <p class="lk-meta"><b>From</b> <span class="lk-from" data-lookalike>Acme Bank Security &lt;[email protected]&gt;</span><br>
              <b>To</b> [email protected]</p>
          </div>
        </header>
        <div class="lk-body">
          <p>Hi Maya, we noticed a sign-in to your Acme Bank business account from São Paulo, Brazil on Sep 23, 2026 at 11:42 PM.</p>
          <p>If this wasn’t you, <a href="https://acmе-bank.com/secure/verify">confirm your identity</a> within 24 hours to avoid a hold on outgoing wires. You can also review recent activity at <a href="https://acme-bank.com.account-review.net/login">acme-bank.com/activity</a>.</p>
          <p>Card payments on your account are processed by lumenpay.co. For anything else, our help center is at <a href="https://acme-bank.com/help">acme-bank.com/help</a>.</p>
          <p>Acme Bank · 400 Harbor Boulevard, Boston, MA 02210</p>
        </div>
      </article>

      <div style="display:grid;gap:1rem;min-width:0">
        <!-- A payment form: fields are checked as you type or paste -->
        <form class="lk-card" aria-label="Send a payment" onsubmit="return false">
          <div class="lk-bar"><strong>Send a payment</strong> · Payouts</div>
          <div class="lk-form">
            <label class="lk-field"><span>Payee email</span>
              <span class="lk-row"><input class="mv-input" type="email" value="[email protected]" autocomplete="off"></span></label>
            <label class="lk-field"><span>Payee IBAN</span>
              <span class="lk-row"><input class="mv-input lk-mono" data-lookalike value="DE89 3704 0044 0532 0180 00" autocomplete="off" spellcheck="false"></span></label>
            <label class="lk-field"><span>Treasury wallet (USDC)</span>
              <span class="lk-row"><input class="mv-input lk-mono" data-lookalike value="0x5290c1b7f04a9d3e6628fb05ac91d7e30b4a9EE7" autocomplete="off" spellcheck="false"></span></label>
            <label class="lk-field"><span>Try it: type or paste any link</span>
              <span class="lk-row"><input class="mv-input" type="url" value="https://www.lumenpay-support.com/invoices" autocomplete="off" spellcheck="false"></span></label>
          </div>
        </form>

        <!-- A team chat: new messages are scanned as they arrive -->
        <section class="lk-card" aria-label="Team chat">
          <div class="lk-bar"><strong>#payouts</strong> · Team chat</div>
          <div class="lk-chat" id="lk-chat">
            <div class="lk-msg"><span class="lk-avatar" aria-hidden="true">JO</span><div><p class="lk-msg-who">Jonas Okafor<span>9:12 AM</span></p><p class="lk-msg-text">September payroll is approved, @northwind can release it.</p></div></div>
          </div>
        </section>
      </div>
    </div>
  </mv-lookalike>

  <div class="lk-controls">
    <label class="mv-choice"><input type="checkbox" role="switch" class="mv-switch" id="lk-intercept" checked> Confirm before opening flagged links</label>
    <span class="lk-ctl"><span id="lk-th-label">Flag from</span>
      <mv-segmented id="lk-threshold" aria-labelledby="lk-th-label" name="threshold" value="lookalike">
        <button value="fine">Similar</button>
        <button value="lookalike">Look-alike</button>
        <button value="impersonation">Impersonation</button>
      </mv-segmented>
    </span>
    <span class="lk-sep"></span>
    <button type="button" class="mv-button" data-variant="outline" data-size="sm" id="lk-incoming">Receive a chat message</button>
    <p class="lk-log" id="lk-log" aria-live="polite">Click a flag, or a flagged link, to see what doesn’t match.</p>
  </div>

  <script type="module">
    const lk = document.getElementById("lk-main");
    const log = document.getElementById("lk-log");
    const say = (text) => { log.textContent = text; };

    // Demo only: never actually open the fake addresses.
    lk.addEventListener("mv-lookalike-proceed", (e) => {
      e.preventDefault();
      lk.close();
      say(`mv-lookalike-proceed · would continue to ${e.detail.href ?? e.detail.value} (cancelled in this demo)`);
    });
    lk.addEventListener("mv-lookalike-report", (e) => say(`mv-lookalike-report · ${e.detail.verdict}: ${e.detail.value}`));
    lk.addEventListener("mv-lookalike-found", (e) => say(`mv-lookalike-found · ${e.detail.result.title}: ${e.detail.value}`));
    lk.addEventListener("click", (e) => {
      const real = e.target.closest?.(".mv-lookalike-real");
      if (real) { e.preventDefault(); say(`Would open the real site: ${real.href}`); }
    });

    document.getElementById("lk-intercept").addEventListener("change", (e) => { lk.intercept = e.target.checked ? "true" : "false"; });
    document.getElementById("lk-threshold").addEventListener("mv-change", (e) => { lk.threshold = e.detail.value; });

    const incoming = [
      ["NR", "Northwind Treasury", "@n0rthwind here: urgent, update the payout wallet before 5 PM using the form at lumenpay.help/payouts"],
      ["PL", "Priya Lal", "Invoices for Q3 are on northwind.io/finance, and the vendor list is at lumenpaay.com/vendors"],
      ["AK", "Ana Kovač", "Heads-up, I got a text from acme-bnak.com asking me to confirm a transfer. Ignored it."],
    ];
    let next = 0;
    document.getElementById("lk-incoming").addEventListener("click", () => {
      const [initials, who, text] = incoming[next++ % incoming.length];
      const chat = document.getElementById("lk-chat");
      const time = new Date().toLocaleTimeString("en-US", { hour: "numeric", minute: "2-digit" });
      const msg = document.createElement("div");
      msg.className = "lk-msg";
      const avatar = Object.assign(document.createElement("span"), { className: "lk-avatar", textContent: initials });
      avatar.setAttribute("aria-hidden", "true");
      const body = document.createElement("div");
      const name = Object.assign(document.createElement("p"), { className: "lk-msg-who", textContent: who });
      name.append(Object.assign(document.createElement("span"), { textContent: time }));
      body.append(name, Object.assign(document.createElement("p"), { className: "lk-msg-text", textContent: text }));
      msg.append(avatar, body);
      chat.append(msg);
      chat.scrollTop = chat.scrollHeight;
    });
  </script>
</div>

Référence culturelle

Le Petit Chaperon rouge, Charles Perrault (1697, conte). Le loup est couché dans le lit de la grand-mère, presque ressemblant, et la fillette remarque, un à un, les détails qui ne collent pas avant qu’il ne soit trop tard. L’interface compare chaque lien, expéditeur ou compte avec celui auquel l’utilisateur fait confiance et nomme un à un chaque détail qui ne colle pas, avant le clic.

API

Attributes

NameTypeDefaultDescription
trustedcomma-separated listTrusted identities. Each entry is a domain (acme-bank.com, also trusts its subdomains and email addresses), an email domain (@stripe.com), an address ([email protected], trusted by its domain), a handle or name (@northwind, left-pad) or an account (IBAN, 0x… or bc1… wallet). Prefix a label with the email syntax to name it in messages and buttons: “Acme Bank <acme-bank.com>”. The identities property replaces this list when set.
thresholdfine | lookalike | impersonationlookalikeLowest verdict that gets a flag (and link interception). fine also flags faint resemblances (“Probably fine”), impersonation only flags deliberate disguises.
intercept"true" | "false"trueClicks (and middle clicks) on flagged links open the explanation as a confirmation instead of navigating. Continue anyway replays the click natively, so target, rel and client-side routers behave as usual.
scanspace-separated: links text fieldslinks text fieldsWhat is checked: links (a[href] with http(s):, mailto: or //), text (domains, emails, @handles, IBANs and 0x wallets written in plain text, wrapped in a span.mv-lookalike-mark only when flagged) and fields (input[type=email], input[type=url] and any input or textarea with data-lookalike, on input, paste, change and blur). Elements with data-lookalike are always checked.
show-verifiedbooleanExact matches of a trusted identity get a small shield-check mark with a “Verified: {label}” text alternative.
validatebooleanFlagged fields get a custom validity message (form submission is blocked) until the user picks Use the real value or Continue anyway.
data-lookalike (on content)empty | valueChecks this element: its text (“Acme Bank Security <[email protected]>” is parsed as display name + address), the attribute value if given, a link’s href, or a field’s value. data-lookalike-name="…" adds a display name to check against the address. data-lookalike-ignore skips a subtree.
data-lookalike-verdict (set on content)impersonation | lookalike | fine | trustedSet by the component on every flagged link, mark, element or field (styleable); data-lookalike-ack once the user chose Continue anyway.
data-foundbooleanSet on the element while at least one suspicious item is flagged.

Properties

NameTypeDescription
identitiesArray<string | { value, label?, href? }>Trusted identities as data (replaces the trusted attribute). href overrides the “Go to the real X” destination (defaults to https://<domain>). Read it to get the parsed list with kinds.
resultsArray<{ element, value, verdict, result, acknowledged, reported }>Every flagged or verified item currently in scope (read-only).
stringsPartial<Record<string, string>>Overrides for every visible text, announcement and difference message ({label}, {value}, {c}, {t}, {count}… placeholders; “{c}” renders as inline code). English defaults.
threshold / intercept / scan / showVerified / validatereflectedMirror the attributes.

Methods

NameDescription
MvLookalike.compare(candidate, trusted, { strings? })Static and pure (also exported as compare): compares one value with one identity. Returns { verdict: "trusted" | "impersonation" | "lookalike" | "fine" | "unrelated", score (0-1 resemblance), kind (domain | email | name | account), value, display, trusted, label, href, title, diffs: [{ n, type, key, vars, message }], rows: { shown, candidate, trusted } (segments { text, n, type, gap } for side-by-side rendering) }. No DOM, safe in Node, Deno, workers.
MvLookalike.check(value, trusted[], options?)Static and pure (also exported as check): compares a value with every identity and returns the most telling result (an exact match wins). checkLink(href, text, trusted) also flags link texts that claim another address.
check(value)Same as the static check, against this element’s identities.
rescan()Re-checks the whole scope now. Content added later (a new chat message, a re-render) is picked up automatically by a MutationObserver.
open(element) / close()Opens the explanation for a flagged link, field or marked element, or closes it.

Events

NameDescription
mv-lookalike-foundA suspicious item was flagged (initial scan, new content or a field value). detail: { element, kind: "link" | "text" | "marked" | "field", value, verdict, result }.
mv-lookalike-proceedCancelable. The user chose Continue anyway. detail: { element, kind, value, href (links), verdict, result }. preventDefault() keeps the warning (and, for an intercepted link, does not open it).
mv-lookalike-reportThe user chose Report (once per item; the flag then reads “· Reported”). detail: { element, kind, value, verdict, result }. Send it to your abuse or security endpoint.

CSS classes

NameDescription
mv-lookalike-flagInline flag <button> placed right after the item (data-verdict, aria-expanded, data-ack, data-reported): an icon, .mv-lookalike-flag-text and a visually hidden verdict.
mv-lookalike-markSpan wrapped around a suspicious address found in plain text (never around unflagged text; unwrapped when no longer flagged).
mv-lookalike-verifiedShield-check mark after exact matches with show-verified.
mv-lookalike-panelExplanation panel (non-modal dialog in the Popover API top layer, data-verdict, data-intercept): -head, -icon, -kicker, -title, -text, -close, -compare (rows of -label + -value with .mv-lookalike-diff / .mv-lookalike-gap and numbered .mv-lookalike-num), -diffs (the numbered explanations, .mv-lookalike-code), -status, -actions (-report, -proceed, -real, -use).

CSS variables

NameDefaultDescription
--mv-lookalike-dangervar(--mv-danger)Tone of impersonations: underline, flag, highlights.
--mv-lookalike-warnvar(--mv-warning)Tone of look-alikes.
--mv-lookalike-okvar(--mv-success)Tone of verified marks and of the trusted row’s highlights.

Accessibility

Every flag is a real <button> with visible words (“Impersonation”, “Look-alike”, “Similar”) plus a visually hidden verdict (“: Impersonates Acme Bank. Show the differences.”), aria-haspopup="dialog", aria-expanded and aria-controls; the wavy underline is never the only signal. The panel is a labelled, described non-modal dialog inserted right after the flag (outside any label, link or button), so Tab moves on naturally; it receives focus when opened from a flag, and on an intercepted link focus goes to the safe action (Go to the real X) rather than Continue anyway. Escape or Close folds it and returns focus to the flag or link; an outside click or moving focus elsewhere closes it too. Differences are spelled out in text, never shown by color alone: the side-by-side rows keep the real characters, each difference is numbered in both rows and in an ordered list of sentences that name the character, its script and code point (“The “а” here is Cyrillic (U+0430), not the Latin letter “a”.”), what was added, missing, swapped or replaced; the numbers are aria-hidden duplicates of the list order. Flagged fields get an extra aria-describedby text with the verdict, an optional custom validity message (validate), and a polite announcement when a typed or pasted value becomes suspicious; new suspicious content (a chat message) is announced politely once per batch; the initial scan is silent. Verified marks carry a text alternative. The one-by-one reveal of the differences and highlights is disabled under reduced motion (OS or data-motion="reduce"), and forced-colors mode keeps highlights as system Mark colors with outlines.

Cette page a été traduite par IA. Signaler un problème de traduction