Lesson 2 of 5 Securing Container Workloads

Detecting Risks with Defender for Containers

This lesson explains how each Defender for Containers capability is delivered, and what it needs.

Learning outcomes

After completing this lesson, you will be able to:

  • Distinguish agentless from sensor-based capabilities.
  • Describe vulnerability assessment.
  • Explain gated deployment.
  • Explain binary drift.

Five areas of protection

Defender for Containers is a workload protection plan for Kubernetes clusters and container images. Microsoft arranges it into five domains: security posture management, vulnerability assessment, run-time threat protection, software supply chain protection, and deployment and monitoring. It covers AKS, and through connectors or Azure Arc it also covers Amazon EKS, Google GKE and Arc-enabled Kubernetes clusters.

A helpful way of understanding it is to divide its capabilities by how they gather data: some work without anything on the cluster, and others need a component on the nodes.

Agentless and sensor-based capabilities

The following table shows what each approach provides.

ApproachCapabilityWhat it does
AgentlessAgentless discovery for KubernetesFinds clusters, and maps their configuration
AgentlessAgentless vulnerability assessmentScans registry images, running containers and cluster nodes, with daily re-scans
AgentlessControl plane hardeningGives recommendations on cluster configuration
Sensor-basedBinary drift detection and blockingAlerts on or blocks processes that did not come from the image
Sensor-basedAntimalwareFinds malware in running containers
Sensor-basedDNS detectionDetects suspicious DNS activity
Add-onKubernetes data plane hardeningUses Azure Policy for Kubernetes to check workloads against rules

Runtime alerts depend on the Defender sensor and on Kubernetes audit logs. On AKS, the service reads control plane audit logs through an Azure-managed integration, so cluster audit logging does not need configuring, and no inbound connectivity is needed. Alerts cover actions that occur after the plan is enabled, so past activity cannot be analysed. EKS and GKE deployments use lightweight sensors, or Azure Arc extensions.

Sort into groups

Agentless or sensor?

Exam skills 3.3.1

Decide whether each Defender for Containers capability is agentless or needs the sensor.

Log in to try this activity Interactive activities are free with an account.

Vulnerability assessment

Vulnerability assessment uses Defender Vulnerability Management, and it works without a scanner in the pipeline. It scans images in Azure Container Registry, and in external registries such as Docker Hub and JFrog Artifactory with Defender CSPM, along with containers that are running. It re-scans daily, because a new vulnerability can be disclosed in an image that has not changed.

Findings appear as recommendations, such as one to resolve vulnerabilities in container images. A finding on an image in a registry is less urgent than the same finding on a running, internet-exposed container, so the context matters. Running container scans in multicloud environments are in preview.

Gated deployment

Finding a vulnerability is useful, but it is better to prevent it from running. Gated deployment, under software supply chain protection, uses rules that audit or block a deployment when an image does not meet the organization's vulnerability policy. Suppose that a rule blocks images with critical vulnerabilities. When a developer deploys such an image to a protected cluster, the deployment is denied, with a reason. It is best to begin in audit mode, so that teams can see the effect before a block is applied.

The following diagram shows a deployment checked against the vulnerability rule.

Gated deployment in Defender for Containers. A rule checks each image against the organization's vulnerability policy when it is deployed to a protected cluster. In audit mode the deployment proceeds and the violation is recorded; in deny mode an image with, for example, critical vulnerabilities is rejected with a reason. Scanning only shows the problem; gated deployment acts on it.
Gated deployment prevents; scanning only detects.

Detect versus prevent

Scanning shows the problem, and gated deployment acts on it. If a scenario asks to stop vulnerable images from being deployed, look for gated deployment or an admission control, not for scanning alone.

Scenario questions

Preventing and detecting

Exam skills 3.3.1

Choose the Defender for Containers capability for each requirement.

Log in to try this activity Interactive activities are free with an account.

Binary drift

A container image should be immutable. If a running container starts a binary that was not in the original image, then something has changed it, which might be an attacker who has downloaded a tool. This is binary drift. Binary drift detection raises an alert, and binary drift blocking stops the process, both through a drift policy. Teams can set exclusions for legitimate cases, such as a tool that updates files. Blocking should follow a period of detection.

Enabling the plan

Turn the plan on in Environment settings, and open its settings to confirm which components are enabled. Check that Agentless discovery for Kubernetes, the Defender sensor and Azure Policy for Kubernetes are on, because each one supplies different results. Sensor images are published to the Microsoft Container Registry at mcr.microsoft.com/azuredefender/stable/..., so a cluster that restricts outbound traffic must allow that path. With Helm-based installs, updates can take up to 30 days to arrive.

Worked example

Identifying the missing component

An AKS cluster shows image vulnerability findings and posture recommendations in Defender for Cloud, but a test that starts an unexpected process in a container produces no alert. What is the likely cause?

Vulnerability findings and posture recommendations are agentless, so they work without anything on the nodes. Detecting a process needs the Defender sensor, so it is probably not deployed, or the drift policy is not set up. Enable the sensor in the plan's settings, and confirm a policy that alerts on drift.

Azure Policy for Kubernetes checks how workloads are configured when they are admitted, and it does not watch processes at run time. Re-scanning images would not detect a process.

Check yourself

Can Defender for Containers report on actions that occurred before it was enabled?

Show answer

No. Runtime alerts cover only activity after the plan is enabled.

Exam Tips

Remember for the exam

  • Vulnerability assessment and discovery are agentless; runtime detection needs the sensor.
  • Gated deployment blocks; scanning only reports.
  • Runtime alerts cover only actions after enablement.
  • Binary drift is a process that was not in the original image.