Skip to content

@ogygia/federation

Threat model

What federation's signatures and capabilities protect against, in plain words, and what they leave to you. In short, a stranger can't call your apps or pose as a visitor, and a peer you list is trusted with your page.

On this page

Federation joins apps that different teams run. This page says who could try to misuse that, what stops them, and what’s left to you. The short version: a stranger can’t call your apps, pose as a visitor, or turn your shell into a proxy. A peer you list, though, is trusted with your page and your visitors.

Attackers

  • A stranger on the internet who calls a producer’s /og/ endpoints directly.
  • A visitor who edits requests in their browser, or sends their own.
  • Someone who sees traffic between your servers and copies or changes a call.
  • One of your peers, misconfigured or compromised, trying to do more than it’s trusted with.
  • Markup in your pages you didn’t write, such as CMS content, trying to load code.

Defenses

AttemptWhat stops it
Calling a producer without being a peerEvery call is signed with the caller’s private key and checked against the public keys the producer lists. A failing call gets a 401 before any route, widget or notice runs (Keys and signing).
Changing a captured callThe signature covers the method, path, query, body, claims, audience, time and nonce. Changing any of them breaks it.
Sending a captured call againA signature is refused once its 120-second window has passed. Inside it, a second delivery is refused by a per-process memory, up to its limits: past about 50,000 to 100,000 other signed calls in the window, a replay can be accepted again (Replay and clocks).
Sending a call made for one app to another that trusts the same keyThe receiving host is signed in, and checked against the receiver’s own configured audience, never the request’s Host (Audience).
Posing as a visitorClaims count only inside a valid signature. Your app attaches them in process under a symbol no HTTP request can set, and the exposed table never sees the raw header. A widget’s request still carries it, so read identity from user (Reading claims).
Using the shell to reach a peer with chosen inputsA deferred region’s URL is signed by the shell when it renders the page and fixes the peer, the page or widget and its props. No endpoint turns browser input into a signed call (Deferred regions).
A peer clearing another peer’s pagesA notice’s tags are filed under the name of the peer whose key checked it, never a name in the body. A notice carries tags, not data, so the most it can do is make pages render again.
Sending huge bodiesA body is read up to maxBodyBytes, 1 MiB by default, before any signature work, and refused with a 413 past it.
Reaching off the producer’s originAn exposed page is always asked on the producer’s own origin; a path that would leave it gets a 400.
Loading island code from injected markupThe runtime imports island code only from your origin and your peers’ (Code origins), and a fragment’s server-island URLs are forwarded only on the peer’s own origins.

Limits

  • Use TLS between servers. Claims and fragments are signed, not encrypted. Anyone who can read the traffic can read visitor ids and roles.
  • A peer is trusted with your page. A fragment’s HTML is printed into your page as it came, so a peer’s markup and scripts run with your origin’s access, cookies included. List only apps you’d let ship code to your site.
  • A key is trusted both ways. A key you list only to take a peer’s thaw notices also lets it call your pages and widgets as any visitor (Key rotation).
  • Claims are the shell’s word. A producer trusts whatever a listed key signs. Authorize from user(c), never from a prop or a query value, which the caller picks. A shell that signs the wrong claims gets the wrong pages.
  • Hole props are readable. A deferred region’s props sit in its URL, signed but not hidden. Pass ids, not secrets.
  • The catalog is public. /og/fragment/__catalog lists widget names and prop names to anyone, on purpose. Don’t put secrets in names.
  • Replays. Each server process remembers the signatures it saw, so a captured call sent to another instance within the window isn’t caught. And once about 50,000 to 100,000 other signed calls arrive inside one window, a captured call can be accepted again by sending only its older headers, visitor claims and all (#2312). Keep skewMs short, rate-limit what each peer may send, and make calls that carry identity or change data safe to receive twice (Replay and clocks).
  • The replay memory has a ceiling. Past about 100,000 signed calls per skewMs per process, new calls in the token form get a 401 (#2311, item 18).
  • Clocks. Servers more than skewMs apart refuse each other’s calls. Keep them synced.
  • Leaked keys. There’s no revocation list: a private key is retired by removing its public key from every app that lists it (Key rotation). Keep private keys in a secret store, never in the repository.
  • Open endpoints. open: true takes calls from anyone who can reach the app (Open endpoints).
  • Deferred holes use your OGYGIA_SECRET. Anyone with it can sign hole URLs for your shell. Keep it secret and stable (Server islands).