mirror of
https://github.com/profullstack/agentbbs.git
synced 2026-12-01 17:24:48 +00:00
security: refuse symlinks under member homepages (nosymfollow) (#179)
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 <noreply@anthropic.com>
This commit is contained in:
parent
fc8206d0e2
commit
1655e7617f
1 changed files with 20 additions and 1 deletions
19
setup.sh
19
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 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 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
|
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/web" # site root
|
||||||
install -d -o "$SVC_USER" -g "$SVC_USER" -m 0755 "$DATA_DIR/domains" # symlink farm: custom domain -> users/<name>/public_html
|
install -d -o "$SVC_USER" -g "$SVC_USER" -m 0755 "$DATA_DIR/domains" # symlink farm: custom domain -> users/<name>/public_html
|
||||||
# Landing page (always regenerated — it's templated marketing content, not user
|
# Landing page (always regenerated — it's templated marketing content, not user
|
||||||
|
|
@ -1017,7 +1032,11 @@ https:// {
|
||||||
CADDY
|
CADDY
|
||||||
ufw allow 80/tcp >/dev/null
|
ufw allow 80/tcp >/dev/null
|
||||||
ufw allow 443/tcp >/dev/null
|
ufw allow 443/tcp >/dev/null
|
||||||
|
if [ "$CADDY_NEEDS_RESTART" = 1 ]; then
|
||||||
|
systemctl restart caddy
|
||||||
|
else
|
||||||
systemctl reload caddy 2>/dev/null || systemctl restart caddy
|
systemctl reload caddy 2>/dev/null || systemctl restart caddy
|
||||||
|
fi
|
||||||
|
|
||||||
# ---- 9b. Ergo IRC server (co-located ${IRC_DOMAIN}; humans + agents) --------
|
# ---- 9b. Ergo IRC server (co-located ${IRC_DOMAIN}; humans + agents) --------
|
||||||
# A lightweight single-binary IRC network on its own ports. Native clients hit
|
# A lightweight single-binary IRC network on its own ports. Native clients hit
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue