mirror of
https://github.com/storytold/figcraft.git
synced 2026-10-24 10:27:00 -06:00
Fixes from the security review of the public server: - team libraries only in key-published files on open servers; unpacking bounded by the file cap (zip bombs refused) - byte-bounded send queues per connection and in all, a bound on bytes waiting for the hub, per-address and global download budgets - batches checked against the file, per-address and total caps as files grow (refused with a Reject the app rolls back); the core's recent-batch memory bounded in bytes; nothing confirmed when a log can't be written - usage reports kept in memory; per-kind message caps checked while read - layered IPv6 limits (/64, /56, /48), a global publish rate, connections reserved for sessions, short idle timeout for one-shot requests - revoked links and removed files cut library connections - data directory 0700, server key 0600 from creation - install.sh: SSH ports from sshd, ufw left off when other services listen, unprivileged builds of the latest tag, settings checked before use, own Caddy snippet; systemd memory and network caps; backups check free space and say they hold the key - linger reads raw bytes after an oversized frame (tungstenite asserted)
21 lines
1.4 KiB
Desktop File
21 lines
1.4 KiB
Desktop File
# Nightly backup of figcraft-server's data directory (an example; docs/server.md, "Backups").
|
|
# install.sh installs it with figcraft-backup.timer; turn it on with
|
|
# sudo systemctl enable --now figcraft-backup.timer
|
|
# It checks there is room for the copy (twice the data directory's size free), stops the server
|
|
# for the few seconds the copy takes (apps reconnect on their own), writes
|
|
# /var/backups/figcraft-server/figcraft-YYYY-MM-DD.tar.gz (readable by root only) and keeps the last
|
|
# 7 days. The archives hold every file, the addresses files came from, the reports and the server
|
|
# key: keep them, and any copy off the machine, as private as the server itself.
|
|
|
|
[Unit]
|
|
Description=Back up figcraft-server's data directory
|
|
After=figcraft-server.service
|
|
|
|
[Service]
|
|
Type=oneshot
|
|
Nice=10
|
|
IOSchedulingClass=idle
|
|
UMask=0077
|
|
# `$$` and `%%` are a literal `$` and `%` for the shell (systemd expands the single ones).
|
|
ExecStart=/bin/sh -ec 'dir=/var/backups/figcraft-server; install -d -m 700 "$$dir"; need=$$(du -sk /var/lib/figcraft-server | cut -f1); free=$$(df -k --output=avail "$$dir" | tail -n 1); if [ "$$free" -lt $$((need * 2)) ]; then echo "not enough free space for a backup ($$free KiB free, $$need KiB of data)" >&2; exit 1; fi; systemctl stop figcraft-server; trap "systemctl start figcraft-server" EXIT; tar -C /var/lib -czf "$$dir/figcraft-$$(date +%%F).tar.gz" figcraft-server; find "$$dir" -name "figcraft-*.tar.gz" -mtime +7 -delete'
|