Skip to content

Latest commit

 

History

History
137 lines (112 loc) · 7.77 KB

security.md

File metadata and controls

137 lines (112 loc) · 7.77 KB

Security

This stack stores your passwords and files, so treat the server like a safe.


Threat model

What this design assumes:

  • The LAN is the trust boundary. Nothing here is meant to face the public internet. There is no remote access by design.
  • Anyone with the disk has everything. The apps store data unencrypted on disk, so full-disk encryption is the control that matters most against a stolen machine.
  • The dashboard is a root shell. /admin/terminal is a real PTY running as root under systemd. That's why hsctl ui binds only loopback + the Docker bridge gateway, not the LAN directly (if the bridge can't be detected it warns and falls back to all interfaces), and why every admin route sits behind a login.

What it does not protect against: a hostile device already on your LAN, a compromised browser on a trusted device, or someone with physical access to an unlocked, running machine.


Hardening checklist

  • Encrypt the server's disk (most important). The apps store data unencrypted on disk — anyone who takes the drive can read your passwords and files. Use full-disk encryption (LUKS): the easiest way is to tick "Encrypt the new installation" when installing Ubuntu. Without it, none of the rest matters if the machine is stolen.
  • Keep it on your LAN only — do not expose it to the internet. Don't port-forward any of these ports on your router. The stack is designed for home-network access; if you need it from outside, reach the LAN over a VPN rather than exposing any service directly.
  • Firewall (optional but nice). If you run ufw, allow only what's needed:
    sudo ufw allow 80,443,8443,8444,8445,8446,8447,8448,53/tcp && sudo ufw allow 53/udp
    The dashboard's own port (UI_PORT, default 8088) is deliberately absent — it isn't bound to the LAN, so it needs no rule.
  • Use strong, unique passwords and turn on 2FA. Especially the Vaultwarden master password (nobody can reset it for you) and the Nextcloud/Pi-hole admin logins.
  • Keep things updated. Run hsctl updates (or the dashboard's Updates page) to see what's behind, and hsctl updates --apply <container> to move one app to its newer release — the new pin is recorded in that app's gitignored .env, never in the tracked compose files. Keep the OS patched too. Want to try a new image (or a newer restic) before touching the live box? Test it in the sandbox first.
  • Encrypt Nextcloud (optional). Server-side encryption is off by default; enable it in Nextcloud → Admin → Settings → Security if you want it on top of disk encryption.

On image pinning: every image is pinned to an exact release, so an install — or a rebuild from a backup — runs exactly what was tested: vaultwarden/server:1.37.4, nextcloud:35.0.2-apache, pihole/pihole:2026.10.0, stirling-tools/stirling-pdf:3.2.2, it-tools:2024.10.22-7ca5933, and the supporting caddy:2.11.7-alpine, postgres:18.6-alpine, redis:8.10.2-alpine, nginx:1.31.8-alpine. hsctl updates reports newer releases: a new patch or minor release is a routine update, a new major (Nextcloud 36, Postgres 19) is applied one app at a time, after a sandbox test. Postgres majors also need their data migrated, so they're never applied in place.


Where the secrets live

Everything generated by hsctl setup is git-ignored. Permissions differ, and the difference matters:

File Mode Contains
<service>/.env 0600 every generated service secret (DB/Redis passwords, admin passwords, the Argon2 hash of the Vaultwarden admin token)
setup.conf 0600 your settings (IP, ports, timezone) — not secrets
.ui-password 0600 dashboard admin password
backup.conf 0600 backup destination + retention
.restic-password 0600 the backup encryption password
.backup-env 0600 cloud credentials for the off-site replica (S3 keys)
WELCOME.txt 0644 a handout of the addresses (dashboard, apps, certificate) — no secrets

These files belong to you (the repo's owner) even when root writes them — sudo hsctl, the dashboard service and the backup timer all hand them back — so they're readable by you and by root, and by nobody else.

Two things to act on:

  • Save the logins setup prints. They're shown once, at the end of hsctl setup (or on the wizard's Your logins step). All but one can be shown again with hsctl secrets show; the Vaultwarden admin token is stored only as a hash, so if you didn't save it, make a new one with hsctl secrets rotate-vw-admin.
  • Back up .restic-password somewhere else. It encrypts your backups; without it they are mathematically unrecoverable. Write it down or store it in Vaultwarden — not only on the machine the backups protect.

The certificate authority's private key lives in the caddy-data Docker volume. Anyone with it could impersonate your sites, so it is included in backups and shouldn't leak.


Changing & rotating passwords

After first setup it's good practice to set your real passwords inside each app. For the human logins, the value in .env is only used to bootstrap the account — once you change it in the app, the .env value is stale (and for Nextcloud you can blank it).

  • Vaultwarden — your master password isn't in .env at all; you set it when you create your account and change it in the web vault (Account settings → Master password). The only .env value is the /admin panel token (VW_ADMIN_TOKEN), which hsctl stores as an irreversible Argon2id hash (never plaintext). Rotate it any time with hsctl secrets rotate-vw-admin — it generates a new token, prints it once for you to save, stores the hash, and recreates the container.
  • Nextcloud — NC_ADMIN_PASSWORD is used only on first install to create the admin user. Change the password in the web UI (Personal → Security) or:
    docker compose -f nextcloud/docker-compose.yml exec -u www-data app php occ user:resetpassword admin
    After that the .env value does nothing — you can blank it.
  • Pi-hole — the admin password is re-applied from the env on each start, so edit PIHOLE_PASSWORD in pihole/.env then cd pihole && docker compose up -d --force-recreate.
  • Dashboard admin — hsctl secrets set-ui-password ['new-password'], which also restarts the dashboard. See configuration.md.
  • Postgres / Redis (the machine passwords) — these are never typed by a human, so leave them as the long random values hsctl generated. Rotating them is a coordinated change (and note POSTGRES_PASSWORD only sets the password on the first DB init — changing it in .env later does nothing). To actually rotate the DB password:
    docker exec -it nextcloud-db psql -U nextcloud -c "ALTER USER nextcloud PASSWORD 'NEW';"
    # then set the same value in nextcloud/.env (POSTGRES_PASSWORD) and recreate the app:
    cd nextcloud && docker compose up -d --force-recreate

See your current generated logins anytime with hsctl secrets show.

To rotate the secrets that are safe to rotate in one go, hsctl setup --force (it asks you to type REGENERATE) generates a new Vaultwarden admin token and new Pi-hole and Redis passwords, in place, and prints them. Nextcloud's database and admin passwords are kept while Nextcloud has data — rotating them would lock it out of its own database — so for a completely fresh start, delete the data first (hsctl down --volumes).