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.
- A URL from datasuch as a card's receipt: whoever wrote the data wrote the URL
- 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
- The link ruleabsolute https, a plain host, printable ASCII, at most 300 characters
- Refused, every onewith and without the github.com allowlist; shown as text, never opened
A lookalike of the trusted host
- The link rulewell-formed, so with no allowlist it is a link
- The github.com allowlistthe host must be exactly this one
- Refused under the allowlist, every oneits host is not exactly the trusted one
A good URL
- The link rulethe same rule, with no allowlist
- Kept, every onereturned unchanged, as a link
An unsafe line of client code
- The test's auditflags any line that could open a URL outside the one link rule
- Caught, every oneeach caught exactly once
A safe line of client code
- The test's auditthe same audit, on lines that look close but open nothing
- 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.
Real
- The defect. A card's receipt, and the URLs in a work panel, a trajectory, the chat's sources and the owner page, could be any string. A click opened it. The server's old rule took plain http on any host, a user name and password inside the URL, unicode and lookalike hosts.
- Where. On the main branch, found in a review. It mattered at once: the agent space was being opened to anonymous guests.
- The fix. One rule, the same bytes on the server, in the contract and in the web clients. A URL from data that is not a link is shown as text and never opened.
SUMMARY ONLY, NOT REPRODUCIBLE HERE
Red on the old code, green on the new
The note that came with the fix ran the engine's own link-safety tests against the code before it. The old code: 66 failed, 17 passed, of 83. The new code: 83 of 83 passed. In the note's words, the 17 that passed are cases the old rule already refused. This is the note's table, not a run of ours: the old code is not on this site, and we did not run it again.
Private commit 4c9cba58, cited by hash, checked as part of the private main aa35e6db on ; this page cannot check it, anyone with access can.
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.
AN AUTHORED FIXTURE, WRITTEN BY US
These are the fixtures of the engine's link-safety test, which we wrote. Each one is an attack or a good URL we made up, not one found in the wild. The verdict beside each URL is what the pinned rule returned when the vendor put it through; the verdict beside each line of code is the test's own assertion, which the run passed. The page never types one by hand. A poisoned URL is shown by a one-line label we wrote, not as itself: as itself it would be a link off this site, an address, or a character that reorders the text. Each label is bound to its URL by the URL's sha256, which the record holds.
30 poisoned URLs: every one refused
| The poisoned URL | The rule | With the github.com allowlist |
|---|---|---|
| A javascript: URL that runs a script in the visitor's page | refused | refused |
| The same javascript: scheme in mixed case | refused | refused |
| A javascript: scheme with a tab inside the word | refused | refused |
| A javascript: URL with a leading space | refused | refused |
| A javascript: URL dressed up with two slashes and the trusted host's name | refused | refused |
| A data: URL holding a whole HTML page with a script | refused | refused |
| A vbscript: URL | refused | refused |
| A file: URL pointing into the visitor's own disk | refused | refused |
| Plain http, unencrypted, on an unknown host | refused | refused |
| The trusted host, with the scheme in capitals | refused | refused |
| A user name and password written into the URL before the trusted host | refused | refused |
| The trusted host's name used as a user name, so the real host is another one | refused | refused |
| The same trick with a port after the trusted host's name | refused | refused |
| The same trick behind a backslash | refused | refused |
| A scheme-relative URL, two slashes and another host | refused | refused |
| A backslash where the path's slash should be | refused | refused |
| A URL about five thousand characters long | refused | refused |
| The trusted host's name with one Cyrillic letter that looks Latin | refused | refused |
| The trusted host's name with a fullwidth first letter | refused | refused |
| A right-to-left override in the path, so a program's name reads as a picture's | refused | refused |
| A zero-width space hidden in the path | refused | refused |
| The punycode spelling of a lookalike of the trusted host | refused | refused |
| A trailing newline after an otherwise good URL | refused | refused |
| A space inside the path | refused | refused |
| A quote that breaks out of the link into a script attribute | refused | refused |
| A script tag in the path | refused | refused |
| A bare IP address as the host | refused | refused |
| The visitor's own machine as the host | refused | refused |
| The scheme with no slashes at all | refused | refused |
| The scheme and nothing else | refused | refused |
3 lookalikes: links with no allowlist, refused under it
These are well-formed https URLs on real-looking hosts, so with no allowlist the rule takes each one as a link. Under the github.com allowlist each is refused, because its host is not exactly the trusted one.
| The lookalike | The rule, no allowlist | With the github.com allowlist |
|---|---|---|
| The trusted host's name as the first part of another host | a link | refused |
| The trusted host's name with a word in front, one host | a link | refused |
| A subdomain of the trusted host as the first part of another host | a link | refused |
3 good URLs: kept as they are
A good URL comes back unchanged. One of them is on another host, so the allowlist refuses it too, as it should.
| The good URL | The rule, no allowlist | With the github.com allowlist |
|---|---|---|
| A pull request on the trusted host | a link | a link |
| A CI run's step on the trusted host, with a query and a fragment | a link | a link |
| A page on another real-looking host, with a port and an escaped space | a link | refused |
28 unsafe opener lines: every one caught
The test also audits the client's own code: any line that could turn a string into a navigation, outside the one pinned link rule, fails the suite. These are the audit's own fixture lines, each a way to open a URL. The test asserts each one is caught exactly once, and the run passed that test.
| The line | Caught |
|---|---|
window.open(receipt.ref) | yes |
globalThis.open(receipt.ref, '_blank') | yes |
self.open(u) | yes |
open(receipt.ref) | yes |
location = receipt.ref | yes |
document.location = receipt.ref | yes |
window.location.href = u | yes |
location.href=u | yes |
location.assign(u) | yes |
window.location.replace(u) | yes |
a.href = receipt.ref | yes |
img.src = u | yes |
f.srcdoc = html | yes |
form.action = u | yes |
const o = document.createElement('object') | yes |
link.setAttribute('href', receipt.ref) | yes |
el.setAttribute("src", u) | yes |
svg.setAttributeNS(ns, 'xlink:href', u) | yes |
el.innerHTML = `<a href="${u}">x</a>` | yes |
el.innerHTML = '<iframe src=' + u + '>' | yes |
const a = document.createElement('a') | yes |
document.createElement("iframe") | yes |
navigation.navigate(u) | yes |
| The browser history rewritten to a URL on another host (shown by its label, not as itself) | yes |
img.src = receipt.ref | yes |
| An image's source set to a fixed URL on another host (shown by its label, not as itself) | yes |
o.setAttribute('data', u) | yes |
f.src = u | yes |
11 safe lines: none flagged
Lines that look close but open nothing. The test asserts the audit flags none of them, and the run passed that test. A false alarm here would teach people to ignore the audit.
| The line | Flagged |
|---|---|
if (a == b) x() | no |
const href = safeUrl(u) | no |
return { href: ok } | no |
// window.open(u) in a comment | no |
x.hrefLang = 'en' | no |
openSafe(u, opts) | no |
const isOpen = panel.open | no |
el.textContent = refText(u) | no |
entry.src = { stop() {} }; | no |
existing.data = parseCreateObject(p); | no |
| A plain field named data set to nothing, which opens nothing (shown by its label, not as itself) | no |
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.