Skip to main content
An update runs a program on your users’ computers, so it matters who can change what they download. This page explains what Bach checks by default, and the two extra protections you can turn on.

What is always checked

  • Downloads use https only, including redirects.
  • The downloaded file must match the checksum (SHA-256) in the feed.
  • It must be a setup file for the same app id, with the version the feed announced.
  • It’s checked again right before it runs, not only after downloading.
The weak point: the feed and the file usually live on the same host. Someone who takes over that host could replace both. Signed feeds and a required signature close this.

Sign the update feed

You create a key pair once. The private key stays with you; the public key goes into your setup files. Installed apps then only accept feed entries signed with your private key.
This writes the private key to feed-key.private and prints the public key. It refuses to overwrite an existing file. Put the public key in bach.toml:
bach.toml
When you build or write the feed, give Bach the private key in an environment variable:
BACH_FEED_KEY (the key itself) works too, for example as a CI secret. Without the key, bach build writes an unsigned feed and warns; bach feed refuses.
Keep feed-key.private out of Git and back it up. Apps that trust this key accept nothing else, so if you lose it, you can’t send them signed updates.
On Linux and macOS the new key file is readable only by you. On Windows it has the permissions of its folder, so keep it somewhere private. The signature covers the version, links, checksums, size, rollout and patch. Release notes aren’t signed.

Expire old feed entries

A signature proves who wrote an entry, not when. Someone who controls your host could keep serving an old, correctly signed entry, so users never see a security fix. To limit that:
bach.toml
Installed apps then ignore entries signed more than 90 days ago. The consequence: you must sign the current release again before it gets that old, for example with a weekly scheduled workflow that runs bach feed and uploads latest.json. Otherwise your users stop getting updates.

Change the signing key

If the key leaks or you want a new one, installed apps have to learn the new key while the old one still works:
  1. Make a new key with bach feed-key, keeping the old one. Release a version with the old key as public_key and the new one as next_public_key. Sign that release’s feed with the old key.
  2. Wait until most users have that version. Then release with only the new key as public_key, and sign with the new key.
Users who skipped step 1 refuse the new feed and have to download the setup file again. A leaked key can’t be revoked from a distance.

Require your code signature

If you sign your setup files, the installed app can also require that updates are signed by you:
bach.toml
Before running a downloaded update, the app asks Windows whether the signature is valid and whether the certificate’s name or organization is exactly this text. An unsigned or differently signed file is deleted and not run. A plain name can be shared by another company. To pin yours exactly, use the certificate’s whole subject. Print it from a signed file:
bach.toml
Things to keep in mind:
  • Sign every file you publish, including patches. bach build --sign checks that the certificate matches signer and stops the build if not.
  • The first version with signer has to be installed by hand, because older copies don’t know the rule.
  • If your certificate’s name changes, you have to give users a new setup file.
The signed feed and the required signature work independently. Using both is the strongest setup.

On a Mac

On a Mac, the same signer checks the Setup app inside the downloaded .dmg or .zip. It has to be signed with a Developer ID Application certificate that Apple issued, with that name. Self-signed and ad hoc signatures are refused. This needs Bach 0.11.2 or newer. A full subject on a Mac has only two parts, such as CN=Example Inc., OU=ABCDE12345, where OU is your team id. A full subject only matches the system it was written for, so an app that ships on Windows and macOS needs the plain name, and both certificates have to carry it. Since Bach 0.11.3, bach build checks this before you publish. With --sign, a certificate that installed Macs would refuse stops the build. Without --sign, the build succeeds and warns that installed copies will refuse the file. bach sign checks a .dmg or .zip too. None of these checks ask whether the app was notarized.