Skip to content
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

Missing checks for CKV_DOCKER_3 (User exists) #2218

Closed
adberger opened this issue Jan 17, 2022 · 15 comments
Closed

Missing checks for CKV_DOCKER_3 (User exists) #2218

adberger opened this issue Jan 17, 2022 · 15 comments
Labels
checks Check additions or changes docker Dockerfile good first issue Good for newcomers stale

Comments

@adberger
Copy link
Contributor

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 adberger added the checks Check additions or changes label Jan 17, 2022
@nimrodkor
Copy link
Contributor

nimrodkor commented Jan 17, 2022

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" ]

@adberger
Copy link
Contributor Author

@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)

@nimrodkor
Copy link
Contributor

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

@adberger
Copy link
Contributor Author

@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.

@gruebel gruebel added the docker Dockerfile label Jan 17, 2022
@nimrodkor
Copy link
Contributor

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

@schosterbarak schosterbarak added the good first issue Good for newcomers label Jan 17, 2022
@adberger
Copy link
Contributor Author

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

@stale
Copy link

stale bot commented Jul 27, 2022

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 stale bot added the stale label Jul 27, 2022
@stale stale bot removed the stale label Aug 5, 2022
@tspearconquest
Copy link

My mistake, please close it.

@stale
Copy link

stale bot commented Feb 1, 2023

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 stale bot added the stale label Feb 1, 2023
@tspearconquest
Copy link

Not stale

@stale stale bot removed the stale label Feb 1, 2023
@stale
Copy link

stale bot commented Aug 2, 2023

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 stale bot added the stale label Aug 2, 2023
@tspearconquest
Copy link

Not stale

@stale stale bot removed the stale label Aug 2, 2023
@ArjunMenon-bit
Copy link
Contributor

Not stale.
Issue fixed in #2294

Copy link

stale bot commented Apr 11, 2024

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 stale bot added the stale label Apr 11, 2024
Copy link

stale bot commented Apr 29, 2024

Closing issue due to inactivity. If you feel this is in error, please re-open, or reach out to the community via slack: codifiedsecurity.slack.com Thanks!

@stale stale bot closed this as completed Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
checks Check additions or changes docker Dockerfile good first issue Good for newcomers stale
Projects
None yet
Development

No branches or pull requests

6 participants