Skip to main content

Overview

This lab deploys a complete AKS runtime security stack using Microsoft Defender for Cloud:

  1. Gated Deployment (GA) โ€” Admission control blocks vulnerable container images
  2. Binary Drift Detection (GA detect / Preview block) โ€” Catches executables not in the original image
  3. Container Anti-Malware (Preview) โ€” Real-time malware detection and blocking inside containers
  4. Sentinel Analytics Rules โ€” 4 detection rules for SOC monitoring
  5. Sentinel Workbook โ€” Container Runtime Security Dashboard

Prerequisites

  • Azure subscription with Owner or Contributor + User Access Administrator
  • Azure CLI v2.60+
  • kubectl v1.28+
  • Helm v3.12+
  • PowerShell 7

Quick Start

git clone https://github.com/j-dahl7/aks-runtime-security-lab.git
cd aks-runtime-security-lab
# Deploy everything
./scripts/Deploy-Lab.ps1 -Location "eastus"

# Run test scenarios
./scripts/Test-RuntimeSecurity.ps1

What Gets Deployed

ResourceTypePurpose
aks-runtime-labAKS ClusterSingle-node cluster with Defender sensor
aks-runtime-lab-lawLog AnalyticsContainer Insights + Sentinel
Defender for ContainersSecurity PlanSubscription-level enablement
4 Analytics RulesSentinelBinary drift, malware, gated deployment, kubectl exec
1 WorkbookSentinelContainer Runtime Security Dashboard

Test Scenarios

Test 1: Binary Drift

kubectl run drift-test --image=nginx:1.27-alpine --restart=Never
kubectl exec drift-test -- /bin/sh -c \
  "echo '#!/bin/sh' > /tmp/notinimage.sh && chmod +x /tmp/notinimage.sh && /tmp/notinimage.sh"

Expected: “Binary drift detected” alert in Defender for Cloud (5-15 min)

Test 2: Anti-Malware (EICAR)

kubectl run malware-test --image=nginx:1.27-alpine --restart=Never
kubectl exec malware-test -- /bin/sh -c \
  "echo 'WDVPIVAlQEFQWzRcUFpYNTQoUF4pN0NDKTd9JEVJQ0FSLVNUQU5EQVJELUFOVElWSVJVUy1URVNULUZJTEUhJEgrSCo=' | base64 -d > /tmp/eicar.com"

Expected: “Malicious file detected” alert (5-15 min)

Test 3: Gated Deployment

kubectl run vuln-test --image=nginx:1.14.0 --restart=Never

Expected: Deployment blocked (Deny mode) or audit recommendation (Audit mode)

Estimated Cost

ResourceApprox. Monthly Cost
AKS (1x Standard_D4s_v3)~$140
Defender for Containers~$7/vCore/month
Log Analytics (30-day retention)~$2.76/GB

Total: ~$150-170/month for a single-node lab cluster.

Cleanup

./scripts/Deploy-Lab.ps1 -Destroy

Or manually:

az group delete --name aks-runtime-lab-rg --yes --no-wait

Companion Blog Post

AKS Runtime Security: Binary Drift, Anti-Malware & Gated Deployment with Defender for Cloud

Repository

github.com/j-dahl7/aks-runtime-security-lab

Keyboard Shortcuts

Navigation
Ctrl + K Open search / command palette
? Show this help
ESC Close dialogs
Actions
G then H Go to Home
G then B Go to Blog
G then A Go to About
G then C Go to Contact
G then T Go to Threat Feeds
G then G Go to Glossary
Shift + C Copy page URL
Easter Eggs
โ†‘โ†‘โ†“โ†“โ†โ†’โ†โ†’BA Konami code
Click cat 9ร— Nine lives activation
Click logo 9ร— Cat Burglar mode