KoG Client

Updates and trust

Update channel Built

The client updates itself from a signed manifest. Nothing the network delivers is trusted until the signatures check. This page is the reference for the format and for what the client verifies.

Source of truth. The client's own description is docs/UPDATE_CHANNEL.md. This page follows it and adds a worked example. The updater is only compiled with -DAUTOUPDATE=ON, and a release build fails while a channel's keys are placeholders.

Channels #

ChannelBuilt fromSignaturesManifest valid forState
stableA release started by hand on mainCI key and the owner's hardware keyup to 90 daysPlanned no stable release yet
canaryEvery push to mainCI keyup to 30 daysBuilt published
devEvery push to devCI keyup to 14 daysBuilt nothing published yet

Canary and dev versions carry the channel (0.1.0-canary.9), are marked "Unstable build, best effort." in the update dialog, and are GitHub prereleases; the last 10 of each are kept. The channel is chosen with kog_update_channel or in the settings, never from the network. Switching to a channel with an older version asks for confirmation in that session.

A client checks a channel only against that channel's own keys, and the channel name is inside the signed text, so a manifest signed for one channel is refused on another.

Diagram of the three channels and their keys. The client has the public keys of every channel built in. The stable channel is checked against two CI keys and the owner's hardware keys and needs both kinds of signature. The canary and dev channels each have their own two CI keys and need one signature. A key of one channel cannot be used for another channel, because the channel name is inside the signed manifest.
Channel and key layout. The public keys are compiled into the client; the private halves are never in it. Open the diagram alone
Diagram source as text (Mermaid)
flowchart LR
  subgraph CL["Compiled into the client: kog_update_pubkey.h"]
    direction TB
    subgraph ST["stable (planned, keys are placeholders)"]
      S1["CI keys a and b"]
      S2["Owner hardware keys"]
      S3["Offline backup CI key"]
    end
    subgraph CA["canary"]
      C1["CI keys a and b"]
    end
    subgraph DE["dev"]
      D1["CI keys a and b"]
    end
  end
  M1["stable/update.json<br/>.sig and .sigb"] --> ST
  M2["canary/update.json<br/>.sig"] --> CA
  M3["dev/update.json<br/>.sig"] --> DE
  classDef planned stroke-dasharray:6 4
  class S1,S2,S3,M1 planned

Endpoints of client.kog.tw #

The site is served by GitHub Pages from the branch published of kog-client-updates. Manifests and this website are published by separate jobs and never overwrite each other.

AddressWhatState
/canary/update.json, /canary/update.json.sigManifest and signature of the canary channelBuilt published
/dev/update.json, /dev/update.json.sigManifest and signature of the dev channelBuilt nothing published yet (the address answers 404)
/stable/update.json, .sig, .sigbStable channel, two signatures. The start page also tries /update.json.Planned no stable release yet (404)
/builds/allowlist.jsonSigned list of released build hashes (idea only)Planned
GitHub releasesThe packages and client binaries a manifest points to (immutable releases)Built
raw.githubusercontent.com/KoG-teeworlds/kog-client-updates/published/CHANNEL/update.jsonFallback host of the client, on another name than the primary. Same files.Built

The names stable, canary, dev, base, releases and builds belong to the release data and are never used by website pages.

The manifest, format 2 #

update.json is JSON. A field that is absent means the old behaviour. Unknown fields are ignored by the client but are signed with the rest.

FieldRequiredMeaning
formatyesThe format number, currently 2.
channelyesMust equal the channel the client asked for.
versionyesThe version offered, with the channel in its form for canary and dev.
sequenceyesRises with every manifest of a channel. A client refuses one that is not higher than the last it applied.
issued, expiresyesUnix seconds. An expired manifest, or one from the future, is refused. The window is at most the channel's maximum.
platforms.linux-x86_64.client, platforms.win64.clientfor updatingThe client binary: sha256, size, url.
files[]yes (may be empty)Data files to update: path below data/, sha256, size, url, optional mirrors[] tried in order. Executables never go through files.
remove[]noData paths to delete.
packages[]noname, sha256, size, url of the zip, dmg and tar.xz that the download page shows. The updater ignores it.
rollout_percentno0 to 100: the share of installs that get the update. The bucket comes from a random per-install value in the config and is never sent anywhere.
haltednoThe update is withdrawn: clients do not apply it.
min_versionnoAn older client shows a blocking "update required" dialog that explains why. Never silent.
notes_urlnoRelease notes link, only on client.kog.tw or github.com/KoG-teeworlds.
changes[]noUp to 3 plain-text lines of at most 120 characters.

An annotated example #

The shape is taken from the published canary manifest. The hashes are shortened and the URLs trimmed, so this is an illustration and not a file to verify. Comments after // are not part of JSON.

{
  "format": 2,                       // required, must be 2
  "channel": "canary",               // must equal the channel the client asked for
  "version": "0.1.0-canary.9",       // the form of the channel
  "sequence": 3,                     // must be higher than the last applied on this channel
  "issued": 1795521981,              // Unix seconds, not in the future
  "expires": 1798113981,             // 30 days later: the canary maximum
  "files": [],                       // data files: path, sha256, size, url, mirrors[]
  "platforms": {
    "linux-x86_64": { "client": { "sha256": "1b318184...", "size": 7814888, "url": "https://github.com/KoG-teeworlds/kog-client/releases/download/canary-9/..." } },
    "win64":        { "client": { "sha256": "0cb0e106...", "size": 5125632, "url": "https://github.com/KoG-teeworlds/kog-client/releases/download/canary-9/..." } }
  },
  "remove": [],
  "packages": [ { "name": "...", "sha256": "...", "size": 0, "url": "..." } ]   // for the download page only
}

The matching update.json.sig of that manifest begins kog-update-sig-v1 1cb978aa d7465f8c....

Signature file and key ids #

update.json.sig is one line:

kog-update-sig-v1 KEYID SIGNATURE
  • kog-update-sig-v1 is the format tag.
  • SIGNATURE is Ed25519 over the exact bytes of update.json, 128 hex characters. It is checked with Monocypher.
  • KEYID is the first 8 hex characters of the public key, so a verifier can see which key was used.

The stable channel will have a second signature, update.json.sigb, in OpenSSH format (ssh-keygen -Y sign -n kog-client-release, key type sk-ssh-ed25519@openssh.com) made with a hardware key. The client checks the application, that the key was touched (user presence), the namespace and the signature. See release signing.

Per-channel keys and rotation #

Each channel has two CI keys, a and b, compiled into the client in kog_update_pubkey.h (KOG_<CHANNEL>_CI_KEYS). A key of one channel cannot sign another channel, and the channel name is part of the signed text.

To replace a CI key without leaving installed clients behind, the client always ships both slots and the signing side holds one active key:

  1. The client in the field already trusts the key that will be used next, because a and b are always shipped.
  2. The active slot is switched to the other one.
  3. The retired slot gets a fresh key; its public half goes into the client through a reviewed change.
  4. A client release with that change is shipped before the next rotation. Only then may the slot that was just filled become active.

A key that is not shipped in a client release is never made active. For stable, the owner's hardware keys (KOG_STABLE_OWNER_KEYS) and an offline backup CI key (KOG_STABLE_BACKUP_CI_KEYS) are separate from the CI keys. The stable keys in the client are still placeholders (KOG_UPDATE_KEYS_PLACEHOLDER_STABLE 1): a channel with placeholder keys does not update.

How the client verifies an update #

Sequence diagram of an update check. The client asks client.kog.tw for the manifest and its signature. If that fails it asks a fallback host with the same files. It verifies the signature against the keys of its own channel, then checks channel, sequence, expiry, version and rollout. It downloads each changed file from the allowed hosts, checks size and SHA-256 before anything is replaced, keeps the previous version, and restores it if the new one does not reach the start screen twice.
What the client does for one update check. Any failed check stops the update and leaves the installed version as it is. Open the diagram alone
Diagram source as text (Mermaid)
sequenceDiagram
  autonumber
  participant C as Client
  participant P as client.kog.tw
  participant F as Fallback host
  participant G as GitHub releases
  C->>P: GET channel/update.json and update.json.sig
  alt primary host does not answer
    C->>F: same two files, other host name
  end
  Note over C: Signature against this channel's compiled-in keys
  Note over C: Channel, sequence, expiry, version, halted, rollout, min_version
  C->>G: GET each changed file (allow-listed hosts only)
  G-->>C: file bytes
  Note over C: SHA-256 and size of every file, before it replaces anything
  Note over C: Keep the previous version beside the new one
  Note over C: Start marker written, removed at the start screen
  Note over C: Two starts without reaching it: restore the previous version
  1. Fetch. The manifest and its signature come from https://client.kog.tw/CHANNEL/update.json, then, if that fails, from the fallback host. The fallback has another name because GitHub redirects github.io to the custom domain. Offline or unreachable is quiet; the settings show the last check and its result.
  2. Signature. Checked against the public keys of that channel only (both signatures for stable). Trust never depends on the host or on TLS. The channel inside the payload must equal the configured one.
  3. Rollback and replay protection. sequence is higher than the last one applied on that channel; the manifest has not expired and is not from the future; the version has the channel's form; a version older than the installed one is only applied after the user confirmed a channel switch; and a version the client rolled back from before (bad-version memory) is not tried again.
  4. Policy fields. halted, the rollout_percent bucket and min_version.
  5. Files. Paths and URLs must be on allow-lists: github.com/KoG-teeworlds/kog-client/releases/download/ and client.kog.tw. Every file's SHA-256 and size are checked before it replaces anything, with enough free disk space, a per-file retry, then the next mirror.
  6. Fail-safe. The previous version stays beside the new one (.kogprev), replaced atomically. A start marker is written on launch and removed when the start screen is reached; after 2 starts that did not reach it, the client restores the previous version and remembers the bad one. Settings are never replaced; a config backup is made when the version changes.

What these checks do not cover is on the security page. To check a published manifest yourself, see verify a download.

Not verified. The Windows free-disk check and the executable-bit handling were not run on Windows, and the updater has had little real-world use. Hardware-key signatures were tested with a software emulation of the OpenSSH format, not with a real security key.

Edit this page on GitHub