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

Nginx should only listen on ports > 1024 #3074

Open
sjberman opened this issue Jan 29, 2025 · 1 comment
Open

Nginx should only listen on ports > 1024 #3074

sjberman opened this issue Jan 29, 2025 · 1 comment
Labels
area/security For security best practices enhancement New feature or request

Comments

@sjberman
Copy link
Collaborator

Right now nginx listens on whatever ports are defined in the Gateway listener. However, ports under 1024 are privileged and require the CAP_NET_BIND capability and allowPrivilegeEscalation in order for nginx to be able to listen on them.

For better security posture, we should only configure nginx to listen on ports greater than 1024. We can still allow users to configure their listeners with any port they want (since 80 and 443 are going to be the most common), and we'll configure the nginx Service to listen on those ports, but forward to containerPorts that aren't privileged.

For example:

  listeners:
  - name: http
    port: 80

would result in a Service config like:

ports:
- name: port-80
  port: 80
  protocol: TCP
  targetPort: 20080

where the container and nginx listen on port 20080 for that listener.

Acceptance

  • Listener ports less than 1024 should result in nginx listening on some higher number port that correlates with the defined port
    • this higher port should be defined in such a way to minimize the possibility of collision with a user defined port
  • Listener ports greater than 1024 should be left alone
  • Service ports still match the listener ports
  • If no longer needed, CAP_NET_BIND should be removed and allowPrivilegeEscalation set to false for the nginx deployment
@sjberman sjberman added area/security For security best practices enhancement New feature or request labels Jan 29, 2025
Copy link
Contributor

This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 14 days.

@github-actions github-actions bot added the stale Pull requests/issues with no activity label Feb 13, 2025
@sjberman sjberman removed the stale Pull requests/issues with no activity label Feb 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/security For security best practices enhancement New feature or request
Projects
Status: 🆕 New
Development

No branches or pull requests

1 participant