Skip to content

Commit 5967351

Browse files
committed
Revert "Fix port binding with reduced privileges (#3574)"
This reverts commit 573828e.
1 parent 58ab6e2 commit 5967351

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

build/Dockerfile.nginx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,15 @@ RUN --mount=type=bind,from=nginx-files,src=nginx_signing.rsa.pub,target=/etc/apk
1616
printf "%s\n" "https://packages.nginx.org/nginx-agent/alpine/v$(egrep -o '^[0-9]+\.[0-9]+' /etc/alpine-release)/main" >> /etc/apk/repositories \
1717
&& apk add --no-cache nginx-agent=${NGINX_AGENT_VERSION#v}
1818

19-
RUN apk add --no-cache bash \
19+
RUN apk add --no-cache libcap bash \
2020
&& mkdir -p /usr/lib/nginx/modules \
21+
&& setcap 'cap_net_bind_service=+ep' /usr/sbin/nginx \
22+
&& setcap -v 'cap_net_bind_service=+ep' /usr/sbin/nginx \
23+
&& setcap 'cap_net_bind_service=+ep' /usr/sbin/nginx-debug \
24+
&& setcap -v 'cap_net_bind_service=+ep' /usr/sbin/nginx-debug \
2125
# Update packages for CVE-2025-32414 and CVE-2025-32415
2226
&& apk --no-cache upgrade libxml2 \
27+
&& apk del libcap \
2328
# forward request and error logs to docker log collector
2429
&& ln -sf /dev/stdout /var/log/nginx/access.log \
2530
&& ln -sf /dev/stderr /var/log/nginx/error.log

build/Dockerfile.nginxplus

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,13 @@ RUN --mount=type=secret,id=nginx-repo.crt,dst=/etc/apk/cert.pem,mode=0644 \
2222
&& printf "%s\n" "https://pkgs.nginx.com/nginx-agent/alpine/v$(egrep -o '^[0-9]+\.[0-9]+' /etc/alpine-release)/main" >> /etc/apk/repositories \
2323
&& apk add --no-cache nginx-plus nginx-plus-module-njs nginx-plus-module-otel nginx-agent=${NGINX_AGENT_VERSION#v}
2424

25-
RUN apk add --no-cache bash \
25+
RUN apk add --no-cache libcap bash \
2626
&& mkdir -p /usr/lib/nginx/modules \
27+
&& setcap 'cap_net_bind_service=+ep' /usr/sbin/nginx \
28+
&& setcap -v 'cap_net_bind_service=+ep' /usr/sbin/nginx \
29+
&& setcap 'cap_net_bind_service=+ep' /usr/sbin/nginx-debug \
30+
&& setcap -v 'cap_net_bind_service=+ep' /usr/sbin/nginx-debug \
31+
&& apk del libcap \
2732
# forward request and error logs to docker log collector
2833
&& ln -sf /dev/stdout /var/log/nginx/access.log \
2934
&& ln -sf /dev/stderr /var/log/nginx/error.log

charts/nginx-gateway-fabric/templates/scc.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ metadata:
4444
name: {{ include "nginx-gateway.scc-name" . }}-nginx
4545
labels:
4646
{{- include "nginx-gateway.labels" . | nindent 4 }}
47-
allowPrivilegeEscalation: false
4847
allowHostDirVolumePlugin: false
4948
allowHostIPC: false
5049
allowHostNetwork: false
@@ -70,6 +69,8 @@ seLinuxContext:
7069
type: MustRunAs
7170
seccompProfiles:
7271
- runtime/default
72+
allowedCapabilities:
73+
- NET_BIND_SERVICE
7374
requiredDropCapabilities:
7475
- ALL
7576
volumes:

deploy/openshift/deploy.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,8 +529,9 @@ allowHostIPC: false
529529
allowHostNetwork: false
530530
allowHostPID: false
531531
allowHostPorts: false
532-
allowPrivilegeEscalation: false
533532
allowPrivilegedContainer: false
533+
allowedCapabilities:
534+
- NET_BIND_SERVICE
534535
apiVersion: security.openshift.io/v1
535536
fsGroup:
536537
ranges:

internal/controller/provisioner/objects.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -617,8 +617,8 @@ func (p *NginxProvisioner) buildNginxPodTemplateSpec(
617617
ImagePullPolicy: pullPolicy,
618618
Ports: containerPorts,
619619
SecurityContext: &corev1.SecurityContext{
620-
AllowPrivilegeEscalation: helpers.GetPointer(false),
621620
Capabilities: &corev1.Capabilities{
621+
Add: []corev1.Capability{"NET_BIND_SERVICE"},
622622
Drop: []corev1.Capability{"ALL"},
623623
},
624624
ReadOnlyRootFilesystem: helpers.GetPointer(true),
@@ -691,12 +691,6 @@ func (p *NginxProvisioner) buildNginxPodTemplateSpec(
691691
SecurityContext: &corev1.PodSecurityContext{
692692
FSGroup: helpers.GetPointer[int64](1001),
693693
RunAsNonRoot: helpers.GetPointer(true),
694-
Sysctls: []corev1.Sysctl{
695-
{
696-
Name: "net.ipv4.ip_unprivileged_port_start",
697-
Value: "0",
698-
},
699-
},
700694
},
701695
Volumes: []corev1.Volume{
702696
{

0 commit comments

Comments
 (0)