bcgov / cloud-pathfinder

This is the technology and UX backend repo for the cloud pathfinder ZenHub task board
https://app.zenhub.com/workspaces/cloud-pathfinder-5e4dbb426c3c6af8dcbf06a7/board?repos=241742911
Creative Commons Zero v1.0 Universal
2 stars 8 forks source link

Create a CSPM test to detect AWS registry container images that still have root enabled #1840

Closed ActionAnalytics closed 1 year ago

ActionAnalytics commented 2 years ago

Describe the issue During the openshift on-prem build process of an image, the root user is always deleted after the installation of software in the image, so that the runtime cannot ever run as root since the root user is gone. There are Openshift tests to scan for and prevent images with root from slipping by. We wish to guarantee the same for ECS image registry images.

Additional context

Definition of done

bruce-wh-li commented 2 years ago

May need Onboarding Container Registries but this feature is only available as Early Available. Please see the following abridged from Cloudguard Admin Guide. Quote "Container Registry is available to customers through the Check Point Early Availability Program. If you want to participate and test the feature, contact the EAP team at ea_support@checkpoint.com. " Unquote

bruce-wh-li commented 2 years ago

Also checked and found checkov by bridgecrew has the capability to scan docker file to ensure the last USER is not root. As mentioned in our daily scrum standup, checkov is the path we're goring forward.

ActionAnalytics commented 2 years ago

We are working with CP support but not getting results yet. We may be able try to build a github bot that looks at the dockerfile user (we will make tickets). Currently waiting on CP

ActionAnalytics commented 2 years ago

We think this might not be a feature that is ready to use in CSPM yet, we're going to leave the ticket open until we know for sure. If the answer is no, please close the ticket

bruce-wh-li commented 2 years ago

Prabhu had shared the container registry in LZ2. The account, workload can be found in CSPM but not image. It could be CSPM onboarding permission issue or checkpoint. Currently, pending on onboarding permission to be fixed before try again.

bruce-wh-li commented 2 years ago

Checkpoint TAC SR #6-0003369490 responded it could be related to role, external id, or SCP, guardrail. Warren is helping to see if AWS SEA related.

bruce-wh-li commented 2 years ago

PO to give Prabhu CSPM permission and same level of access to see if the 'unauthorized operation' error stemming from the lack of authority. If not, due to extreme difficult and dependency on checkpoint support. Owning to the difficulty aforementioned and other alternatives available, we will close the ticket as a result if retry failed.

bruce-wh-li commented 2 years ago

Had the screenshare session with checkpoint TAC support. The 'unauthorized operation' error is appeared related to SCP ro CSP Policy. In addition, we have to onboard Container Environment as it is not part of unified onboarding and have to do it separately. However, Terraform API does not have the related serverless API to onboard. But, could do it through standalone AWS API call !? Also, the CloudGuard CSPM does not have AWS container in the UI. Hence, can't do it through UI. If CheckPoint TAC support can't replicate the problem, I will create another ticket and reach out to Chris B. for it.

bruce-wh-li commented 2 years ago

AWS Dashboard System Ruleset (D9.AWS.IAM.49 to be exact) covers the checking of running ECS Service as 'Admin'.

bruce-wh-li commented 2 years ago
  1. Kubernetes Cluster is needed to onboard ECR Registry to install the CloudGuard Agent as per current UI
  2. CheckPoint is currently working to change for ECS Scanning.
  3. ECR Image Scanning is available in Shift Left/Spectral. CheckPoint to Update the status next week (of Sept 18 2022)
ActionAnalytics commented 1 year ago

Checkov can already cover root configuration checks in the Docker file IaC, so this mitigates a lot of the risk.

We are holding off on the ShipLeft, no certainty of runtime protection. Bruce thinks ACS (RedHat Advanced Cluster Security) is capable of doing it for ROSA so we would imagine it's possible via Check Point.

Also possible to assign Carles to see if he design a custom test for probing container user status in all ECS instances.

ActionAnalytics commented 1 year ago

Good try, thank you!