Bug type: Installer / Server
Plugin / server version: Any.
Homeserver name: N/A
Description:
Currently the installer allows for an option for the user to be able to remotely manage their Postgres database. It uses ufw for this, and it sets up the allowlist / ip-whitelisting there.
The problem:
The NAT table PREROUTING chain shows Docker DNATing port 5432 to 172.18.0.7:5432 for all sources (0.0.0.0/0). This happens before UFW even sees the packet. UFW's INPUT chain is irrelevant for forwarded/NATted traffic. The created UFW rule for 5432 is correct but fires too late in the netfilter pipeline, meaning that essentially the database is wide open, and I've seen bruteforcing on my postgres instance. Luckily we're not using a default database name and a simple password, but this is a problem.
The fix:
- Remove the dependancy on ufw from the installer (it's simply not needed)
- Use iptables to handle the ip whitelisting
- Change the manage.sh script to alter iptables in stead of ufw.