# Pinned panel and connector releases

> An organization's owners decide which code runs: the dashboard build every member's browser loads and the bridge release every team bridge starts.

Source: https://osevel.com/docs/security/pinned-releases/

An organization's **owners decide which code runs**: the panel build every member's browser
loads, and the connector release every team bridge starts. A new build or release takes effect
only after the owners sign it as a [signed record](https://osevel.com/docs/security/signed-records/). The host of
the panel, ourselves included, cannot change the code unnoticed.

A web page cannot check its own code: tampered code would tamper with the check too. So the
panel is guarded in layers, each closing what the previous one leaves open.

| Layer | What it does                                                                                           | Does not stop                                    |
| ----- | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------ |
| L1    | Owners sign the build's digest (`release.propose`, `release.sign`)                                     | nothing by itself: the others compare with it    |
| L2    | Every team bridge fetches the signed build from the panel's address every 5 minutes and compares files | code served to one person only                   |
| L3    | The panel names its build when it opens a channel; the bridge answers only the build in force          | tampered code that names the right build         |
| L4    | Each browser keeps the signed build and shows a warning when the address serves something else for it  | a host that replaces the browser's worker itself |
| L5    | What you sign is shown and confirmed on your phone                                                     | —                                                |
| L6    | [A panel you host yourself](https://osevel.com/docs/guides/self-hosted-dashboard/)                                                      | your own host                                    |

## Who accepts a build

- **Two owners** sign it: the first proposes it (`release.propose`), the second co-signs
  (`release.sign`).
- **A person alone** signs on two devices: the computer proposes, the phone confirms the same
  record.
- **Any owner may refuse** a build (`release.refuse`): it never takes effect, not even as a
  critical fix.
- **A critical fix** our release key marks critical takes effect by itself **72 hours** after we
  publish it, counted at the earliest from when each bridge first saw it (so a release dated in
  the past still waits), unless an owner refused it or the owners accepted another build after
  it was published. Every bridge says so from the start and counts down.

An acceptance is fixed when it is reached: members joining or leaving later never accept or
un-accept a build. "A person alone" means the organization's only owner when the build was
proposed. Before the owners signed any build, nothing is pinned and nothing is enforced; the
bridges say so. Once one was accepted, the organization stays pinned: if every accepted build is
refused later, no panel is answered until the owners accept one.

In the panel: **Organization → Signed records → Panel version**. It shows the build in force,
the build of the page you are on, and every build we published, with its state (in force,
waiting for a second owner, refused, critical with its countdown) and, for an owner, the record
to sign or refuse.

## Our builds are signed

Each panel build carries `build-release.json` (version, digest of its `build-hashes.json`,
critical or not, publication time) signed with our release key, the same Ed25519 key that signs
connector releases. The cloud keeps earlier builds and serves each at `/b/<digest>/`, and lists
them at `/.well-known/osevel/panel-builds.json`. The cloud only stores: bridges, panels and
browsers verify every entry against the release key pinned in their own code, so an entry the
cloud made up is ignored everywhere.

## What the bridges do

Every 5 minutes each team bridge fetches the build in force from the panel's address (yours if
you [pinned your own](https://osevel.com/docs/guides/self-hosted-dashboard/)) and compares every file with the
signed build's list. On the hosted panel it also checks `/`, what a browser loads first: it must
be a build our release key signed, with every file intact.

- **A difference** is confirmed on three fetches a minute apart (a stale cache must not close the
  panel). Then the bridge **answers no panel channel** until the files match again, and tells
  every member: on the bridge's terminal, to the team's webhook (`osevel connect notify`), and on
  every member's phone. **Phones and the terminal keep working.**
- **An address it cannot reach** changes nothing: nobody can load the panel from it either. Only
  the page itself decides that: once the page answers, any other file that fails (an error, a
  redirect) counts as a difference.
- **A channel from another build** gets the build in force in the reply and is closed; an honest
  panel moves to `/b/<digest>/` of the signed build by itself.
- **A new build waiting** for the owners, and a critical fix's countdown, are announced to the
  owners (terminal, webhook, the owners' phones).

## In each browser

When a bridge confirms the page is the signed build, the browser's worker keeps that build: it
checks our release key's signature and every file's hash, then serves the panel's pages from its
copy, for every page path except another build's own address. It never goes back to an older
build. When the address later serves something else for that build, the page shows: _the
panel's code changed without an owner's signature_. The worker keeps only the public files of the build;
it never sees the API or the encrypted channel.

## Connector releases

A connector paired to an organization starts only a release its owners accepted: the digest of
its signed `release-manifest.json`, accepted with the same records (`target: connector`), or a
critical fix after its 72 hours.

- `osevel daemon run` checks before it starts anything: a refused release, a release the owners
  did not accept, or an unsigned build once any release is accepted, does not start.
- A critical release's 72 hours run at the earliest from when the connector first saw it.
- An **older accepted release keeps running**: signing a new one never stops a bridge that has not
  updated yet.
- If the organization's records cannot be read, the daemon does not start.
- A running bridge checks again after each records sync and warns when its release was refused;
  the next start refuses it.

The digest to sign is the SHA-256 of the release's `release-manifest.json`.

## Limits

- A host that serves altered code **to one person only** is not seen by the bridges' check; the
  browser's worker (L4) and the phone confirmation (L5) cover that person.
- A host that replaces the browser's worker defeats L4; the bridges' check and the phone remain.
- Tampered code can name the right build in its channel hello (L3 is a check of honest panels).
- The connector check runs when the daemon starts, from the verified records it holds; an
  `osevel daemon install` of an unaccepted release succeeds, and the service then refuses to
  start it. The check is part of the release it checks: it binds our honest releases, and the
  release key's holder could ship one without it (the same trust as the critical-fix rule). A
  refusal the cloud has not delivered yet is not known to the connector; a connector whose
  records file is missing counts as belonging to no organization.
- Any page of the panel's address can tell the browser's worker to dismiss a "changed" warning;
  it cannot make the worker keep an unsigned or older build.
