Skip to content

Fix/restrict lan only services - #2904

Open
szaimen wants to merge 9 commits into
mainfrom
fix/restrict-lan-only-services
Open

szaimen wants to merge 9 commits into
mainfrom
fix/restrict-lan-only-services

Conversation

@szaimen

@szaimen szaimen commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator

Several optional services are only meant to be used inside the local
network, but their ufw rules allowed any source address.

🤖 AI (if applicable)

  • The content of this PR was partly or fully generated using AI (N/A)

szaimen and others added 7 commits November 25, 2026 12:13
Several optional services are only meant to be used inside the local
network, but their ufw rules allowed any source address. These helpers
let scripts restrict such rules to private address ranges.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Simon L. <szaimen@e.mail.de>
Port 3389 was allowed from any source, exposing the xrdp login to the
internet whenever the port is reachable.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Simon L. <szaimen@e.mail.de>
The wg-easy admin interface is documented as local-network only, but
neither Apache nor ufw restricted the source address.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Simon L. <szaimen@e.mail.de>
Port 53 was published on all interfaces. Docker publishes ports in the
nat table before ufw, so it could not be restricted and Pi-hole could
end up as an open resolver usable for amplification attacks. Publish it
only on the server's private address and refuse to install otherwise.
The admin web interface is also limited to private networks now.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Simon L. <szaimen@e.mail.de>
Until the admin user is created, anyone reaching the public vhost could
complete the startup wizard and take over the server. The LAN-only ports
(unencrypted http, https, discovery) are restricted to private networks
as well.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Simon L. <szaimen@e.mail.de>
Samba was allowed from any source, which exposes file shares to the
internet whenever the ports are reachable.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Simon L. <szaimen@e.mail.de>
Webmin, AdminNeo, Netdata, RDP, Samba and the Pi-hole, WireGuard and
Jellyfin LAN ports were allowed from any source, and all UDP ports were
open for 192.168.0.0/16 although only UPnP (1900/udp) needs it.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Simon L. <szaimen@e.mail.de>
Binding port 53 to the server's address breaks DNS for the whole network
as soon as that address changes. Pi-hole is only meant for trusted home
networks where the router doesn't forward port 53, so not restricting it
is acceptable.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Simon L. <szaimen@e.mail.de>
Comment thread not-supported/smbserver.sh Resolved
Comment thread not-supported/smbserver.sh Resolved
Comment thread not-supported/smbserver.sh Resolved
Comment thread not-supported/smbserver.sh Resolved
Comment thread not-supported/smbserver.sh Resolved
@szaimen
szaimen requested a review from enoch85 November 25, 2026 13:24
@enoch85

enoch85 commented Nov 25, 2026

Copy link
Copy Markdown
Member

Not approving this yet. The restrictions work, but two things need to change:

  1. apps/netdata.sh L80-L86 still tells users to open port 19999 to reach Netdata from their domain. With this PR, firewall.sh only allows 19999 from private networks, so once the firewall is enabled that can't work: from a public address the port stays blocked. Please either change the message or leave Netdata out of the private-only rules.
  2. In pi-hole.sh, L274-L277 and L380-L381 were written for the port 53 binding that 532b74b reverted. Port 53 behaves as on main again, so both hunks are leftovers, and the new comment explains a decision ("This is acceptable since …") that is already in 532b74b's commit message. Please restore both to main.

Tested on a fresh Nextcloud 35.0.3 on Ubuntu 26.04, from a public and a LAN client. Everything else works:

  • With ufw on, RDP, Samba, the Pi-hole and WireGuard web UIs, Jellyfin's 8096, Webmin, Netdata and AdminNeo are blocked from the public client and reachable from the LAN. Nextcloud and Talk stay public.
  • With ufw off, Apache answers 403 to the public client for the Pi-hole and WireGuard UIs and for Jellyfin's /Startup (also with other casing, %53 and //), and 200 from the LAN.
  • Uninstalling removes the new rules.

netdata.sh tells users to open port 19999 to reach Netdata from their
domain, which a private-only rule would block. Also drop the pi-hole.sh
comment changes left over from the reverted port 53 binding.

Assisted-by: Claude Code:claude-opus-5-5
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Simon L. <szaimen@e.mail.de>
@szaimen

szaimen commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator Author

Not approving this yet. The restrictions work, but two things need to change:

  1. apps/netdata.sh L80-L86 still tells users to open port 19999 to reach Netdata from their domain. With this PR, firewall.sh only allows 19999 from private networks, so once the firewall is enabled that can't work: from a public address the port stays blocked. Please either change the message or leave Netdata out of the private-only rules.
  2. In pi-hole.sh, L274-L277 and L380-L381 were written for the port 53 binding that 532b74b reverted. Port 53 behaves as on main again, so both hunks are leftovers, and the new comment explains a decision ("This is acceptable since …") that is already in 532b74b's commit message. Please restore both to main.

Tested on a fresh Nextcloud 35.0.3 on Ubuntu 26.04, from a public and a LAN client. Everything else works:

  • With ufw on, RDP, Samba, the Pi-hole and WireGuard web UIs, Jellyfin's 8096, Webmin, Netdata and AdminNeo are blocked from the public client and reachable from the LAN. Nextcloud and Talk stay public.
  • With ufw off, Apache answers 403 to the public client for the Pi-hole and WireGuard UIs and for Jellyfin's /Startup (also with other casing, %53 and //), and 200 from the LAN.
  • Uninstalling removes the new rules.

Should be addressed now 👍

@szaimen

szaimen commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator Author

@enoch85 can you please have another look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants