ADR 0364: Received Webmentions are stored by a hosted receiver that never fetches, and verified by the command-line pull
- Status: Accepted
- Date: 2026-10-29
- Parent epic: #387
- Story: #402 (task DIST7.2.1)
Context#
Story #402 wants other sites to be able to tell this one that they link a post, and the author to moderate what arrives. The W3C Webmention Recommendation (12 January 2017, checked 2026-10-29) sets the receiver's rules:
- 3.2: the receiver SHOULD check the request synchronously and then queue and process it asynchronously, answering
202 Accepted(or201with a status URL, or200when it verified synchronously). - 3.2.1: it MUST check that
sourceandtargetare valid URLs of a supported scheme and MUST reject the request when they are the same; it SHOULD check that the target is a resource it accepts Webmentions for. - 3.2.2: before using a Webmention it MUST GET the source, following redirects (it SHOULD limit them), and the source
MUST contain an exact match of the target. A
410 Gone, or a200without the link, SHOULD delete an existing Webmention; a repeat SHOULD update it, idempotently. - 3.2.3: a sender's mistake is a
400 Bad Request; the receiver's own failure SHOULD be a500. - 4.1 and 4.2: verification SHOULD be asynchronous so the receiver cannot be used for denial of service; receivers SHOULD limit redirects, data and time when fetching an unverified source, and MUST encode or filter what they show.
A static site cannot take a POST, so a receiver needs a hosted function. The project already has them (Netlify
functions over Supabase, opt-in supabase/*.sql schemas, a key per function), and the outbound half (ADR 0361)
already has a public-only fetcher that checks every redirect hop and resolves names only to public addresses. A hosted
function that fetched the source would be a request-forgery proxy for anyone who can POST two addresses.
Decision#
- The hosted receiver never fetches a source.
netlify/functions/webmention.mjs(/api/webmention) checks the request (3.2.1), stores the pair and answers202. It reads exactly onesourceand onetargetfrom anapplication/x-www-form-urlencodedbody of at most 8 KiB: bothhttp(s), at most 2048 bytes, no user name or password, different once the fragment is removed, the target onOPENBLOG_SITE_ORIGINand the source not. Each refusal is a400with a fixed code and message that never repeats input. The only request it makes beyond Supabase is to its own origin'sopenblog-webmention.json, with redirects refused: a target that is not a post accepting mentions is refused (3.2.1's SHOULD), and an unreadable list is a503, never a guess. A storage failure is a500that says nothing about the database. - Off by default, with its own secret. The function answers
404to everything and touches nothing unlessOPENBLOG_WEBMENTION_ENABLED=trueand every setting is valid: Supabase,OPENBLOG_SITE_ID, anhttpsOPENBLOG_SITE_ORIGIN, andOPENBLOG_WEBMENTION_ADMIN_KEY, at least 32 characters and different from every other credential the deployment holds. The schema issupabase/webmention.sql, additive and private (row level security with no policy, nothing granted to the public roles), undone bysupabase/webmention-rollback.sql. - The site advertises the endpoint only while it receives.
webmention.receiveinopenblog.json(enabled,endpoint,inboxFile,retentionDays) is off by default and omitted while it has its defaults. Only when it is on, with anhttpsendpoint without credentials, query or fragment, does each post that has not opted out withwebmentions: falsecarry<link rel="webmention" href="https://github.com/journey-to-code-org/open.blog/blob/main/docs/adr/...">in its head, and does the build writeopenblog-webmention.json: the absolute addresses of those posts. Every other site's output is byte for byte as before, and feeds never change. - Verification is the command-line pull.
openblog mentions pull --writetakes at most 100 waiting requests with the Admin key, checks each again (the same rules, inopenblog_core::webmention_inbox::check_request) and against the site as published now, then fetches the source with the network half ofopenblog webmention: every address and redirect hop checked byvalidate_public_urland resolved by the public-only resolver, at most five redirects, 15 seconds, the first MiB, no proxy, no cookie, no credential. A source that is not public is never connected to. A dry run contacts nothing. - What counts as a link (3.2.2). Only
text/html,application/xhtml+xmlandtext/plainbodies are read. HTML is parsed into a tree byhtml5ever; no script runs and no style, image, frame or other resource is requested, so a link a script would write is no link. Anhrefofa,areaorlink, asrcofimg,video,audioorsource, or aciteofblockquote,q,insordelcounts when it resolves, against the address after redirects, to exactly the target (with or without a fragment). Plain text must contain the target address. - Outcomes. A source that links the post becomes a pending mention (ADR 0365). A
404or410, a page without the link or a body that is not read withdraws a known mention (3.2.2's deletion) and keeps nothing for an unknown one. A source that does not answer, times out, redirects too often or answers another status stays in the hosted store for the next pull, for 72 hours from its arrival, then is dropped. The inbox is saved before the handled requests are deleted from the hosted store, each only at the version taken, so a pull that stops halfway repeats work and loses nothing, and a repeat that arrived meanwhile is kept.
Consequences#
- Nothing a stranger sends can make the hosted function request anything, and the one fetch is made where the public-only fetcher already lives.
- Mentions are verified when the author pulls, not when they arrive: a sender gets
202, and the mention appears only after a pull, a moderator's approval and a build. A sender gets no status URL. - A site with no hosted service cannot receive Webmentions; it keeps its canonical pages and can still send them.
- Like ADR 0361, receiving is not a provider in the capability contract (ADRs 0325 to 0327): nothing is published to another service, and the sender is any site.