How do you prevent a container from gaining privileges via setuid binaries?
IntermediateScenarioSecurity and scanning
Answer
Situation read → setuid binaries like su or ping can be abused.
What I'd do → --security-opt no-new-privileges:true and strip setuid bits in the image: RUN find / -perm /6000 -type f -exec chmod a-s {} + || true. Drop capabilities.
Why → no-new-privileges sets the kernel flag so execve cannot raise privileges.
Interview tip → In Kubernetes: allowPrivilegeEscalation: false.
More on Security and scanning
A scan reports 300 CVEs in your base image. How do you triage?IntermediateAdd vulnerability scanning to CI so critical findings block the merge.BeginnerWhy is mounting `/var/run/docker.sock` into a container dangerous?IntermediateA developer asks for `--privileged`. What do you do?IntermediateHarden a container run command for a stateless web API.IntermediateA pentester got root inside a container. How bad is it?Advanced