A pod needs to bind to port 80 and the team added `NET_ADMIN` and `SYS_ADMIN` capabilities. What do you suggest?
BeginnerScenarioKubernetes Security
Answer
Situation read → Binding to a low port needs at most NET_BIND_SERVICE. SYS_ADMIN is close to full root.
What I'd do →
- Change the app to listen on 8080 and map port 80 in the Service.
- If it truly must bind 80, use only
NET_BIND_SERVICE:
securityContext:
runAsNonRoot: true
allowPrivilegeEscalation: false
capabilities: { drop: ["ALL"], add: ["NET_BIND_SERVICE"] }
- Block
SYS_ADMINandNET_ADMINthrough PSArestrictedor a policy.
Why → Services already remap ports; capabilities should never be the workaround.
Interview tip → "Drop ALL, add back only what you need" is the line to say.
More on Kubernetes Security
What are the 4Cs of cloud native security?BeginnerWhat happens to a request between `kubectl apply` and etcd from a security point of view?IntermediateExplain Role, ClusterRole, RoleBinding and ClusterRoleBinding.BeginnerHow do you check what a user or service account is allowed to do?BeginnerWhich RBAC permissions are effectively cluster-admin in disguise?AdvancedHow do service account tokens work now, and what is `automountServiceAccountToken`?Intermediate