关于 implementing-cloud-security-posture-management
面向云安全团队的多云安全态势管理实施指南,涵盖 AWS、Azure 和 GCP 的配置评估、合规监控、发现项聚合及漂移修复。
主要功能
- 01配置云原生态势监控
- 02使用 Prowler 和 ScoutSuite 评估
- 03构建定期合规检查流水线
- 04聚合并去重安全发现项
- 05检测配置漂移并自动修复
适用场景
- 01统一查看多个云环境的安全态势
- 02按 CIS、SOC 2 或 PCI DSS 评估配置
- 03持续监控基线偏差并处理告警
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ mukul975/ anthropic-cybersecurity-skills --skill implementing-cloud-security-posture-management安装后在 Claude Code 中输入/implementing-cloud-security-posture-management确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
LICENSESKILL.es.mdreferences/api-reference.mdscripts/agent.py详细介绍
实施云安全态势管理
何时使用
- 在 AWS、Azure 和 GCP 环境中建立持续安全监控时
- 当合规要求需要基于 CIS、SOC 2 或 PCI DSS 的自动化态势评估时
- 当安全团队需要了解多个账户和订阅中的云配置错误时
- 在构建检测并修复安全基线偏差的安全运营工作流时
- 在将工作负载迁移到云并需要实施安全防护机制时
不要使用于运行时工作负载保护(使用 Falco 或 Aqua 等 CWPP 工具)、应用安全测试(使用 DAST/SAST 工具)或网络入侵检测(使用 GuardDuty 或 Network Watcher 等云原生 IDS)。
前置条件
- 具有跨所有目标环境的只读安全审计权限的多云凭证
- 已安装 Prowler v3+(
pip install prowler) - 已安装 ScoutSuite(
pip install scoutsuite) - 在各自环境中启用了 AWS Config、Azure Policy 和 GCP Organization Policy
- 用于发现结果聚合的集中日志记录目标(S3 存储桶、Log Analytics Workspace 或 Cloud Storage)
- 为关键发现告警配置了通知渠道(Slack、PagerDuty、电子邮件)
工作流
步骤 1:部署云原生 CSPM 服务
启用各云提供商内置的 CSPM 能力,以进行基线态势评估。
# AWS: Enable Security Hub with FSBP and CIS standards
aws securityhub enable-security-hub --enable-default-standards
aws securityhub batch-enable-standards --standards-subscription-requests \
'[{"StandardsArn":"arn:aws:securityhub:::standards/cis-aws-foundations-benchmark/v/1.4.0"}]'
# Azure: Enable Microsoft Defender for Cloud (CSPM tier)
az security pricing create --name CloudPosture --tier standard
az security auto-provisioning-setting update --name default --auto-provision on
# GCP: Enable Security Command Center Premium
gcloud services enable securitycenter.googleapis.com
gcloud scc settings update --organization=ORG_ID \
--enable-asset-discovery
步骤 2:运行 Prowler 进行多云评估
执行 Prowler 以在所有三个云提供商中执行全面的安全检查。
# AWS assessment with all CIS checks
prowler aws \
--profile production \
-M json-ocsf csv html \
-o ./prowler-results/aws/ \
--compliance cis_1.4_aws cis_1.5_aws
# Azure assessment
prowler azure \
--subscription-ids SUB_ID_1 SUB_ID_2 \
-M json-ocsf csv html \
-o ./prowler-results/azure/ \
--compliance cis_2.0_azure
# GCP assessment
prowler gcp \
--project-ids project-1 project-2 \
-M json-ocsf csv html \
-o ./prowler-results/gcp/ \
--compliance cis_2.0_gcp
# View summary across all providers
prowler aws --list-compliance
步骤 3:运行 ScoutSuite 进行跨云比较
使用 ScoutSuite 进行统一的多云安全评估并提供可视化报告。
# Scan AWS
python3 -m ScoutSuite aws --profile production \
--report-dir ./scoutsuite/aws/
# Scan Azure
python3 -m ScoutSuite azure --cli \
--all-subscriptions \
--report-dir ./scoutsuite/azure/
# Scan GCP
python3 -m ScoutSuite gcp --user-account \
--all-projects \
--report-dir ./scoutsuite/gcp/
# Each produces an HTML report with risk-scored findings
步骤 4:构建自动化合规监控管道
创建一个计划的管道,每天运行 CSPM 检查并将发现结果路由到适当的渠道。
# Create a daily Prowler scan with EventBridge + CodeBuild (AWS)
cat > buildspec.yml << 'EOF'
version: 0.2
phases:
install:
commands:
- pip install prowler
build:
commands:
- prowler aws -M json-ocsf -o s3://security-findings-bucket/prowler/$(date +%Y%m%d)/
- prowler aws --compliance cis_1.5_aws -M csv -o s3://security-findings-bucket/prowler/compliance/
post_build:
commands:
- |
CRITICAL=$(cat output/*.json | grep -c '"CRITICAL"')
if [ "$CRITICAL" -gt 0 ]; then
aws sns publish --topic-arn arn:aws:sns:us-east-1:ACCOUNT:security-alerts \
--subject "Prowler: $CRITICAL critical findings" \
--message "Review at s3://security-findings-bucket/prowler/$(date +%Y%m%d)/"
fi
EOF
# Schedule with EventBridge
aws events put-rule \
--name daily-prowler-scan \
--schedule-expression "cron(0 6 * * ? *)" \
--state ENABLED
步骤 5:配置发现结果聚合与去重
将来自多个 CSPM 工具和云提供商的发现结果聚合到统一视图中。
# findings_aggregator.py - Normalize and deduplicate CSPM findings
import json
import hashlib
from datetime import datetime
def normalize_finding(finding, source):
"""Normalize findings from different CSPM tools to a common format."""
normalized = {
'id': hashlib.sha256(f"{finding.get('ResourceId','')}{finding.get('CheckId','')}".encode()).hexdigest()[:16],
'source': source,
'cloud': finding.get('Provider', 'unknown'),
'account': finding.get('AccountId', finding.get('SubscriptionId', '')),
'region': finding.get('Region', ''),
'resource_type': finding.get('ResourceType', ''),
'resource_id': finding.get('ResourceId', ''),
'severity': finding.get('Severity', 'INFO').upper(),
'status': finding.get('Status', 'FAIL'),
'title': finding.get('CheckTitle', finding.get('Title', '')),
'description': finding.get('StatusExtended', ''),
'compliance': finding.get('Compliance', {}),
'remediation': finding.get('Remediation', {}).get('Recommendation', {}).get('Text', ''),
'timestamp': datetime.utcnow().isoformat()
}
return normalized
def aggregate_findings(prowler_file, scoutsuite_file):
findings = {}
for file_path, source in [(prowler_file, 'prowler'), (scoutsuite_file, 'scoutsuite')]:
with open(file_path) as f:
for line in f:
raw = json.loads(line)
normalized = normalize_finding(raw, source)
if normalized['status'] == 'FAIL':
findings[normalized['id']] = normalized
return sorted(findings.values(), key=lambda x: {'CRITICAL':0,'HIGH':1,'MEDIUM':2,'LOW':3}.get(x['severity'],4))
步骤 6:实施漂移检测与自动修复
设置对违反安全基线的配置漂移的自动响应。
# AWS Config auto-remediation for non-compliant S3 buckets
aws configservice put-remediation-configurations --remediation-configurations '[{
"ConfigRuleName": "s3-bucket-public-read-prohibited",
"TargetType": "SSM_DOCUMENT",
"TargetId": "AWS-DisableS3BucketPublicReadWrite",
"Parameters": {
"S3BucketName": {"ResourceValue": {"Value": "RESOURCE_ID"}}
},
"Automatic": true,
"MaximumAutomaticAttempts": 3,
"RetryAttemptSeconds": 60
}]'
# Azure Policy for auto-remediation
az policy assignment create \
--name "enforce-storage-encryption" \
--policy "/providers/Microsoft.Authorization/policyDefinitions/404c3081-a854-4457-ae30-26a93ef643f9" \
--scope "/subscriptions/SUB_ID" \
--enforcement-mode Default
# GCP Organization Policy constraint
gcloud resource-manager org-policies set-policy policy.yaml --organization=ORG_ID
# policy.yaml: constraint: constraints/storage.publicAccessPrevention, enforcement: true
关键概念
| 术语 | 定义 |
|---|---|
| CSPM | 云安全态势管理,持续监控云基础设施以发现配置错误和合规违规的实践 |
| 配置漂移 | 云资源配置随时间推移偏离已批准安全基线的意外更改 |
| 安全基线 | 所有云资源必须满足的最低安全配置要求的文档化集合 |
| 合规框架 | 用于评估云配置的结构化安全控制和要求集合(CIS、SOC 2、PCI DSS、NIST) |
| 发现结果严重性 | 基于可利用性和潜在影响的配置错误风险分类(Critical、High、Medium、Low、Informational) |
| 自动修复 | 在无需人工干预的情况下将不合规资源恢复到其所需配置的自动纠正措施 |
工具与系统
- Prowler:开源多云安全评估工具,具有 300+ 项符合 CIS、PCI DSS、HIPAA 和 NIST 的检查
- ScoutSuite:多云安全审计工具,根据 API 收集的配置数据生成风险评分的 HTML 报告
- AWS Security Hub:AWS 原生 CSPM,具有聚合发现结果和合规标准评估
- Microsoft Defender for Cloud:Azure 原生 CSPM,具有安全评分、法规合规和工作负载保护
- GCP Security Command Center:GCP 原生安全平台,具有资产清单、漏洞扫描和合规监控
常见场景
场景:为多云企业建立 CSPM
背景:某企业在 AWS(主要)、Azure(身份与 Microsoft 服务)和 GCP(数据分析)上运行生产工作负载。安全团队需要统一的安全态势可见性。
方法:
- 在各提供商中启用云原生 CSPM:Security Hub、Defender for Cloud、SCC
- 通过 CI/CD 管道在各环境中以每日计划任务的方式部署 Prowler 扫描
- 使用聚合脚本将发现结果规范化并汇总到中央数据湖中
- 在 Grafana 或 Kibana 中构建仪表板,按云、账户和严重程度展示安全态势评分
- 为已知可靠的修复措施(阻止公开访问、启用加密)配置自动修复
- 将 CRITICAL 级别的发现结果路由到 PagerDuty 以便立即响应,将 HIGH 级别的发现结果路由为 Jira 工单
- 为高管利益相关者生成每周合规报告,展示趋势数据
陷阱:以过于宽泛的权限运行 CSPM 工具会制造一个高价值攻击目标。应使用具有只读权限的专用服务账户,并定期轮换凭证。不同的 CSPM 工具可能以不同方式报告同一错误配置,因此去重逻辑必须考虑各工具之间不同的资源 ID 格式和发现结果标题。
输出格式
Cloud Security Posture Management Dashboard
==============================================
Organization: Acme Corp
Assessment Date: 2026-02-23
Environments: AWS (12 accounts), Azure (8 subscriptions), GCP (5 projects)
POSTURE SCORES:
AWS: 82/100 (+3 from last week)
Azure: 76/100 (-1 from last week)
GCP: 79/100 (+5 from last week)
Overall: 79/100
FINDINGS BY SEVERITY:
Critical: 18 (AWS: 7, Azure: 8, GCP: 3)
High: 67 (AWS: 28, Azure: 24, GCP: 15)
Medium: 234 (AWS: 98, Azure: 87, GCP: 49)
Low: 412 (AWS: 178, Azure: 134, GCP: 100)
TOP FAILING CATEGORIES:
1. IAM overly permissive policies (43 findings)
2. Encryption not enabled at rest (38 findings)
3. Public network exposure (29 findings)
4. Logging and monitoring gaps (24 findings)
5. Unused credentials and keys (19 findings)
AUTO-REMEDIATION (Last 7 Days):
Findings auto-remediated: 34
Manual remediation pending: 51
Exceptions approved: 8
评论
支持 Markdown