关于 auditing-cloud-with-cis-benchmarks
面向云安全团队的审计技能,用于依据 CIS 基准评估云环境,涵盖自动化检查、修复排序和持续合规监控。
主要功能
- 01选择云厂商对应的 CIS 基准
- 02使用 Prowler 或 ScoutSuite 扫描
- 03按严重性排序失败控制项
- 04修复严重和高危问题
- 05建立持续合规监控
适用场景
- 01为新云账户建立安全基线
- 02准备合规审计所需的 CIS 证据
- 03持续跟踪云配置合规情况
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ mukul975/ anthropic-cybersecurity-skills --skill auditing-cloud-with-cis-benchmarks安装后在 Claude Code 中输入/auditing-cloud-with-cis-benchmarks确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
LICENSEreferences/api-reference.mdscripts/agent.py详细介绍
使用 CIS Benchmark 审计云环境
何时使用
- 当依据行业标准 Benchmark 对云环境执行初始安全审计时
- 当为引用 CIS 控制的 SOC 2、ISO 27001 或合规审计做准备时
- 当为新的云账户或订阅建立可度量的安全基线时
- 当通过定期重新评估跟踪合规改进情况时
- 当评估收购或继承的云环境的安全态势时
不要使用于运行时威胁检测(参见 detecting-cloud-threats-with-guardduty)、应用层安全测试(参见 conducting-cloud-penetration-testing),或非基于 CIS 的合规框架(请参考特定的法规技能文件)。
前置条件
- 对目标云账户的只读访问权限(AWS SecurityAudit policy、Azure Reader role、GCP Viewer role)
- 已安装并配置 Prowler、ScoutSuite 或云原生 CSPM 工具
- 了解 CIS benchmark 结构:章节、控制、配置文件(Level 1 和 Level 2)
- 用于实施修复的修复访问权限(与审计凭证分开)
工作流
步骤 1:选择合适的 CIS Benchmark 版本
为每个云服务商选择正确的 benchmark 版本。截至 2025 年的当前版本包括 CIS AWS Foundations Benchmark v5.0、CIS Azure Foundations Benchmark v4.0 和 CIS GCP Foundations Benchmark v4.0。
CIS Benchmark Coverage Areas:
+-------------------+-------------------------+------------------------+
| Section | AWS v5.0 | Azure v4.0 |
+-------------------+-------------------------+------------------------+
| Identity & Access | IAM policies, MFA, root | Azure AD, RBAC, PIM |
| Logging | CloudTrail, Config | Activity Log, Diag |
| Monitoring | CloudWatch alarms | Defender, Sentinel |
| Networking | VPC, SG, NACLs | NSG, ASG, Firewall |
| Storage | S3 encryption, access | Storage encryption |
| Database | RDS encryption | SQL TDE, auditing |
+-------------------+-------------------------+------------------------+
CIS Profile Levels:
Level 1: Practical security settings that can be implemented without significant
performance impact or reduced functionality
Level 2: Defense-in-depth settings that may reduce functionality or require
additional planning for implementation
步骤 2:使用 Prowler 运行自动化评估
使用 Prowler 对 AWS、Azure 和 GCP 执行全面的 CIS benchmark 扫描,以实现自动化控制评估。
# AWS CIS v5.0 assessment
prowler aws \
--compliance cis_5.0_aws \
--profile audit-account \
--output-formats json-ocsf,html,csv \
--output-directory ./cis-audit-$(date +%Y%m%d)
# Azure CIS v4.0 assessment
prowler azure \
--compliance cis_4.0_azure \
--subscription-ids "sub-id-1,sub-id-2" \
--output-formats json-ocsf,html,csv \
--output-directory ./cis-audit-azure-$(date +%Y%m%d)
# GCP CIS v4.0 assessment
prowler gcp \
--compliance cis_4.0_gcp \
--project-ids "project-1,project-2" \
--output-formats json-ocsf,html,csv \
--output-directory ./cis-audit-gcp-$(date +%Y%m%d)
# Multi-account AWS scan using ScoutSuite
scout suite aws \
--profile audit-account \
--report-dir ./scout-report \
--ruleset cis-5.0 \
--force
步骤 3:解读结果并确定修复优先级
按章节和严重性分析审计结果。优先处理 Level 1 控制,因为它们代表基本的安全卫生,然后处理 Level 2 控制以实现纵深防御。
# Parse Prowler results for failed controls
cat ./cis-audit-*/prowler-output-*.json | \
jq '[.[] | select(.StatusExtended == "FAIL")] | group_by(.CheckID) |
map({control: .[0].CheckID, description: .[0].CheckTitle,
failed_resources: length, severity: .[0].Severity}) |
sort_by(-.failed_resources)'
# Generate compliance score by section
cat ./cis-audit-*/prowler-output-*.json | \
jq 'group_by(.Section) | map({
section: .[0].Section,
total: length,
passed: [.[] | select(.StatusExtended == "PASS")] | length,
failed: [.[] | select(.StatusExtended == "FAIL")] | length,
score: (([.[] | select(.StatusExtended == "PASS")] | length) / length * 100 | round)
})'
步骤 4:修复关键和高危控制
从影响最大的项目开始处理未通过的控制。使用 AWS Config remediation、Azure Policy 或 Terraform 系统性地应用修复。
# CIS 1.4: Ensure no root account access key exists
aws iam list-access-keys --user-name root
# If keys exist, delete them
aws iam delete-access-key --user-name root --access-key-id AKIAEXAMPLE
# CIS 2.1.1: Ensure S3 bucket default encryption is enabled
for bucket in $(aws s3api list-buckets --query 'Buckets[*].Name' --output text); do
aws s3api put-bucket-encryption --bucket "$bucket" \
--server-side-encryption-configuration '{
"Rules": [{"ApplyServerSideEncryptionByDefault": {"SSEAlgorithm": "AES256"}}]
}' 2>/dev/null && echo "Encrypted: $bucket" || echo "FAILED: $bucket"
done
# CIS 3.1: Ensure CloudTrail is enabled in all regions
aws cloudtrail create-trail \
--name organization-trail \
--s3-bucket-name cloudtrail-logs-bucket \
--is-multi-region-trail \
--enable-log-file-validation \
--kms-key-id arn:aws:kms:us-east-1:123456789012:key/key-id
aws cloudtrail start-logging --name organization-trail
# CIS 4.x: Configure CloudWatch metric filters and alarms
aws logs put-metric-filter \
--log-group-name CloudTrail/DefaultLogGroup \
--filter-name UnauthorizedAPICalls \
--filter-pattern '{ ($.errorCode = "*UnauthorizedAccess*") || ($.errorCode = "AccessDenied*") }' \
--metric-transformations metricName=UnauthorizedAPICalls,metricNamespace=CISBenchmark,metricValue=1
步骤 5:建立持续合规监控
部署自动化合规监控,以检测周期性审计之间的配置漂移。使用 AWS Security Hub、Azure Policy 或 GCP Security Command Center。
# AWS: Enable CIS v5.0 in Security Hub
aws securityhub batch-enable-standards \
--standards-subscription-requests '[
{"StandardsArn": "arn:aws:securityhub:::ruleset/cis-aws-foundations-benchmark/v/5.0.0"}
]'
# Azure: Assign CIS benchmark policy initiative
az policy assignment create \
--name cis-azure-benchmark \
--scope "/subscriptions/<sub-id>" \
--policy-set-definition "1a5bb27d-173f-493e-9568-eb56638dbd0e" \
--params '{"effect": {"value": "AuditIfNotExists"}}'
# Schedule periodic Prowler assessments
# Run weekly via cron or CI/CD pipeline
0 2 * * 1 prowler aws --compliance cis_5.0_aws --output-formats csv --output-directory /opt/audits/weekly-$(date +\%Y\%m\%d)
关键概念
| 术语 | 定义 |
|---|---|
| CIS Benchmark | 由 Center for Internet Security 通过社区共识制定的规范性安全配置指南 |
| Level 1 Profile | 可在不对性能或功能造成显著影响的情况下实施的实用安全控制,代表安全卫生 |
| Level 2 Profile | 纵深防御控制,可能会限制功能,实施前需要仔细规划 |
| Foundations Benchmark | 专为云服务商制定的 CIS benchmark,涵盖 IAM、日志记录、监控、网络和存储安全 |
| Control ID | 每条 CIS 建议的唯一数字标识符(例如,1.4 用于 root 访问密钥检查,2.1.1 用于 S3 加密) |
| Compliance Score | 处于通过状态的 CIS 控制百分比,随时间跟踪以衡量安全态势改进 |
| Automated Assessment | 使用云服务商 API 检查资源配置是否符合 benchmark 要求,由工具驱动的 CIS 控制评估 |
| Remediation Runbook | 用于修复特定未通过 CIS 控制的成文分步流程,包括预检查和验证 |
工具与系统
- Prowler:开源云安全工具,执行 300 多项检查,包括针对 AWS、Azure 和 GCP 的 CIS 基准评估
- ScoutSuite:多云安全审计工具,具有 CIS 基准规则集并生成 HTML 报告
- AWS Security Hub:AWS 原生服务,支持将 CIS AWS Foundations Benchmark 作为安全标准
- Azure Policy:治理服务,内置 CIS 基准策略计划,用于自动化合规监控
- GCP Security Command Center:GCP 原生服务,根据 CIS GCP Foundations Benchmark 评估配置
常见场景
场景:用于 SOC 2 认证的审计前 CIS 评估
背景:一家正在申请 SOC 2 Type II 认证的 SaaS 公司需要证明其云安全控制措施符合 CIS 基准。审计师要求提供跨 45 个 AWS 账户的持续合规监控证据。
方法:
- 在所有 45 个账户中运行 Prowler CIS v5.0 评估,以建立基线合规评分
- 将结果导出为 CSV,并按部分(IAM、Logging、Monitoring、Networking)对失败项进行分类
- 将每项 CIS 控制措施映射到相关的 SOC 2 信任服务标准(CC6.1、CC6.6、CC7.1 等)
- 在 30 天内修复所有 Level 1 控制失败项,在 60 天内修复 Level 2 控制失败项
- 在 AWS Security Hub 中启用 CIS v5.0,以实现持续监控和自动化漂移检测
- 生成每周合规报告,向审计师展示改进轨迹
- 对有意不实施的控制措施记录例外情况,并提供风险接受理由
陷阱:未先在预发布环境中测试就修复控制措施,可能会破坏生产工作负载。完全忽略 Level 2 控制措施会削弱审计叙述,即使这些控制措施并非严格要求。
输出格式
CIS Benchmark Audit Report
============================
Cloud Provider: AWS
Benchmark Version: CIS AWS Foundations Benchmark v5.0
Accounts Assessed: 45
Assessment Date: 2025-02-23
Tool: Prowler v4.3.0
OVERALL COMPLIANCE SCORE: 74%
COMPLIANCE BY SECTION:
1. Identity and Access Management: 68% (41/60 controls passed)
2. Storage: 82% (28/34 controls passed)
3. Logging: 91% (20/22 controls passed)
4. Monitoring: 55% (18/33 controls passed)
5. Networking: 78% (32/41 controls passed)
TOP FAILED CONTROLS (by affected accounts):
[1.4] Root account has active access keys - 3/45 accounts
[1.5] MFA not enabled for root account - 2/45 accounts
[2.1.1] S3 default encryption not enabled - 12/45 accounts
[3.1] CloudTrail not multi-region - 8/45 accounts
[4.3] No alarm for root account usage - 28/45 accounts
[5.1] VPC flow logs not enabled - 15/45 accounts
[5.4] Security groups allow 0.0.0.0/0 ingress - 22/45 accounts
REMEDIATION PRIORITY:
Critical (Fix within 7 days): Root access keys, missing root MFA
High (Fix within 30 days): S3 encryption, CloudTrail, VPC flow logs
Medium (Fix within 60 days): CloudWatch alarms, security group restrictions
Low (Fix within 90 days): Level 2 controls, informational items