Hardening
This page lists the steps that make a Lasbolt server harder to attack. The install page already has the unit file. Read Security for what Lasbolt defends against.
systemd-analyze security for this page. Run systemd-analyze security lasboltd on your host and read the score.Run as a separate user
Run lasboltd as its own user (lasbolt) with no login shell. Do not run it as root. lasboltd needs no capability, because it listens on a port above 1024 behind the proxy.
The systemd sandbox
| Setting | What it does |
|---|---|
NoNewPrivileges=true | The process and its children cannot get more rights. |
CapabilityBoundingSet= and AmbientCapabilities= (empty) | The process has no Linux capability. |
ProtectSystem=strict and ReadWritePaths=/var/lib/lasbolt | The file system is read-only, except the data folder. |
ProtectHome=true, PrivateTmp=true, PrivateDevices=true | No home folders, a private /tmp, no device files. |
ProtectKernelTunables, ProtectKernelModules, ProtectKernelLogs, ProtectControlGroups, ProtectClock, ProtectHostname=true | The process cannot change kernel settings, load modules, read the kernel log, change cgroups, the clock or the host name. |
ProtectProc=invisible and ProcSubset=pid | The process sees only its own entries in /proc. |
LockPersonality=true | The process cannot change its execution domain. |
MemoryDenyWriteExecute=true | No memory is both writable and executable. A Go program built without cgo needs no JIT. |
RestrictRealtime, RestrictSUIDSGID, RestrictNamespaces=true | No realtime scheduling, no SUID files, no new namespaces. |
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX | Only IP sockets and Unix sockets. |
SystemCallArchitectures=native, SystemCallFilter=@system-service, SystemCallErrorNumber=EPERM | Only the system calls that a normal service needs. |
UMask=0077 | New files are private to the service user. |
RuntimeDirectory=lasbolt, RuntimeDirectoryMode=0700 | A private folder for the control socket. |
If you add a feature that needs more, for example a different folder for backups, add that path to ReadWritePaths.
File permissions
| Path | Owner and mode | Why |
|---|---|---|
/var/lib/lasbolt | lasbolt:lasbolt, 0700 | The database and the backups. |
/var/lib/lasbolt/backups | 0700 | The server sets this mode itself. |
/etc/lasbolt | root:lasbolt, 0750 | Settings and keys. |
/etc/lasbolt/lasboltd.env | root:lasbolt, 0640 | Settings. No secrets. |
/etc/lasbolt/passphrase or kek | lasbolt, 0600 or 0400 | The server refuses wider modes. |
/etc/lasbolt/backup.key.pub | 0644 | A public key. |
backup.key (private) | not on the server | Opens sealed backups. |
/run/lasbolt/ctl.sock | lasbolt, 0600 | Only the service user and root can use it. |
Keep the private backup key and a copy of the unseal secret off the server.
Network exposure
lasboltdlistens on127.0.0.1only. The proxy is the only way in.- Open ports 443 and 80 (for the redirect) on the proxy. Do not open 8080.
- The UDP port 7849 of peer sync is open on all addresses by default. If you do not want it, set
--peer-udp off. If you use it, allow it in the firewall. See TLS and proxy. - The control socket has no network port. Do not put it in a folder that other users can write to.
- Set
--trusted-proxyto the proxy address only. - Use HTTPS for all clients. The server sends
Strict-Transport-Securitywith a long max age. - Keep the host patched. Restrict SSH to key login.
Example for firewalld:
sudo firewall-cmd --permanent --add-service=https --add-service=http
sudo firewall-cmd --permanent --add-port=7849/udp # only if peer sync should work
sudo firewall-cmd --reloadRate limits
The server limits failed logins. The limits are built in and have no flag:
- Per user name: 5 failures, then one more try each minute.
- Per client address: 20 failures, then one more try each 15 seconds.
- Checks of invitation tokens, device-code logins and reset links have limits of their own.
The per-address limits work only if --trusted-proxy is right. Without it, all users share the address of the proxy. Add a limit in the proxy for the paths /login and /register if you expect many bad requests.
Registration
- Keep the registration mode at
inviteorclosed. See First owner and users. - Use
openonly for a short time. - Give the roles
ownerandadminto few people.
Second factors for admins
Ask each owner and admin to turn on two-factor authentication in Settings › Security. A second factor limits the damage of a stolen master password. Admin functions also need a login with the master password: the lasbolt CLI and the extensions cannot do them.
A policy that makes a second factor required for all users is planned. It is not available yet.
Other steps
- Seal the backups to a key that is not on the server. See Backups and restore.
- Use the terminal passphrase if a person can be there at a restart, or put the key file on a medium that is not the data disk.
- Watch the log. See Monitoring.
- Rebuild from a known commit. The build is reproducible:
make release-checkbuilds twice and compares the binaries.