LAB 07 · CAN DATA TRICK A CLICK?

Can data trick a click?

On the agent space's floor, a card can carry a receipt: a URL that came from data. A click on the card opened it in the visitor's browser. So a receipt written to run a script, or to look like a trusted host, would have opened too. It was a real defect, on the main branch, and it was fixed. This page shows the rule that fixed it and puts every one of its test's fixtures through that rule.

What it is.

The lab in plain words, and how it runs.

The engine's link-safety test is the check that guards the fix. This lab asks what that test shows: does the rule refuse every bad URL the test throws at it and keep the good ones, and does the test catch every line of client code that could open a URL on its own?

We put every URL of the test through the rule itself: URLs written to run a script or to slip past the rule, lookalikes of the trusted host, and good URLs. We put every line of client code of the test through the test's own audit, which looks for code that could open a URL. The fixtures are attacks we wrote, not ones found in the wild. The verdict on each URL is the rule's own, and on each line of code the audit's own; none is typed by hand.

What came out: every poisoned URL was refused, every lookalike was refused under the allowlist, every good URL was kept as it is, the audit caught every unsafe line of code, it flagged none of the safe lines. On , on a Mac, the test itself ran: 7 of its 7 test cases passed.

How it works: every URL of the test put through the one link rule, every line of code through the test's audit; the test run: 7 of its 7 test cases passed
  1. A URL from datasuch as a card's receipt: whoever wrote the data wrote the URL
  2. The fixtures, written by usattacks, good URLs and lines of code from the engine's link-safety test, not found in the wild

A poisoned URL

  1. The link ruleabsolute https, a plain host, printable ASCII, at most 300 characters
  2. Refused, every onewith and without the github.com allowlist; shown as text, never opened

A lookalike of the trusted host

  1. The link rulewell-formed, so with no allowlist it is a link
  2. The github.com allowlistthe host must be exactly this one
  3. Refused under the allowlist, every oneits host is not exactly the trusted one

A good URL

  1. The link rulethe same rule, with no allowlist
  2. Kept, every onereturned unchanged, as a link

An unsafe line of client code

  1. The test's auditflags any line that could open a URL outside the one link rule
  2. Caught, every oneeach caught exactly once

A safe line of client code

  1. The test's auditthe same audit, on lines that look close but open nothing
  2. None flaggeda false alarm would teach people to ignore the audit

The defect was real.

What it was, and what the old code did against the new tests.

The rule.

A URL from data is a link only when it passes all of these. Anything else is plain text, and is never made clickable.

  • The scheme. Absolute https, in lower case. Never javascript:, data:, vbscript:, file:, or plain http on any host.
  • The host. A plain lower-case name with a letter ending, and an optional port. No bare IP address, and no punycode label: the ASCII spelling of a lookalike is not a link either.
  • No credentials. No user name and password before the host, which also refuses the trick of writing the trusted host's name there.
  • The characters. Printable ASCII only: no space, no control character, no backslash, quote or angle bracket, and no unicode, so no direction override, no zero-width space and no letters from another script.
  • The length. At most 300 characters.
  • The allowlist. Where a connector names its hosts, the host must be one of them exactly. For these fixtures it is github.com.

A reference that looks like a link but is not one is shown with "not a link: " in front of it, so an older client that links anything starting with http still shows words.

Every fixture, through the rule.

The attacks are ours. The verdicts are the rule's.

Check it yourself.

Everything on this page comes from one record, published here and pinned by its sha256. It was read from the web client of the engine's private repository: its link rule and its link-safety test, read and run at one commit. Private commit 5afcbbf3, cited by hash, checked as part of the private main 55543194 on ; this page cannot check it, anyone with access can.

The test, run

On , on a Mac, the engine's link-safety test ran at that commit with Node's own test runner, with nothing installed, in a clean snapshot of the commit: 7 passed, 0 failed, 0 skipped, of 7. The fixtures above are that test's, at that commit.

The files, by sha256

  • The link rule, the one function a click on a URL from data goes through: 2c83dc5ff377806c165f2bce3917e0b2b86575f92ce34e6d44a3f8f3d88d51df
  • The link-safety test: the poisoned, lookalike and good URLs, and the opener audit with its fixture lines: 832e4ff8b5ebf9d2466482e840dc15a607af0809d3f708d98f8e5e2d3cddcaf8
  • The link-safety note: 71a0c35acca3d9a42b22e186c474c8070ffa7a3b39d68cd4ecb7deaf9a0be1c7

Each main was checked by GitHub compare of the cited commit against the private main head; behind by 0 means the commit is part of main, on .

What this does not show.

  • The fixtures are attacks we wrote. They do not say how often a poisoned URL turns up, or that no other trick exists.
  • It shows that this rule refuses these URLs and that this audit catches these lines. It does not show every client: a client that skips the rule is caught only where the audit reads its code.
  • The red/green table is the note's. This page shows the new rule run, not the old one.
  • No screenshot of a poisoned card is shown: one could not be taken without touching a live instance.