mcpField
S
securing-azure-with-microsoft-defender

securing-azure-with-microsoft-defender

github.com/mukul975安全35.2k57 次安装8 周前更新
代码仓库

关于 securing-azure-with-microsoft-defender

该技能面向负责 Azure 云安全的团队,介绍使用 Microsoft Defender for Cloud 管理安全态势、威胁防护和多云环境,并分析攻击路径及自动化告警响应。

主要功能

  1. 01启用不同工作负载的 Defender 计划
  2. 02连接 AWS 和 GCP 环境
  3. 03查看并排序 Secure Score 建议
  4. 04配置即时访问与应用控制
  5. 05自动化安全告警工作流
  6. 06分析云资源攻击路径

适用场景

  1. 01建立 Azure 订阅的安全基线
  2. 02统一查看 Azure、AWS 和 GCP 安全态势
  3. 03保护 AKS 集群及容器注册表
  4. 04调查通往关键资产的攻击路径

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/mukul975/anthropic-cybersecurity-skills --skill securing-azure-with-microsoft-defender

安装后在 Claude Code 中输入/securing-azure-with-microsoft-defender确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

LICENSE
references/
api-reference.md
scripts/
agent.py

详细介绍

使用 Microsoft Defender 保护 Azure

使用场景

  • 在 Azure 订阅和资源组中部署云工作负载保护时
  • 建立 Secure Score 基线并确定安全建议优先级时
  • 将威胁防护扩展到包括 AWS 和 GCP 在内的多云环境时
  • 为 AKS 集群和 Azure Container Registry 启用容器安全时
  • 通过数据和 AI 安全仪表板集成 AI 工作负载安全时

请勿使用于仅 AWS 环境(参见 implementing-aws-security-hub)、身份提供程序配置(参见 managing-cloud-identity-with-okta)或网络级防火墙规则管理(参见 implementing-cloud-waf-rules)。

先决条件

  • 具有 Security Admin 或 Contributor 角色的 Azure 订阅
  • 在管理组级别为 Defender for Cloud 启用的 Azure Policy 计划
  • 为安全数据收集预配的 Log Analytics 工作区
  • 已获得许可的 Microsoft Defender for Cloud 计划(服务器保护需 P1 或 P2)

工作流

第 1 步:启用 Defender for Cloud 计划

为每种工作负载类型激活 Defender 计划:服务器、容器、App Service、存储、数据库、Key Vault、Resource Manager 和 DNS。每个计划都提供专门的威胁检测和漏洞评估。

# Enable Defender for Servers Plan 2
az security pricing create --name VirtualMachines --tier Standard --subplan P2

# Enable Defender for Containers
az security pricing create --name Containers --tier Standard

# Enable Defender for Storage with malware scanning
az security pricing create --name StorageAccounts --tier Standard \
  --extensions '[{"name":"OnUploadMalwareScanning","isEnabled":"True",
  "additionalExtensionProperties":{"CapGBPerMonthPerStorageAccount":"5000"}}]'

# Enable Defender for Databases
az security pricing create --name SqlServers --tier Standard
az security pricing create --name CosmosDbs --tier Standard

# Enable Defender for Key Vault
az security pricing create --name KeyVaults --tier Standard

# Verify all enabled plans
az security pricing list --query "[?pricingTier=='Standard'].{Plan:name, Tier:pricingTier, SubPlan:subPlan}" -o table
第 2 步:为多云配置环境连接器

将 AWS 账户和 GCP 项目连接到 Defender for Cloud,以实现跨云提供程序的统一安全态势管理。

# Create AWS connector for CSPM
az security security-connector create \
  --name aws-production-connector \
  --resource-group security-rg \
  --environment-name AWS \
  --hierarchy-identifier "123456789012" \
  --offerings '[{
    "offeringType": "CspmMonitorAws",
    "nativeCloudConnection": {"cloudRoleArn": "arn:aws:iam::123456789012:role/DefenderForCloudRole"}
  }]'

# Create GCP connector
az security security-connector create \
  --name gcp-production-connector \
  --resource-group security-rg \
  --environment-name GCP \
  --hierarchy-identifier "my-gcp-project-id" \
  --offerings '[{"offeringType": "CspmMonitorGcp"}]'
第 3 步:查看 Secure Score 建议并确定优先级

分析所有订阅的 Secure Score。每条建议都包含基于资产暴露、互联网暴露和威胁情报上下文的风险优先级。

# Get current Secure Score
az security secure-score list \
  --query "[].{Name:displayName, Score:current, Max:max, Percentage:percentage}" -o table

# List unhealthy recommendations sorted by severity
az security assessment list \
  --query "[?properties.status.code=='Unhealthy'].{Name:properties.displayName, Severity:properties.metadata.severity, Resources:properties.resourceDetails.id}" \
  --output table

# Get specific recommendation details
az security assessment show \
  --assessment-name "4fb67663-9ab9-475d-b026-8c544cced439" \
  --query "{Name:properties.displayName, Description:properties.metadata.description, Remediation:properties.metadata.remediationDescription}"
第 4 步:配置自适应应用程序控制和 JIT 访问

启用即时 VM 访问,仅在需要时打开管理端口以减少攻击面,并部署自适应应用程序控制以将已批准的可执行文件加入允许列表。

# Enable JIT VM access policy
az security jit-policy create \
  --resource-group production-rg \
  --location eastus \
  --name default \
  --virtual-machines '[{
    "id": "/subscriptions/sub-id/resourceGroups/production-rg/providers/Microsoft.Compute/virtualMachines/web-server-01",
    "ports": [
      {"number": 22, "protocol": "TCP", "allowedSourceAddressPrefix": "10.0.0.0/8", "maxRequestAccessDuration": "PT3H"},
      {"number": 3389, "protocol": "TCP", "allowedSourceAddressPrefix": "10.0.0.0/8", "maxRequestAccessDuration": "PT1H"}
    ]
  }]'

# Request JIT access
az security jit-policy initiate \
  --resource-group production-rg \
  --location eastus \
  --name default \
  --virtual-machines '[{
    "id": "/subscriptions/sub-id/resourceGroups/production-rg/providers/Microsoft.Compute/virtualMachines/web-server-01",
    "ports": [{"number": 22, "duration": "PT1H", "allowedSourceAddressPrefix": "203.0.113.10"}]
  }]'
第 5 步:设置安全警报和工作流自动化

配置工作流自动化,在生成安全警报时触发 Logic Apps 或 Azure Functions。为“严重”和“高”严重性警报设置电子邮件通知。

# Create workflow automation for high severity alerts
az security automation create \
  --name high-severity-alert-automation \
  --resource-group security-rg \
  --scopes '[{"description": "Production subscription", "scopePath": "/subscriptions/<sub-id>"}]' \
  --sources '[{
    "eventSource": "Alerts",
    "ruleSets": [{"rules": [{"propertyJPath": "Severity", "propertyType": "String", "expectedValue": "High", "operator": "Equals"}]}]
  }]' \
  --actions '[{
    "logicAppResourceId": "/subscriptions/<sub-id>/resourceGroups/security-rg/providers/Microsoft.Logic/workflows/alert-handler",
    "actionType": "LogicApp"
  }]'

# Configure email notifications
az security contact create \
  --name default \
  --email "[email protected]" \
  --alert-notifications "on" \
  --alerts-to-admins "on"
第 6 步:启用云安全图和攻击路径分析

使用云安全图可视化攻击者可能利用以到达关键资产的攻击路径。根据实际可利用性而非单个发现的严重性来确定修复优先级。

# Query attack paths via Resource Graph
az graph query -q "
  securityresources
  | where type == 'microsoft.security/attackpaths'
  | extend riskLevel = properties.riskLevel
  | extend entryPoint = properties.attackPathDisplayName
  | where riskLevel == 'Critical'
  | project entryPoint, riskLevel, properties.description
  | limit 20
"

关键概念

术语定义
Secure Score基于已实施安全建议百分比的组织安全态势数值度量,按订阅评分并在管理组级别聚合
云安全图映射云资源、身份、网络暴露和漏洞之间关系的图数据库,用于识别可利用的攻击路径
攻击路径分析可视化攻击者可能从入口点到达高价值目标的多步攻击链,按现实世界可利用性确定优先级
即时访问默认阻止管理端口,并在请求获批后临时打开的安全控制,可减少 VM 攻击面
自适应应用程序控制基于机器学习的允许列表,建议应在 VM 上运行的应用程序,并在出现偏差时发出警报
Defender CSPM增强型云安全态势管理计划,提供无代理扫描、攻击路径分析和云安全图功能
安全连接器将 AWS 或 GCP 环境连接到 Defender for Cloud 以进行多云态势管理的集成点

工具与系统

  • Microsoft Defender for Cloud:核心 CNAPP 平台,跨 Azure、AWS 和 GCP 提供 CSPM、CWP 和威胁防护
  • Azure Resource Graph:查询引擎,用于大规模探索云安全图谱数据和攻击路径
  • Azure Logic Apps:工作流自动化平台,用于构建由 Defender 警报触发的修复 playbook
  • Microsoft Defender 门户:统一的安全运营控制台,将 Defender for Cloud 与 XDR、Sentinel 和威胁情报集成
  • Azure Policy:治理引擎,用于将 Defender for Cloud 建议作为合规要求强制执行

常见场景

场景:存在已知漏洞的互联网暴露 SQL Server

背景:Defender for Cloud 识别出一台 Azure SQL Server,它具有公共终结点、一个未修补的严重 CVE,以及一个拥有数据库所有者权限的服务主体,该服务主体还可以访问包含生产加密密钥的 Key Vault。

方法:

  1. 在云安全图谱中查看攻击路径:Internet -> SQL Server(CVE)-> 服务主体 -> Key Vault
  2. 立即将 SQL Server 防火墙限制为仅允许专用终结点
  3. 通过 Azure Update Management 应用 SQL Server 安全补丁
  4. 轮换服务主体凭据,并将其权限范围限定为仅所需的数据库操作
  5. 添加 Key Vault 访问策略,要求服务主体通过托管标识进行身份验证,而不是使用基于密钥的凭据
  6. 在 24 小时内验证攻击路径已在 Defender CSPM 中消除

陷阱:仅关注 SQL 漏洞会遗漏通往 Key Vault 的横向移动路径。限制终结点而不更新应用程序连接字符串会导致服务中断。

输出格式

Microsoft Defender for Cloud Security Report
=============================================
Tenant: acme-corp.onmicrosoft.com
Subscriptions Monitored: 12
Report Date: 2025-02-23

SECURE SCORE: 72/100

DEFENDER PLANS STATUS:
  Servers (P2):     ENABLED - 156 VMs covered
  Containers:       ENABLED - 8 AKS clusters covered
  Storage:          ENABLED - 342 storage accounts, malware scanning active
  Databases:        ENABLED - 23 SQL servers, 5 Cosmos DB accounts
  Key Vault:        ENABLED - 18 vaults monitored
  AWS Connector:    ENABLED - 3 accounts connected
  GCP Connector:    ENABLED - 2 projects connected

CRITICAL ATTACK PATHS:
  [AP-001] Internet -> VM (RDP open) -> Managed Identity -> Storage (PII data)
    Risk: Critical | Affected Resources: 3 | Remediation: Close RDP, restrict MI scope
  [AP-002] Internet -> App Service (SQLi vuln) -> SQL DB -> Service Principal -> Key Vault
    Risk: Critical | Affected Resources: 5 | Remediation: Patch app, private endpoint

ALERT SUMMARY (Last 30 Days):
  Critical: 5 | High: 23 | Medium: 67 | Low: 134
  Top Alert Types:
    - Suspicious login activity (18)
    - Malware detected in storage (7)
    - Anomalous resource deployment (12)

评论

支持 Markdown