Security for owners
This page is for you as the person who runs the site. After reading it you know what the internet can reach, which secrets matter, what is off until you choose it, how updates are protected, and what you must keep safe yourself.
Keeping your server's operating system up to date is part of this too. The installer switches on automatic security updates, and the Doctor row Security updates install themselves checks they stay on.
What the internet can reach
Your install answers on three names, all on your domain:
| Address | What answers | What it is for |
|---|---|---|
example.com |
The website | Pages, sign-in, the Admin Panel, payment webhooks, and the Matrix discovery files |
api.example.com |
The chat service | The live chat connection browsers and OBS use, and a few read-only answers such as "is the stream live" |
matrix.example.com |
The homeserver (Synapse) and its sign-in service (MAS) | Community rooms, direct messages, sign-in, Matrix apps |
Everything else runs on a private network inside the install and has no address on the internet: the database, the ingest service, the sign-in service's admin interface, and the chat service's internal routes.
One reverse proxy (Caddy) is the only thing that receives visitors. In tunnel mode it opens no port at all: the tunnel connects out to Cloudflare and hands requests to it. In direct mode it opens ports 80 and 443 (443 also over UDP, for HTTP/3) and nothing else. The proxy sets the visitor's address itself on every request, so a visitor cannot pretend to come from somewhere else to get past a rate limit or a ban.
The internal API secret
The website and the ingest service talk to the chat service with a shared secret, STREAM_API_SECRET. Every route that changes something (chat, money, moderation, identity, settings) requires it. Routes that hand out stored keys are stricter still: they accept the secret and nothing else, and never from a browser.
The chat service fails closed. If it is told to enforce the secret but has none, it refuses to start with a [FATAL] STREAM_API_ENFORCE is on but STREAM_API_SECRET is not set message. The installer always generates the secret, so you only see this if .env lost the line.
The same secret is the key behind viewers' public ids (see Linking stays private). Changing it gives everyone new public ids, so keep the value the installer made.
Things that are off until you choose them
| Setting | On a new install | Where it is explained |
|---|---|---|
| Federation | Off. Your rooms stay on your own server until you switch it on in Admin Panel → Site → Community, card Federation and sign-up. | Federation |
| Sign-in from other Matrix servers | Off. Accounts on your own homeserver sign in; you choose which other servers may join them. | Federated sign-in. Set it in Admin Panel → Site → Site, card Sign-in from other servers. |
| Let people make accounts (sign-up on the homeserver) | Closed until you open it with Let people make accounts in Admin Panel → Site → Community, card Federation and sign-up. It stays closed while setup runs, so nobody can take your community's names first. | Sign-up |
| Every optional module, and every AI feature | Off | Turning features on and off |
| Bug reports to the project | None are sent in this release, so the Send bug reports switch is hidden |
Recommended: switch on federation and sign-in from other servers when you want your community to meet accounts and servers you do not run. Until then, keeping them off means every account in your rooms is one you can ban at the source.
The secrets that matter
The installer generates every secret at random and writes them to /opt/blackbranch/.env, which only root can read. They are yours: they exist nowhere else, except inside your encrypted backups. This release has no command to change a secret (sudo blackbranch set changes display values only), so a secret keeps the value the installer gave it. What each one protects is on The install's settings file. What happens if you lose one:
| Secret | If it is lost |
|---|---|
BACKUP_PASSPHRASE (on your recovery sheet) |
No backup can be opened, by anyone. It cannot be reset. |
TOKEN_ENC_KEY |
Every viewer must link their platforms again. Restore .env instead. |
INSTANCE_MASTER_KEY |
You must enter every saved key again. Restore .env instead. |
Every other secret in .env |
Restore .env from a backup. |
The homeserver's signing key (in the homeserver's data, not .env) |
Cannot be replaced. Other servers and apps would no longer trust your server as the same one. It is in every backup. |
The sign-in service's keys (matrix/mas-keys.yaml) |
Everyone signs in again. Restore it from a backup. |
Recommended: keep two things off the server, in a password manager: the backup passphrase from the recovery sheet, and a copy of
.env. With those and your backups you can rebuild the whole site on a new server. See Moving to a new server.
The Doctor's Secrets rows check all of this. A red row there almost always means .env was replaced or edited. The fix is to restore it from a backup rather than make new values.
Never paste anything from .env into a chat, an issue or a support request. When you ask for help, attach the report from sudo blackbranch doctor --report. It holds no secret, chat text, viewer id or domain, and the command checks it against every value in .env before keeping it.
The Cloudflare account certificate
In tunnel mode, the installer signs in to Cloudflare with an account certificate that can create and delete tunnels and DNS records on your account. The installer deletes the file once the tunnel is set up, and backups leave it out. The API token inside it stays valid at Cloudflare until you delete it. The steps are on Putting your domain on Cloudflare.
The setup link
The link the installer prints lets whoever opens it first create the admin account. It works only until that account exists. Until then, keep it to yourself. If you think someone else saw it, replace it:
sudo blackbranch setup-link --new
What the website can make the server do
The website never controls Docker or runs commands on the server. When it needs something from the server (a restart after a setting change, new homeserver settings, a Doctor check, an update you pressed Apply for), it drops a request with a fixed name into a folder. A root service on the server runs the one action that name stands for. Any other name is refused, and the request's contents are never read. Even a website that was broken into could only ask for the short list of actions the Admin Panel already offers. The list is on The server command.
The website does hold secrets of its own: the key that encrypts viewers' linked platform sign-ins (TOKEN_ENC_KEY), the key that signs site sessions (AUTH_SECRET), the shared secret for the chat service (STREAM_API_SECRET), its database password, and its sign-in client's secret for the homeserver.
The one secret the website never keeps is the backup passphrase. It is handed to the site only while the setup page with the recovery sheet is on screen, and the server takes it back afterwards. The website chooses where backups go, so a website that kept the passphrase could send your backups elsewhere and open them.
Signed updates
Your server updates itself from the project's release feed, and it checks what it gets:
- The feed is signed with the project's release key. Your server checks the signature against the public key it was installed with, and an update never changes that key.
- Each release names the exact fingerprint (sha256) of its source and the exact digest of every container image, so what is downloaded is exactly what was announced.
- It refuses an unsigned or expired feed, a release older than the one it runs, and a feed for another channel.
- Before anything changes it backs up. After the switch it runs a health check, and if that fails it goes back to the previous release and its data by itself.
- A security release installs itself at your quiet hour, never while you are live. A feature release waits for you.
The details are on Updates and rollback.
The first install is different: it trusts the copy of Black Branch you downloaded. Install only with the command from the project's own site, blackbranch.app, or from its public repository, github.com/Black-Branch/blackbranch.
Keeping it safe
- Save the recovery sheet's passphrase and a copy of
.envin a password manager, off the server. - Send backups somewhere other than the server's own disk: a bucket or another server.
- Keep your server account's password and SSH key safe. Root on the server can read everything that is not end-to-end encrypted.
- Give Stripe a restricted key, not your secret key (Card payments (Stripe)). Give every other service the narrowest key it offers.
- Revoke the Cloudflare account certificate once the tunnel works, unless you plan to make another tunnel.
- Leave federation, sign-in from other servers and open sign-up off until you want them.
- Never run
docker volume rmon the install's volumes. They hold the databases and the homeserver's signing key, and only a backup brings them back. - Open the Doctor now and then, and after every change at a payment service. The Doctor shows problems on screen; for the urgent ones, set up phone alerts. The server also alerts you through an ntfy topic or an email command when a backup or restore check fails, an update goes back, the disk runs low or a certificate nears expiry.