From bf4d8020c4569efaaae989677d886b5cba2b2788 Mon Sep 17 00:00:00 2001 From: Anthony Ettinger Date: Mon, 30 Nov 2026 09:06:02 +0000 Subject: [PATCH] security: refuse symlinks under member homepages (nosymfollow) Members own public_html from a root shell in their pod, so they could plant symlinks to host paths, and Caddy's file_server followed them: two accounts used this to download agentbbs.db and list /var/lib/caddy (TLS keys). setup.sh now bind-mounts $DATA_DIR/users with nosymfollow (persisted in fstab) and restarts Caddy when the mount is new, because Caddy's private mount namespace does not see mounts added after start. Co-Authored-By: Claude Opus 5.5 --- setup.sh | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/setup.sh b/setup.sh index 208bc6b..58355aa 100755 --- a/setup.sh +++ b/setup.sh @@ -186,6 +186,21 @@ log "preparing $DATA_DIR" install -d -o "$SVC_USER" -g "$SVC_USER" -m 0751 "$DATA_DIR" # others may traverse, not list install -d -o "$SVC_USER" -g "$SVC_USER" -m 0700 "$DATA_DIR/ssh" # host key stays private install -d -o "$SVC_USER" -g "$SVC_USER" -m 0755 "$DATA_DIR/users" # tilde homepages live here +# Members write their public_html from a root shell in their pod, so they can +# plant symlinks to host paths; Caddy follows symlinks, which served the BBS +# database and every TLS key to anyone who asked (2026-11 incident). A +# nosymfollow bind mount makes the kernel refuse every symlink under users/, +# for Caddy and everything else. Caddy runs in a private mount namespace +# (PrivateTmp), so it must RESTART, not reload, to see a newly added mount. +CADDY_NEEDS_RESTART=0 +if ! grep -qE "^$DATA_DIR/users[[:space:]]+$DATA_DIR/users[[:space:]].*nosymfollow" /etc/fstab; then + echo "$DATA_DIR/users $DATA_DIR/users none bind,nosymfollow 0 0" >> /etc/fstab +fi +if ! findmnt -no OPTIONS --mountpoint "$DATA_DIR/users" 2>/dev/null | grep -q nosymfollow; then + mountpoint -q "$DATA_DIR/users" || mount --bind "$DATA_DIR/users" "$DATA_DIR/users" + mount -o remount,bind,nosymfollow "$DATA_DIR/users" + CADDY_NEEDS_RESTART=1 +fi install -d -o "$SVC_USER" -g "$SVC_USER" -m 0755 "$DATA_DIR/web" # site root install -d -o "$SVC_USER" -g "$SVC_USER" -m 0755 "$DATA_DIR/domains" # symlink farm: custom domain -> users//public_html # Landing page (always regenerated — it's templated marketing content, not user @@ -1017,7 +1032,11 @@ https:// { CADDY ufw allow 80/tcp >/dev/null ufw allow 443/tcp >/dev/null -systemctl reload caddy 2>/dev/null || systemctl restart caddy +if [ "$CADDY_NEEDS_RESTART" = 1 ]; then + systemctl restart caddy +else + systemctl reload caddy 2>/dev/null || systemctl restart caddy +fi # ---- 9b. Ergo IRC server (co-located ${IRC_DOMAIN}; humans + agents) -------- # A lightweight single-binary IRC network on its own ports. Native clients hit