checkov icon indicating copy to clipboard operation
checkov copied to clipboard

Missing checks for CKV_DOCKER_3 (User exists)

Open adberger opened this issue 3 years ago • 8 comments

Describe the issue https://github.com/bridgecrewio/checkov/blob/master/checkov/dockerfile/checks/UserExists.py doesn't cover all of https://docs.bridgecrew.io/docs/ensure-that-a-user-for-the-container-has-been-created

Bridgecrew Policy ID: BC_DKR_3 Checkov Check ID: CKV_DOCKER_3

ToDo: Additionally check if gosu is executed in either CMD or ENTRYPOINT

Examples

FROM alpine:3.14
ENTRYPOINT ["gosu", "app", "tini", "--", "/app/run.sh" ]

should be passing but isn't:

Check: CKV_DOCKER_3: "Ensure that a user for the container has been created"
	FAILED for resource: /Dockerfile.
	File: /Dockerfile:1-50
	Guide: https://docs.bridgecrew.io/docs/ensure-that-a-user-for-the-container-has-been-created

Version (please complete the following information):

  • Checkov Version 2.0.692

adberger avatar Jan 17 '22 08:01 adberger

Hey @adberger !

This is an interesting one. How would checkov know if the first keyword (i.e. gosu) is the name of the command or a user?

Perhaps this should fail:

FROM alpine:3.14
ENTRYPOINT ["gosu", "app", "tini", "--", "/app/run.sh" ]

But this should pass:

FROM alpine:3.14
USER gosu
ENTRYPOINT ["gosu", "app", "tini", "--", "/app/run.sh" ]

nimrodkor avatar Jan 17 '22 08:01 nimrodkor

@nimrodkor I would rather check if gosu is in CMD or ENTRYPOINT, despite the location (first, middle, last etc.).

USER gosu would not be correct, because gosu is the command and app the user which gets created by gosu (AFAIK)

adberger avatar Jan 17 '22 08:01 adberger

@adberger Right. However, how would you know gosu is a user and not the app / executable / command?

nimrodkor avatar Jan 17 '22 09:01 nimrodkor

@adberger Right. However, how would you know gosu is a user and not the app / executable / command?

You could parse it according to the gosu usage: Usage: ./gosu user-spec command [args]

If gosu and then a user-spec is set, the test should be valid.

adberger avatar Jan 17 '22 09:01 adberger

I think I got it now. Want to fix the check and open a PR? We'd love the contribution @adberger !

nimrodkor avatar Jan 17 '22 11:01 nimrodkor

@nimrodkor I prepared some changes in my forked repository, which is currently under review by my colleagues: https://github.com/adberger/checkov

adberger avatar Jan 25 '22 15:01 adberger

Thanks for contributing to Checkov! We've automatically marked this issue as stale to keep our issues list tidy, because it has not had any activity for 6 months. It will be closed in 14 days if no further activity occurs. Commenting on this issue will remove the stale tag. If you want to talk through the issue or help us understand the priority and context, feel free to add a comment or join us in the Checkov slack channel at https://slack.bridgecrew.io Thanks!

stale[bot] avatar Jul 27 '22 00:07 stale[bot]

My mistake, please close it.

tspearconquest avatar Aug 05 '22 04:08 tspearconquest

Thanks for contributing to Checkov! We've automatically marked this issue as stale to keep our issues list tidy, because it has not had any activity for 6 months. It will be closed in 14 days if no further activity occurs. Commenting on this issue will remove the stale tag. If you want to talk through the issue or help us understand the priority and context, feel free to add a comment or join us in the Checkov slack channel at https://slack.bridgecrew.io Thanks!

stale[bot] avatar Feb 01 '23 07:02 stale[bot]

Not stale

tspearconquest avatar Feb 01 '23 14:02 tspearconquest

Thanks for contributing to Checkov! We've automatically marked this issue as stale to keep our issues list tidy, because it has not had any activity for 6 months. It will be closed in 14 days if no further activity occurs. Commenting on this issue will remove the stale tag. If you want to talk through the issue or help us understand the priority and context, feel free to add a comment or join us in the Checkov slack channel at https://slack.bridgecrew.io Thanks!

stale[bot] avatar Aug 02 '23 20:08 stale[bot]

Not stale

tspearconquest avatar Aug 02 '23 21:08 tspearconquest

Not stale. Issue fixed in #2294

ArjunMenon-bit avatar Sep 23 '23 12:09 ArjunMenon-bit

Thanks for contributing to Checkov! We've automatically marked this issue as stale to keep our issues list tidy, because it has not had any activity for 6 months. It will be closed in 14 days if no further activity occurs. Commenting on this issue will remove the stale tag. If you want to talk through the issue or help us understand the priority and context, feel free to add a comment or join us in the Checkov slack channel at codifiedsecurity.slack.com Thanks!

stale[bot] avatar Apr 11 '24 09:04 stale[bot]