← All writing

The link that says one thing and goes somewhere else

On a fake mail, the words on a link and the address behind it disagree. Keyhaven's reading page now checks every link on my device, without visiting any of them. What it looks for, what it can't know, and the button that offered the bad link anyway.

·5 min read
The link checker open above a made-up mail: two of its three links are marked in red, one that starts like shop.example.com but belongs to parcel-check.example, and one that shows shop.example.com but goes to parcel-check.example.

A link in a mail is two separate things: the words you see and the address behind them. Nothing forces them to agree. A mail can show shop.example.com and take you anywhere at all, and a lot of fake mail is built on exactly that gap.

Browsers show the real address when you hover. I know that, and I still don’t check every time. So when version 1.10.0 of Keyhaven got a fuller reading page, one part of it was a link checker. A mail with links gets a small button above it. Normally it just says how many there are. On this one, which I made up for the picture, it’s red:

A made-up mail about a parcel, with a red button above it saying 2 of 3 links look wrong.

What it looks for

Press it and every link is listed with its real address, wrong ones first. It explains itself in one sentence per problem:

The trick What Keyhaven says
The words name one site, the link goes to another Shows shop.example.com, but goes to parcel-check.example.
The address starts like a real site It starts like shop.example.com, but it belongs to parcel-check.example.
Something in front of an @ Whatever comes before the @ is only a name: this goes to parcel-check.example.
A bare number instead of a name It goes to a bare number instead of a name, which real companies rarely do.
Letters from another alphabet Its name uses letters from another alphabet, which can look just like ordinary ones.
An address that makes no sense This address can’t be read, so it can’t be checked.

The important step is working out who a name really belongs to. shop.example.com.parcel-check.example reads like the shop, but names are read from the right. Whoever owns parcel-check.example can write anything they like in front of it. So the checker cuts every host down to the part a company actually owns, and compares those. It’s the same helper the “may be leaked” note uses to tell one company from another.

The words get the same treatment. bаnk.example with a Cyrillic а looks right on screen, but turned into a real host name it comes out as something else, so the words and the address no longer match.

Most of the work was not crying wolf

If every newsletter went red, I’d stop reading the warning within a week. So some things are only said quietly, with no red at all:

  • a newsletter link that runs through a mail service: It goes through sendgrid.net, a mail service that counts clicks.
  • a redirect that carries its destination in its own address: It goes through one place, then on to another. It’s only a warning if the words claim a third
  • plain http: Not encrypted (http).

And a few things that looked wrong at first weren’t:

  • www.shop.example behind the words shop.example is the same company
  • report.pdf looks like a domain to a pattern match, but it’s a file name, so file endings don’t count as claims
  • Click here claims nothing, so there’s nothing to compare

These have tests, because they’re the kind of rule that quietly breaks when someone tightens the checker a year later.

Nothing gets visited

The checker runs on my device, from the mail it has already opened. It doesn’t visit the links and it doesn’t send them anywhere.

That second part was a choice. A reputation service would catch more, but it would mean handing the links in my mail to somebody else, and the whole point of sealing mail is that nobody else gets to read it.

It also reads from the right copy. The links come from what the sanitizer wrote, not from the raw mail: the same links the mail’s frame shows, no more and no fewer. Two parsers disagreeing about one piece of HTML is a classic place to hide something. With only one reading, there’s nothing left to disagree about. A javascript: link, or one tucked inside an HTML comment, never reaches the list at all.

What it can’t know

Plenty, and it says so.

  • A well-made fake on its own name. A plain corner-shop-deals.example behind the words Click here claims nothing false. No warning.
  • Where a link goes after the click. The last line of the panel says it outright: None of these were visited, so a link may still send you on somewhere else once you open it.

So the words are always “look wrong”, never “safe”. There’s no green tick anywhere in it. An honest link simply has no note under it, and that’s all it gets.

The button that offered it anyway

Here’s my favourite part of this round, because no test of either feature on its own would have caught it.

Keyhaven has found sign-up codes and verification links in mail for a long time, and offers them as a button. It’s one of the reasons the inbox is nice to use. The new reading page came from an AI agent, as usual: I direct, Claude Code writes, and at the end of its work it reported something it had noticed on its test mail: an Open verification link button pointing at the fake address, right above the checker’s red warning.

Both features were doing their job. One said this looks wrong, and the other, a few pixels higher, said click here.

The fix was small. The button now asks the checker first:

const link = offeredLink(mail, detectVerifyLink(mail));
// null if the checker flags it: it stays in the checker, with its warning

An honest mail keeps its button, and the reading bar and the right-click menu get the same answer. A test also reads the inbox’s code and fails if any use of the detected link skips that question, so the next feature that wants a verification link has to ask too.

It’s a lesson I keep learning: features meet in places their own tests don’t look. What found this one was a deliberately hostile test mail, opened in every new view, and somebody actually looking at the result.

Keyhaven is a private tool for one person, so there’s no link to try it. The pictures are from a copy on my own PC, filled with made-up data, and the fake mail in them is one I wrote myself.