-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Inherit NET_BIND_SERVICE from IC to Nginx #3722
Conversation
IMO this is a better solution anyway because the Kubernetes Pod Security Standards allows for adding the I think this means NIC will be fully compatible with the restricted policy after this, if I'm not missing anything. |
From what I see, Keep in mind that Restricted policy inherits Baseline policy. But yes - this is generally a cleaner approach. |
Oh, I see - that wasn't clear to me. Thanks. |
The first line of Controls states Everything from the baseline profile. As to why this solution is objectively cleaner, it allows dropping the capability in turn locking down ports 80/443. |
184f937
to
aa3f2ab
Compare
Locally tested it comes online for sudo snap install microk8s --classic
microk8s status --wait-ready sudo microk8s reset
microk8s enable dashboard dns registry istio
make debian-image PREFIX=myregistry.example.com/nginx-ingress TARGET=container
docker save myregistry.example.com/nginx-ingress:3.0.0-SNAPSHOT-aa3f2ab > nic.tar
microk8s ctr images import nic.tar
rm nic.tar
microk8s helm install --create-namespace --namespace nginx-ingress nginx-ingress deployments/helm-chart \
--set controller.image.repository=myregistry.example.com/nginx-ingress \
--set controller.image.tag=3.0.0-SNAPSHOT-aa3f2ab \
--set controller.image.pullPolicy=Never \
--set controller.hostNetwork=true
microk8s kubectl get pods -n nginx-ingress
# NAME READY STATUS RESTARTS AGE
# nginx-ingress-controller-7f756c56c5-jzmww 1/1 Running 0 10s
microk8s helm uninstall --namespace nginx-ingress nginx-ingress
microk8s ctr images rm myregistry.example.com/nginx-ingress:3.0.0-SNAPSHOT-aa3f2ab The For |
aa3f2ab
to
1db6c6f
Compare
It seems the edge image is flaky on |
1db6c6f
to
2cbfdf0
Compare
I did a rebase, and it looks fine, but Github reports that this PR consists of three commits now. I think that's a Github web UI bug, but let me know if I should try rebasing again. |
Codecov Report
@@ Coverage Diff @@
## main #3722 +/- ##
=======================================
Coverage 52.41% 52.41%
=======================================
Files 59 59
Lines 16902 16902
=======================================
Hits 8859 8859
Misses 7748 7748
Partials 295 295 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Heads up - the CI failed on
|
3419fde
to
6c16513
Compare
4b952a3
to
a8bd2d3
Compare
b65e804
to
f27c32a
Compare
99e8aba
to
3c5a700
Compare
f0d1e0f
to
355a46e
Compare
0aacbfd
to
9e2f0a1
Compare
@vepatel, heads up, the Plus repository seems to be unavailable on the CI run! |
4f4cda9
to
ede9268
Compare
ede9268
to
c5882fa
Compare
81edd48
to
cf92c83
Compare
8be0144: Rework port binding logic without privileges caused issues for host networking configurations. The Kubernetes documentation states that the `net.*` sysctls can be used with container networking, which was misinterpreted. This commit reverts the change, bringing back NET_BIND_SERVICE to the Nginx process, as well as reverts the libcap package removal done in a later commit. In order to avoid privilege escalation being re-introduced, the IC process is also receiving NET_BIND_SERVICE, so that it can be inherited over to Nginx. This change aims to restore host networking as functional for the Helm chart. A future change is recommended to harden security for the IC process (to drop the capability after executing Nginx) as well as Nginx itself (to drop the capability after binding). OBS! To use a 3.1.0 image, you should manually install the `setcap` binary and add `+ep` on `/nginx-ingress` and `+eip` on `nginx` binary. Co-authored-by: Luca Comellini <[email protected]>
cf92c83
to
6f1600b
Compare
Still hitting issues in CI for accessing the Nginx Plus repository. 😕
All of these jobs report warnings for
While most Debian runs have a generic "could not get a Release file" error..
|
@ciarams87 ping ☝🏻 |
@sigv Running the pipeline again now. Sorry for the inconvenience! (As an explanation, PRs from external contributors cannot access the build secrets. If there are no changes to the base NGINX Plus images, this normally does not cause a problem as we can use cached layers from other builds, but when changes are made which require rebuilding the whole image, as here, a maintainer needs to open a separate branch which does have secret-read access) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @sigv !
8be0144: Rework port binding logic without privileges caused issues for host networking configurations. The Kubernetes documentation states that the `net.*` sysctls can be used with container networking, which was misinterpreted. This commit reverts the change, bringing back NET_BIND_SERVICE to the Nginx process, as well as reverts the libcap package removal done in a later commit. In order to avoid privilege escalation being re-introduced, the IC process is also receiving NET_BIND_SERVICE, so that it can be inherited over to Nginx. This change aims to restore host networking as functional for the Helm chart. A future change is recommended to harden security for the IC process (to drop the capability after executing Nginx) as well as Nginx itself (to drop the capability after binding). OBS! To use a 3.1.0 image, you should manually install the `setcap` binary and add `+ep` on `/nginx-ingress` and `+eip` on `nginx` binary. (cherry picked from commit 5d56f71)
8be0144: Rework port binding logic without privileges caused issues for host networking configurations. The Kubernetes documentation states that the `net.*` sysctls can be used with container networking, which was misinterpreted. This commit reverts the change, bringing back NET_BIND_SERVICE to the Nginx process, as well as reverts the libcap package removal done in a later commit. In order to avoid privilege escalation being re-introduced, the IC process is also receiving NET_BIND_SERVICE, so that it can be inherited over to Nginx. This change aims to restore host networking as functional for the Helm chart. A future change is recommended to harden security for the IC process (to drop the capability after executing Nginx) as well as Nginx itself (to drop the capability after binding). OBS! To use a 3.1.0 image, you should manually install the `setcap` binary and add `+ep` on `/nginx-ingress` and `+eip` on `nginx` binary. (cherry picked from commit 5d56f71) Co-authored-by: Valters Jansons <[email protected]>
@sigv I am confused after reading all the comments. Just want to confirm that can nginxinc/kubernetes-ingress avoid the privilege escalation of NET_BIND_SERVICE or not? |
Proposed changes
8be0144: Rework port binding logic without privileges caused issues for host networking configurations. The Kubernetes documentation states that the
net.*
sysctls can be used with container networking, which was misinterpreted.This commit reverts the change, bringing back NET_BIND_SERVICE to the Nginx process, as well as reverts the libcap package removal done in a later commit.
In order to avoid privilege escalation being re-introduced, the IC process is also receiving NET_BIND_SERVICE, so that it can be inherited over to Nginx.
This change aims to restore host networking as functional for the Helm chart. A future change is recommended to harden security for the IC process (to drop the capability after executing Nginx) as well as Nginx itself (to drop the capability after binding).
OBS! To use a 3.1.0 image, you should manually install the
setcap
binary and add+ep
on/nginx-ingress
and+eip
onnginx
binary.Resolves #3714.
Effectively reverts #3573 and #3616.
Checklist
Before creating a PR, run through this checklist and mark each as complete.