CCSP · Domain 3 · 17%

Bảo mật nền tảng & Hạ tầng đám mây

Cloud Platform & Infrastructure Security

Bảo vệ lớp hạ tầng đám mây: virtualization security, container/Kubernetes hardening, serverless attack surface, VPC/VNET design, IaC security scanning, workload identity, và CIS Cloud Benchmarks — nền tảng kỹ thuật của CCSP Domain 3.

Mục tiêu chương / Learning objectives

1. Lý thuyết cốt lõi / Core theory

1.1. Virtualization Security — Hypervisor & VM Isolation (Virtualization security)

Nền tảng của cloud là virtualization. Hypervisor (Virtual Machine Monitor) là phần mềm quản lý VMs trên physical host. Hai loại:

VM Isolation & Security risks:

1.2. Container Security — Docker & Kubernetes Hardening (Container security)

Docker hardening best practices:

Kubernetes security controls:

1.3. Serverless Security — Lambda & Functions Attack Surface (Serverless security)

Serverless (FaaS) loại bỏ OS management nhưng tạo ra attack surface mới:

1.4. Cloud Network Security — VPC/VNET, WAF, PrivateLink (Cloud network security)

1.5. IaC Security & Cloud Identity Hardening (IaC security & identity)

Infrastructure as Code (IaC) Security:

Cloud Identity Security:

2. Bài thực hành / Hands-on lab

🖥️ Nền tảng / Platform: Windows 11 + Ubuntu 22.04 LTS
🛠️ Công cụ / Tools: PowerShell + Az module + kubectl · Docker + Trivy + kube-bench

Lab 1 — Audit Azure NSG & AKS Security với PowerShell + kubectl

OS: Windows 11 · Tool: PowerShell + Az module + kubectl.

# Liệt kê tất cả NSGs và resource groups
Get-AzNetworkSecurityGroup | Select-Object Name, ResourceGroupName, Location | Format-Table

# Xem NSG rules bằng Azure CLI (dễ filter hơn)
az network nsg list -o table

# Tìm NSG rules cho phép Inbound từ Internet (CidrIp 0.0.0.0/0)
az network nsg rule list --nsg-name myNSG -g myRG `
  --query "[?access=='Allow' && direction=='Inbound' && sourceAddressPrefix=='*']" `
  -o table

# Kết nối AKS cluster
az aks get-credentials --resource-group myRG --name myAKS --overwrite-existing

# Kiểm tra tất cả pods trong tất cả namespaces
kubectl get pods -A -o wide

# Audit RBAC - xem tất cả ClusterRoleBindings với cluster-admin
kubectl get clusterrolebindings -o json | `
  python3 -c "import json,sys; [print(b['metadata']['name'], '->', b.get('subjects','[]')) for b in json.load(sys.stdin)['items'] if b.get('roleRef',{}).get('name')=='cluster-admin']"

# Kiểm tra permissions của current service account
kubectl auth can-i --list --namespace default

✅ Kết quả mong đợi / Expected output: NSG list hiển thị tên, RG, location. NSG inbound rules với source * = overly permissive (finding). AKS pods list với namespace/node placement. ClusterRoleBindings với cluster-admin = audit carefully. kubectl auth can-i --list hiển thị permissions của current context — nên thấy limited set, không phải wildcard *.

Lab 2 — Container Security Audit với Docker inspect, Trivy & kube-bench

OS: Ubuntu 22.04 · Tool: Docker + Trivy + kube-bench.

# Cài đặt Trivy (image vulnerability scanner)
# curl -sfL https://raw.githubusercontent.com/aquasecurity/trivy/main/contrib/install.sh | sh -s -- -b /usr/local/bin

# Kiểm tra cấu hình security của container đang chạy
docker inspect mycontainer 2>/dev/null | python3 -c "
import json, sys
try:
    c = json.load(sys.stdin)[0]
    hc = c['HostConfig']
    cfg = c['Config']
    print('=== Container Security Audit ===')
    print(f'Privileged:     {hc.get(\"Privileged\", False)}')
    print(f'User:           {cfg.get(\"User\", \"root (WARNING!)\") or \"root (WARNING!)\"}')
    print(f'Network Mode:   {hc.get(\"NetworkMode\", \"bridge\")}')
    print(f'Read-Only FS:   {hc.get(\"ReadonlyRootfs\", False)}')
    print(f'PID Mode:       {hc.get(\"PidMode\", \"\")}')
    caps_add = hc.get('CapAdd') or []
    caps_drop = hc.get('CapDrop') or []
    print(f'Caps Added:     {caps_add}')
    print(f'Caps Dropped:   {caps_drop}')
except Exception as e:
    print(f'Error: {e}. Run: docker run -d --name mycontainer nginx:alpine')
"

# Scan Docker image cho CVEs (thay nginx:alpine bằng image thực)
trivy image --severity HIGH,CRITICAL nginx:alpine 2>/dev/null | head -40

# Chạy CIS Kubernetes Benchmark (cần có cluster hoặc minikube)
# docker run --pid=host --network=host --userns=host --cap-add=audit_write \
#   -v /etc:/etc:ro -v /var:/var:ro -v /usr/lib:/usr/lib:ro \
#   aquasec/kube-bench:latest --benchmark cis-1.8 2>/dev/null | grep -E "FAIL|WARN" | head -20

echo "--- Checking for containers running as root ---"
docker ps -q | xargs -I{} docker inspect {} \
  --format '{{.Name}} User={{.Config.User}} Privileged={{.HostConfig.Privileged}}' 2>/dev/null

✅ Kết quả mong đợi / Expected output: Container audit hiển thị Privileged: false (good), User: 1001 (good, not root), ReadOnlyRootfs: true (good). Trivy scan hiển thị CVEs với severity HIGH/CRITICAL và CVE IDs — cần patch base image. kube-bench FAIL items là remediation priorities. Containers chạy User="" nghĩa là root — critical finding trong CIS Benchmark.

3. Tình huống doanh nghiệp / Real-world scenario

Bối cảnh:

Một công ty e-commerce deploy microservices trên Azure Kubernetes Service (AKS). Trong pentest, red team phát hiện: (1) Pod chạy với privileged=true, (2) ServiceAccount có ClusterAdmin binding, (3) NetworkPolicy không được cấu hình — mọi pod có thể communicate với nhau. Red team escalate từ compromised frontend pod để access database pod và extract customer data.

Remediation plan:

  1. Immediate (0-4h): Remove privileged=true từ tất cả pod specs. Revoke ClusterAdmin từ application ServiceAccounts. Enable Pod Security Admission ở Restricted profile cho production namespace.
  2. Network segmentation (4-8h): Deploy default-deny NetworkPolicy: kubectl apply -f default-deny-all.yaml. Tạo specific allow policies: frontend → backend API (port 8080), backend → database (port 5432 only).
  3. Identity hardening (8-24h): Tạo separate ServiceAccount cho mỗi service với minimal permissions. Enable AKS Workload Identity (replace pod-managed identity). Audit RBAC với kubectl-who-can tool.
  4. Ongoing: Integrate Trivy vào CI/CD pipeline — block deployment nếu có CRITICAL CVEs. Enable Microsoft Defender for Containers — real-time threat detection cho AKS.

Bài học CCSP: Container/Kubernetes security là "defense-in-depth" — không có single control đủ. Kết hợp: image scanning (supply chain) + PSA (runtime) + NetworkPolicy (lateral movement) + RBAC (privilege) + monitoring (detection).

4. Tự kiểm tra / Knowledge check

  1. VM Escape attack là gì? CSP mitigate risk này như thế nào trong kiến trúc AWS Nitro và Azure Hyper-V? Tại sao Confidential Computing không thay thế hoàn toàn VM isolation?
  2. So sánh Kubernetes PodSecurityAdmission (PSA) với PodSecurityPolicy (PSP) đã deprecated. Tại sao PSP bị loại bỏ? Cách migrate sang PSA Restricted profile?
  3. Serverless event injection attack khác gì với traditional SQL injection? Lấy ví dụ với AWS Lambda trigger từ API Gateway và cách mitigate.
  4. Giải thích sự khác biệt giữa Security Groups và NACLs trong AWS. Khi nào dùng NACL thay vì Security Group?
  5. IaC drift detection là gì và tại sao quan trọng cho cloud security? Checkov và AWS Config phục vụ use case khác nhau như thế nào?
  6. Managed Identity (Azure) và IAM Role for EC2 (AWS) giải quyết vấn đề gì mà static access keys không thể? Rủi ro gì vẫn còn tồn tại?
Chương 2: Bảo mật dữ liệu Chương 4: Bảo mật ứng dụng đám mây
Thực hành trên công cụPowerShell · kubectl · Trivy
Nền tảngWindows 11 · Ubuntu 22.04
Thời điểm phát hànhQ2/2026
Ngày biên soạn24/05/2026
Người biên soạnTrần Văn Hòa (MCT)
Phiên bảnv1.0
Zalo