Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit Hetzner firewall port exposure #474

Open
roy-hardin opened this issue Oct 27, 2024 · 2 comments
Open

Limit Hetzner firewall port exposure #474

roy-hardin opened this issue Oct 27, 2024 · 2 comments

Comments

@roy-hardin
Copy link

roy-hardin commented Oct 27, 2024

Wouldn’t security be improved if the hetzner-k3s create command of hetzner-k3s version 2.0.8 did not (re-)open the Hetzner Cloud Firewall to allow any incoming traffic from any IPv4 or IPv6 address on ports 5001, 30000 through 32767, and for ICMP (ping)?

According to the OWASP Kubernetes Security Cheat Sheet:

Since Kubernetes clusters usually listen on a range of well-defined and distinctive ports, it is easier for attackers to identify the clusters and attack them. An overview of the default ports used in Kubernetes is provided below. Make sure that your network blocks access to ports, and you should seriously consider limiting access to the Kubernetes API server to trusted networks.

Control plane nodes

Protocol Port Range Purpose
TCP 6443- Kubernetes API Server
TCP 2379-2380 etcd server client API
TCP 10250 Kubelet API
TCP 10251 kube-scheduler
TCP 10252 kube-controller-manager
TCP 10255 Read-Only Kubelet API

Worker Nodes

Protocol Port Range Purpose
TCP 10250 Kubelet API
TCP 10255 Read-Only Kubelet API
TCP 30000-32767 NodePort Services

Given these guidelines, would it be possible to restrict the firewall configuration to enhance security while preserving necessary functionality?

@roy-hardin roy-hardin changed the title Enhancement Request: Limit Hetzner Firewall Port Exposure for hetzner-k3s create Limit Hetzner firewall port exposure for hetzner-k3s create Oct 28, 2024
@roy-hardin roy-hardin changed the title Limit Hetzner firewall port exposure for hetzner-k3s create Limit Hetzner firewall port exposure Oct 28, 2024
@vitobotta
Copy link
Owner

Port 5001 is required for the embedded registry mirror to work. Unfortunately during my testing I found that it doesn't work out of the box with peers communicating through the private network if available. Connections between peers are authenticated, but I will see if I can test Spegel (the embedded registry mirror) again to see if something has been fixed and whether it works now with the private network.

Ports 30000-32767 are required for NodePort services, so they only pose a risk if you explicitly decide to expose a service to the Internet on a NodePort. Otherwise those ports are not in use so they don't pose any risk IMO. I have in on my list to make it possible to enable/disable the NodePort range with a config option, though.

As for ICMP, it's probably a matter of opinions but I think that preventing pings does little in terms of security since most bots and scanners etc will knock on various ports to look for holes and vulnerabilities. They are unlikely going to stop just because an IP address doesn't respond to ping. Again, it's something I can make configurable anyway.

@roy-hardin
Copy link
Author

Thanks for your detailed response. I understand the port requirements for 5001 and 30000-32767 and appreciate your explanation about the configuration. It’s reassuring that peer connections are authenticated, and NodePort services only pose a risk if exposed. Configuring the NodePort range and ICMP settings in the future would be great for those who want more control over the firewall setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants