-
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
NIC should be able to run with the "restricted" POD security level #3544
Comments
Please leave default HTTP/S ports as defaults. Most users of the Ingress Controller will want ports 80 and 443 used. This would particularly impact those who expose NIC to the Internet, as port change would result in users having to type Docker v20.10.0 (released 2020-12-08) can be seen as supporting binding privileged ports with no capabilities, as it automatically sets Similarly, K8s docs state that The safe sysctl set, based on documentation, should be namespaced and not interfere with other Pods or the node. This to me implies that with Kubernetes, even if host network is used, the I have not yet experimented with this.. but a general solution, setting the
This would however leave containers running in host network in a peculiar situation. The mentioned Docker runtime change avoids setting the Such scenario sounds like an issue for people who run Docker natively on host and want to use Nginx Ingress Controller. Is this a supported use-case? |
@hafe, is there any aspect in which NIC does not comply with Restricted security level, other than |
I guess not. It is hard to tell when you can't test. Cap net bind seems to be allowed - https://kubernetes.io/docs/concepts/security/pod-security-standards/#restricted |
So what is the reason allowPrivilegeEscalation is set to start with? |
Allowing Privilege Escalation is done to support NET_BIND_SERVICE in Nginx process when Entrypoint (Ingress Controller) doesn't have it as Permitted/Effective. (Previous discussion: #1677 (comment)) |
Yes that makes sense from my testing. When I changed to high ports I could remove allowPrivilegeEscalation |
Alternative approach could be that we set |
Sounds like a good approach! |
As part of the linked PR, it was identified that the underlying process does not drop NET_BIND_SERVICE once that capability is effective. Therefore, on existing approach even if privilege escalation is restricted, code execution could in an attack chain result in binding the low ports. Instead, 8be0144 applies the sysctl change to remove privilege requirement (and in effect remove the Escalation use case). For the scope of Kubernetes policy, this complies (as it's a safe sysctl that individual pods can obtain since K8s v1.22). In future, someone may want to pick up the task to re-implement the Capability, and add proper bind+drop. You should be able to experiment on the |
This must also be set in the security context to comply: seccompProfile:
type: RuntimeDefault
|
I like this! I write something like a requirement and others implement 😁 |
@blurpy, would you mind opening a Pull Request for this with you as author? |
I would have liked to, but I can't prioritize it right now. I would be happy if anyone else has the time to fix it in the mean time. |
Opened #3629 on your behalf. |
@sigv thank you for the PR. We going to review it on our side. If we need anything or have any questions, will update your PR thread. |
@blurpy, the edge version (latest |
Excellent, thank you! I will have to get back to you on that. |
I finally got some time to play with latest main. Nice work with all security improvements lately! What I found out is that running with UID 101 is now what is stopping using the restricted policy |
@hafe, where are you seeing UID 101 being an issue? Is there some reference document/source you could link to?
|
OKD/Openshift gives each namespace a UID range and allocates a random UID from that to a pod. If you need a fixed UID you need to use the anyuid policy or a custom one. But I need to play more with this |
Understood, it's about OpenShift's This needs a further investigation. I have not worked hands on with OpenShift so I am not 100% familiar with their approach. @hafe, if you instead apply the |
I will do some more checks but otherwise I think this particular issue could be rephrased and closed |
I am taking a closer look and @hafe, could you check |
@sigv Initial testing looks good! We have the controller running with the restricted profile now. |
@blurpy, just to double check, as there are competing request scopes: Kubernetes restricted with latest release, or OpenShift modifying 'run as user'? |
@sigv using the restricted pod security standard: https://kubernetes.io/docs/concepts/security/pod-security-standards/#restricted The namespace is configured as follows:
Still at the poc stage though, so perhaps we discover something more later. |
I originally thought about changing the templates so high (>1024) ports optionally could be configured. This could then be used with normal (non-host) networking and removing the need for privileged mode. I never got around to test. Is this a feasible path? |
@hafe, are you on OpenShift 4.11+? Or are you running on the 4.10 Maintenance Support? I am asking as I want to hear if you have the |
I can/will test with OpenShift 4.11/12 but just haven't got time for that yet |
@sigv I cannot get it to work with restricted and OpenShift 4.12. The reason seems to be the runAsUser directive. With runAsUser it is stopped by the admission controller. Without runAsUser it can't start, the USER directive in the image does seems to take effect. |
When running Another discussion about log files is pending. After these concerns are resolved, it should be possible to remove the hard-coded UID and switch to @hafe, will let you know when the relevant changes are in |
Sounds promising! However nginx with app-protect is also pending to be solved |
Is this still relative? Should this have been closed? |
I think binding to low ports like 80 & 443 is a problem with the restricted SCC. |
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 10 days. |
Closing as there has been no activity, please feel free to open a new issue if this is still relevant. |
WIP
Summary
NIC is currently (3.x) required to run as a privileged POD with added capabilities. This is not ideal from a security perspective and not aligned with best practice container security guidelines and standards such as:
To improve the security posture, NIC should be able to run with the restricted POD security level. See Pod Security Standards for more information.
Motivation
NIC is usually exposed to the Internet and thus a target for all kinds of attacks. The project should always strive to improve the security of NIC.
Goals
Non-goals
readOnlyRootFilesystem: true
#1677 )Proposal
TBD
The text was updated successfully, but these errors were encountered: