kube-bench icon indicating copy to clipboard operation
kube-bench copied to clipboard

Docker image build with a non-root user account

Open sosadtsia opened this issue 3 years ago • 4 comments

Overview

Our container scanning tool trigger HIGH severity compliance alert after security scan with of the image aquasec/kube-bench:latest.

How did you run kube-bench?

N/A

What happened?

Description of the alert: '(CIS_Docker_v1.2.0 - 4.1) Image should be created with a non-root user. It is a good practice to run the container as a non-root user, if possible.'

What did you expect to happen:

Security scan completion without alerts.

Environment kind v0.11.0 go1.16.4 linux/amd64

[What is your version of kube-bench? (run kube-bench version)] v0.6.3

[What is your version of Kubernetes? (run kubectl version or oc version on OpenShift.)] Client Version: "v1.19.11" Server Version: "v1.21.1"

Running processes N/A

Configuration files N/A

Anything else you would like to add: We are willing to open a pull request to fix this issue. We are suggesting to update Dockerfile with the following:

RUN adduser -S -s /bin/sh -G root -u 1001 kube-bench
USER kube-bench

sosadtsia avatar Jul 20 '21 18:07 sosadtsia

I think we had this issue before and we need to run this as root because else some test couldn't be checked. The quickest way to test it will be to just run it with root and without and compare results. Could you do it @sosadtsia ? ( If not I will get to it in a few days )

yoavrotems avatar Jul 25 '21 13:07 yoavrotems

Hi @yoavrotems . I've tested a build of two images with and without root user. After comparing the output results of the kube-bench tests for both scenarios and I wasn't able find any discrepancies. You can find the output for both tests here

sosadtsia avatar Jul 27 '21 18:07 sosadtsia

Hey @sosadtsia Thanks for running and comparing it, in the link you attached I could only see one case results, could you please add the second one?

yoavrotems avatar Aug 02 '21 08:08 yoavrotems

Hey @yoavrotems . You can find the second one here

sosadtsia avatar Aug 02 '21 13:08 sosadtsia