Information
Use Binary Authorization to allowlist (whitelist) only approved container registries.
Allowing unrestricted access to external container registries provides the opportunity for malicious or unapproved containers to be deployed into the cluster. Ensuring only trusted container images are used reduces this risk.
Solution
Using Google Cloud Console
- Go to Binary Authorization by visiting: https://console.cloud.google.com/security/binary-authorization.
- Enable the Binary Authorization API (if disabled).
- Create an appropriate policy for use with the cluster. See https://cloud.google.com/binary-authorization/docs/policy-yaml-reference for guidance.
- Go to Kubernetes Engine by visiting: https://console.cloud.google.com/kubernetes/list.
- Select the cluster for which Binary Authorization is disabled.
- Under the details pane, within the Security section, click on the pencil icon named Edit Binary Authorization.
- Check the box next to Enable Binary Authorization.
- Choose Enforce policy and provide a directory for the policy to be used.
- Click SAVE CHANGES.
Using Command Line:
Update the cluster to enable Binary Authorization:
gcloud container cluster update <cluster_name> --location <location> --project <project_id> --binauthz-evaluation-mode=<evaluation_mode>
Example:
gcloud container clusters update $CLUSTER_NAME --location $LOCATION --project $PROJECT_ID --binauthz-evaluation-mode=PROJECT_SINGLETON_POLICY_ENFORCE
See: https://cloud.google.com/sdk/gcloud/reference/container/clusters/update#--binauthz-evaluation-mode for more details around the evaluation modes available.
Create a Binary Authorization Policy using the Binary Authorization Policy Reference: https://cloud.google.com/binary-authorization/docs/policy-yaml-reference for guidance.
Import the policy file into Binary Authorization:
gcloud container binauthz policy import <yaml_policy>
Impact:
All container images to be deployed to the cluster must be hosted within an approved container image registry. If public registries are not on the allowlist, a process for bringing commonly used container images into an approved private registry and keeping them up to date will be required.