Led by a founder with more than 21 years of experience

contact@guilda.io

Kubernetes and Containers

Container security best practices: what to fix first

The container weaknesses we find most often are ordinary mistakes, not exotic exploits. Fix them in order of risk. Take secrets out of images, take privilege away from pods and accounts, isolate workloads on the network, and scan every image automatically, then act on what the scanner finds.

Diagram: fix container weaknesses in order, secrets out of images, then privilege, then network isolation, then image scanning, and act on what scans find.
The order we follow when a team has little time; the first steps close risks that exist right now.

Container security best practices come down to a short list, applied in order of risk: keep secrets out of images, run containers without privilege, give accounts only the access they need, isolate workloads on the network, and scan every image automatically. The order matters as much as the list. A team with little time should fix what an attacker can use today before it improves what might be used later.

This is the overview of our Google Cloud and Kubernetes series. The other three articles go deeper into one control each: Workload Identity Federation for GKE, Shielded GKE Nodes and Binary Authorization.

What we find most often

The same weaknesses come up again and again in the container environments we assess. Container images are unscanned or out of date. Secrets are embedded in images or in the configuration that ships with them. Containers run with more privilege than the application needs, sometimes as root or in privileged mode. Kubernetes RBAC grants wider permissions than anyone intended. And the network between workloads is barely segmented, so every pod can reach every other pod.

None of these is a sophisticated attack. Each is a setting left at its default or a shortcut taken to get something working, and together they decide how far an attacker gets. An exposed secret hands over credentials. Excess privilege turns one compromised container into a compromised node or cluster. An open network lets the attacker move sideways from the first foothold to the systems that matter.

The order to fix them in

When a team has little time, we fix these in a set order. Exposed secrets come first, then privileged containers and excessive RBAC permissions, then network isolation, and then automated vulnerability scanning. The first steps close risks of compromise that exist right now. The later ones limit the damage of an attack and improve the supply chain over time.

1. Take secrets out of images

A secret inside an image travels with every copy of that image: to the registry, to every node that pulls it and to anyone who can read either. It cannot be rotated without rebuilding and redeploying. Move secrets to a secret manager, such as Secret Manager on Google Cloud, and give each workload access only to the secrets it uses. If Kubernetes Secrets stay in use, encrypt them at the application layer with a key you manage, as Google recommends. Then rotate every secret that was ever baked into an image, because it has to be treated as exposed.

On Google Cloud, the strongest version of this step removes the secret altogether. A workload that authenticates with Workload Identity Federation for GKE needs no service account key at all, so there is nothing to leak.

2. Take privilege away from pods and accounts

Kubernetes defines three Pod Security Standards: Privileged, Baseline and Restricted. Restricted follows current pod hardening practice. Containers must run as a non-root user, set allowPrivilegeEscalation to false, drop all Linux capabilities and use the RuntimeDefault seccomp profile, and they cannot mount host paths or share the host's network. Pod Security Admission, stable since Kubernetes 1.25, enforces a standard per namespace with a label such as pod-security.kubernetes.io/enforce: restricted.

Start each namespace in warn or audit mode to see what would fail, fix the workloads, then switch to enforce. Keep the Privileged standard for the few system workloads that really need it, in namespaces of their own.

RBAC needs the same treatment. Look for cluster-wide roles bound to service accounts that need access to one namespace, and for permissions on secrets that an application never reads. On GKE, Google also advises against enabling the older attribute-based access control (ABAC), which is off by default.

3. Isolate workloads on the network

By default, every pod in a cluster can talk to every other pod. A Kubernetes NetworkPolicy changes that, but only where a network plugin enforces it. On GKE, Dataplane V2 enforces network policies and is the default for Autopilot clusters; Standard clusters can use it or Calico. Start with a policy per namespace that denies traffic unless it is allowed, then allow the connections each application actually needs. The result is that one compromised workload can reach only the few services it talks to, not the whole cluster.

4. Scan every image, automatically

Scanning belongs in the pipeline, not in a quarterly report. On Google Cloud, once scanning is enabled, Artifact Analysis scans an image when it is pushed to Artifact Registry and keeps updating its findings as new vulnerability data arrives, as long as the image has been pulled in the last 30 days. On-demand scanning runs the same check inside your CI/CD pipeline, so a build can fail before a vulnerable image reaches the registry. Rebuild on a current base image regularly, so fixes from upstream reach your containers.

Once images are scanned, Binary Authorization can make sure only images that passed the scan and the rest of your checks are allowed to deploy.

Scanning without fixing is wasted effort

The most common wasted effort we see is running vulnerability scanners without remediation. A scanner that produces long reports gives little security value while critical findings, excessive privileges and insecure configurations stay unresolved. The report becomes a backlog nobody owns, and the volume hides the few findings that matter.

Scanning earns its cost when it is tied to a decision: a severity threshold that fails the build, an owner for each finding that is allowed through, and a date by which it is fixed. Ten findings fixed this week do more than a thousand listed in a dashboard.

The cluster underneath

Pods are only as safe as the cluster they run on. On GKE, Google's hardening guide starts with a few cluster settings worth checking on every cluster:

  • Release channels. Enrol the cluster in a release channel so the control plane and nodes receive security patches. Autopilot clusters always are.
  • Workload Identity Federation for GKE. Google calls it the recommended way for workloads to reach Google Cloud APIs. It is always on in Autopilot; on Standard, enable it for every cluster and node pool.
  • A node service account of your own. Use a dedicated, least-privilege service account for nodes instead of the Compute Engine default service account.
  • Control plane access. Google recommends using only the DNS-based endpoint, or at least closing the external IP endpoint or limiting it with authorized networks.
  • Shielded GKE Nodes and Container-Optimized OS. Shielded nodes verify each node's identity; our article on Shielded GKE Nodes explains what they protect against and what they do not.

The GKE security posture dashboard and Security Command Center then show which of these settings drift over time.

Where GUILDA can help

Our Engineering Security service hardens container images and Kubernetes clusters on GKE, Amazon EKS and Azure Kubernetes Service against the CIS Benchmarks, and adds security checks to your build and release pipeline. Data, Application & Cloud Security assesses and hardens the Google Cloud, AWS or Azure accounts the clusters run in, and Network & Systems Security covers segmentation and firewalls around them. What Engineering Security sets up is documented and handed to your team to own.

Sources

  1. Pod Security Standards, Kubernetes, 2026
  2. Pod Security Admission, Kubernetes, 2026
  3. Best practices for hardening your cluster's security, Google Cloud, 2026
  4. Control communication between Pods and Services using network policies, Google Cloud, 2026
  5. Container scanning overview, Google Cloud, 2026

Kubernetes and Containers

Binary Authorization on GKE: a rollout that does not block deployments

Binary Authorization makes GKE check every container image against a policy before it deploys, and lets only images signed by the attestors you trust run. Roll it out in dry-run mode first, sign image digests in CI after the build and the scan pass, and keep exemptions and break-glass for real emergencies.

4 min read

Kubernetes and Containers

Shielded GKE Nodes: what they protect and what they do not

Shielded GKE Nodes prove to the control plane that each node is a genuine VM of your cluster, so an attacker who steals a node's bootstrap credentials cannot impersonate it. Secure Boot and integrity monitoring add checks on how the node started. They protect the node, not the workloads running on it.

4 min read

Tell us how your software is built and shipped

Name the languages, the pipeline and where it runs. We reply within two business days.