AZ-500 LAB 48 ~40 phút Chương 11 Defender for Storage

Defender for Storage + Malware Scanning

Bật Microsoft Defender for Storage, cấu hình malware scanning cho Blob storage, kích hoạt hành vi upload test để sinh alert và thiết lập notification workflow automation cơ bản.

🎯 Mục Tiêu Lab

Bật Defender for Storage trên Storage Account lab

Cấu hình malware scanning trên upload (on-upload scanning)

Upload file test (EICAR test file) để kích hoạt malware alert

Xem security alerts và recommendations trong Defender for Cloud

Cấu hình Event Grid notification hoặc workflow automation cơ bản

Hiểu sự khác biệt giữa activity monitoring và malware scanning

📋 Chuẩn Bị

Yêu cầu:
  • Azure subscription với quyền Owner hoặc Security Admin
  • Defender for Cloud đã enabled (Lab 45)
  • Azure CLI: az login
  • Azure Storage Explorer hoặc trình duyệt để upload file test
Lưu ý:
  • Defender for Storage: ~$10/tháng/storage account
  • Malware scanning: $0.15/GB scanned (tháng đầu có free tier)
  • EICAR test file là file vô hại, chỉ dùng để test AV detection
  • Region: southeastasia, RG: rg-az500-storage-sec

🏗️ Kịch Bản

Công ty sử dụng Azure Blob Storage làm nơi nhận file upload từ đối tác và khách hàng. Để ngăn ransomware và malware lây lan qua storage, bạn cần bật Defender for Storage với malware scanning. Khi có file độc hại được upload, hệ thống phải tự động cảnh báo security team và có thể tự động xóa file nguy hiểm qua workflow automation.

🧪 Các Bước Thực Hiện

1

Tạo Storage Account và Bật Defender for Storage

Tạo Storage Account lab và bật Defender for Storage kèm malware scanning.

Cách 1 — Portal
  1. 1.1Portal → Storage accounts+ Create
  2. 1.2RG: rg-az500-storage-sec, Name: staz500lab48[random], Region: Southeast Asia
  3. 1.3Tab AdvancedMicrosoft Defender for Storage → tick Enable
  4. 1.4Bật Malware scanning → giữ mức cap mặc định (5000 GB/month)
  5. 1.5Review + Create → Create → chờ deployment hoàn tất
  6. 1.6Vào Storage Account → Microsoft Defender for Cloud (menu trái) → xác nhận Defender = On
Cách 2 — Azure CLI
Azure CLI— Tạo Storage Account và bật Defender
# Tạo resource group
az group create \
  --name rg-az500-storage-sec \
  --location southeastasia \
  --tags "owner=hoatranlab" "env=lab" "module=az500-lab48"

# Tạo storage account (tên phải unique globally)
STORAGE_NAME="staz500lab48$(date +%s | tail -c 6)"
az storage account create \
  --name $STORAGE_NAME \
  --resource-group rg-az500-storage-sec \
  --location southeastasia \
  --sku Standard_LRS \
  --kind StorageV2 \
  --allow-blob-public-access false

# Bật Defender for Storage với malware scanning
az security defender for-storage show \
  --resource-group rg-az500-storage-sec \
  --storage-account $STORAGE_NAME 2>/dev/null || echo "Dùng Portal để bật Defender for Storage với malware scanning"

# Xem storage account vừa tạo
az storage account show \
  --name $STORAGE_NAME \
  --resource-group rg-az500-storage-sec \
  --query "{name:name, location:location, kind:kind}" -o table

echo "Storage account name: $STORAGE_NAME"
2

Cấu Hình Malware Scanning và Tạo Container

Cấu hình chi tiết malware scanning và tạo Blob container để test.

Cách 1 — Portal
  1. 2.1Defender for Cloud → Environment settings → subscription → tìm Storage → On
  2. 2.2Click Settings bên cạnh Storage → kiểm tra On-upload malware scanning = On
  3. 2.3Cấu hình Scanning result send to → bật Event Grid topic nếu muốn automation
  4. 2.4Save → vào Storage Account → Containers+ Container
  5. 2.5Name: uploads, Access level: Private → Create
Cách 2 — Azure CLI
Azure CLI— Tạo container và chuẩn bị file test
# Thay YOUR_STORAGE_NAME bằng tên storage account vừa tạo
STORAGE_NAME="YOUR_STORAGE_NAME"

# Lấy connection string
CONN_STR=$(az storage account show-connection-string \
  --name $STORAGE_NAME \
  --resource-group rg-az500-storage-sec \
  --query connectionString -o tsv)

# Tạo container "uploads"
az storage container create \
  --name uploads \
  --connection-string "$CONN_STR" \
  --public-access off

# Tạo file test bình thường
echo "This is a test file for lab 48" > test-normal.txt
az storage blob upload \
  --container-name uploads \
  --file test-normal.txt \
  --name test-normal.txt \
  --connection-string "$CONN_STR"

# Xác nhận blob được upload
az storage blob list \
  --container-name uploads \
  --connection-string "$CONN_STR" \
  --query "[].{name:name, size:properties.contentLength}" \
  -o table
3

Upload EICAR Test File để Kích Hoạt Malware Alert

EICAR Test File: File kiểm thử tiêu chuẩn của ngành antivirus (European Institute for Computer Antivirus Research). Hoàn toàn vô hại, chỉ chứa một chuỗi ASCII đặc biệt để test AV/malware detection mà không cần dùng malware thật.
Cách 1 — Portal
  1. 3.1Tạo file eicar-test.txt trên máy local với nội dung chính xác như trong CLI bên dưới
  2. 3.2Portal → Storage Account → ContainersuploadsUpload
  3. 3.3Chọn file eicar-test.txtUpload
  4. 3.4Chờ 5–10 phút → Defender for Cloud → Security alerts → xem alert "Malware uploaded to storage"
  5. 3.5Click vào alert → xem chi tiết: storage account, container, blob name, scan result
Cách 2 — Azure CLI
Azure CLI / Bash— Tạo và upload EICAR test file
# Tạo EICAR test file (chuỗi chuẩn EICAR — hoàn toàn vô hại)
printf 'X5O!P%%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*' > eicar-test.txt

# Kiểm tra file đã tạo đúng
cat eicar-test.txt

# Upload EICAR test file lên storage
STORAGE_NAME="YOUR_STORAGE_NAME"
CONN_STR=$(az storage account show-connection-string \
  --name $STORAGE_NAME \
  --resource-group rg-az500-storage-sec \
  --query connectionString -o tsv)

az storage blob upload \
  --container-name uploads \
  --file eicar-test.txt \
  --name eicar-test.txt \
  --connection-string "$CONN_STR"

echo "EICAR file uploaded. Check Defender for Cloud alerts in 5-10 minutes."

# Xem alerts sau khi chờ (nếu CLI hỗ trợ)
az security alert list \
  --query "[?contains(alertDisplayName,'Malware') || contains(alertDisplayName,'storage')].{name:alertDisplayName, severity:severity, time:timeGeneratedUtc}" \
  -o table
Kết quả mong đợi trong Portal (Security Alerts)
Alert: "Malware uploaded to a storage blob container"
Severity: High
Description: Azure Defender for Storage detected a malware upload.
Affected resource: staz500lab48xxxxx/uploads/eicar-test.txt
Scan verdict: Malicious
EICAR signature: EICAR-Test-File (not a virus)
4

Xem Alerts và Cấu Hình Workflow Automation

Phân tích alert và cấu hình notification tự động khi có malware được phát hiện.

Cách 1 — Portal
  1. 4.1Defender for Cloud → Security alerts → click alert malware storage
  2. 4.2Xem tab Take action → đọc suggested remediation steps
  3. 4.3Defender for Cloud → Workflow automation+ Add workflow automation
  4. 4.4Trigger: Security alert, Condition: Severity = High, Alert type chứa "storage"
  5. 4.5Action: chọn Logic App (nếu có) hoặc ghi nhận cấu hình mà không tạo để tiết kiệm chi phí
  6. 4.6Xem Email notifications: Defender for Cloud → Environment settingsEmail notifications
Cách 2 — Azure CLI
Azure CLI— Xem alerts và cấu hình email notification
# Xem tất cả security alerts
az security alert list \
  --query "[].{name:alertDisplayName, severity:severity, state:status, time:timeGeneratedUtc}" \
  -o table

# Xem chi tiết alert (nếu có malware alert)
az security alert list \
  --query "[?severity=='High'].{name:alertDisplayName, description:description}" \
  -o json | head -50

# Kiểm tra email notification settings
az security contact list \
  --query "[].{email:email, phone:phone, alertNotifications:alertNotifications, alertsToAdmins:alertsToAdmins}" \
  -o table

# Cấu hình email notification (thay YOUR_EMAIL)
az security contact create \
  --email "[email protected]" \
  --phone "+84917516878" \
  --alert-notifications On \
  --alerts-to-admins On \
  --name "secops-contact"

echo "Email notification configured"
5

Xem Recommendations và Blob Index Tags

Defender for Storage tự động thêm metadata (index tag) vào blob sau khi scan để đánh dấu trạng thái.

Cách 1 — Portal
  1. 5.1Storage Account → Containersuploads → click vào eicar-test.txt
  2. 5.2Xem tab Index tags → tìm tag Malware Scanning Verdict = Malicious
  3. 5.3Defender for Cloud → Recommendations → lọc Resource type: Storage accounts
  4. 5.4Xem các recommendations liên quan đến storage security (public access, HTTPS only, v.v.)
Cách 2 — Azure CLI
Azure CLI— Kiểm tra blob index tags sau scan
# Xem blob properties (bao gồm metadata) sau khi scan
STORAGE_NAME="YOUR_STORAGE_NAME"
CONN_STR=$(az storage account show-connection-string \
  --name $STORAGE_NAME \
  --resource-group rg-az500-storage-sec \
  --query connectionString -o tsv)

# Xem metadata của blob eicar test
az storage blob show \
  --container-name uploads \
  --name eicar-test.txt \
  --connection-string "$CONN_STR" \
  --query "{name:name, metadata:metadata, tags:tags}" \
  -o json

# Xem tất cả blobs với metadata
az storage blob list \
  --container-name uploads \
  --connection-string "$CONN_STR" \
  --include m \
  --query "[].{name:name, metadata:metadata}" \
  -o json

# Xem recommendations cho storage accounts
az security assessment list \
  --resource-group rg-az500-storage-sec \
  --query "[?status.code=='Unhealthy'].{name:displayName, severity:metadata.severity}" \
  -o table

📊 Kết Quả Đầu Ra Lab 48

Defender for Storage Enabled

Storage account hiển thị Defender status = On trong Portal

Malware Scanning Active

On-upload malware scanning = On trong Defender settings

Malware Alert Generated

Alert "Malware uploaded to storage" xuất hiện trong Security alerts

Blob Index Tag Set

eicar-test.txt có tag "Malware Scanning Verdict" = "Malicious"

Email Notification Configured

Security contact với email alert đã được cấu hình

Storage Recommendations Reviewed

Đã xem và ghi nhận các recommendations cho storage security

🧹 Dọn Dẹp Tài Nguyên

Azure CLI— Dọn dẹp lab 48
# Xóa resource group
az group delete \
  --name rg-az500-storage-sec \
  --yes \
  --no-wait

# Tắt Defender for Storage plan (optional — tiết kiệm chi phí)
az security pricing create \
  --name StorageAccounts \
  --tier Free

# Xóa file EICAR local
rm -f eicar-test.txt test-normal.txt

echo "Lab 48 cleanup complete"

❓ Câu Hỏi Ôn Tập

1. Defender for Storage có hai tính năng chính: Activity monitoring và Malware scanning. Sự khác biệt là gì?

Gợi ý: Activity monitoring phát hiện hành vi bất thường (anonymous access, unusual geolocation); Malware scanning quét nội dung file upload để phát hiện virus/malware thực sự

2. Sau khi Defender for Storage scan một blob và phát hiện malware, điều gì xảy ra với file đó?

Gợi ý: File KHÔNG tự động bị xóa — Defender chỉ sinh alert và gắn index tag "Malicious". Việc xóa/quarantine phải được thực hiện qua automation rule (Logic App) hoặc thủ công

3. EICAR test file có phải là malware thật không? Tại sao nó được dùng để test?

Gợi ý: Không, hoàn toàn vô hại. Là chuỗi ASCII 68 ký tự được EICAR chuẩn hóa — tất cả AV engines đều nhận dạng nó mà không cần dùng malware thật, đảm bảo an toàn cho môi trường lab/production

4. Blob index tag "Malware Scanning Verdict" có giá trị nào? Dùng để làm gì?

Gợi ý: Giá trị: "No threats found", "Malicious", "No scan" (file quá lớn/không được scan). Tag này cho phép dùng Lifecycle policy hoặc Logic App tự động xóa blob có tag = Malicious

5. Khi nào nên bật Defender for Storage ở cấp subscription vs. từng storage account?

Gợi ý: Subscription-level: tự động bảo vệ mọi storage account mới tạo, dễ quản lý nhưng tốn chi phí nhiều hơn; Account-level: kiểm soát chi phí từng storage account, phù hợp khi chỉ một số account cần bảo vệ cao

Lab 47: Defender for Servers Thư viện Labs Lab 49: Sentinel + Analytics Rule
Zalo