/cybersecurity-skills-zh:implementing-aws-security-hub-compliancefrom cybersecurity-skills-zh
Configures AWS Security Hub across multiple accounts, enables CIS and PCI DSS compliance standards, sets up automated remediation via EventBridge and Lambda, and creates custom security insights for organizational risk management.
Ships in cybersecurity-skills-zh. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
不适用于:实时威胁检测(使用 GuardDuty)、漏洞扫描(使用 Inspector)或数据分类(使用 Macie)。Security Hub 聚合来自这些服务的发现结果,但不能取代它们。
securityhub:*、config:*、events:* 和 lambda:* 的 IAM 权限在管理账户中启用 Security Hub,并选择要评估的合规标准。
# 在当前账户/区域启用 Security Hub
aws securityhub enable-security-hub \
--enable-default-standards \
--control-finding-generator SECURITY_CONTROL
# 启用特定合规标准
aws securityhub batch-enable-standards --standards-subscription-requests \
'[
{"StandardsArn": "arn:aws:securityhub:us-east-1::standards/aws-foundational-security-best-practices/v/1.0.0"},
{"StandardsArn": "arn:aws:securityhub:us-east-1::standards/cis-aws-foundations-benchmark/v/1.4.0"},
{"StandardsArn": "arn:aws:securityhub:us-east-1::standards/pci-dss/v/3.2.1"},
{"StandardsArn": "arn:aws:securityhub:us-east-1::standards/nist-800-53/v/5.0.0"}
]'
# 验证已启用的标准
aws securityhub get-enabled-standards \
--query 'StandardsSubscriptions[*].[StandardsArn,StandardsStatus]' --output table
设置委派管理员,并聚合来自所有组织账户的发现结果。
# 指定委派管理员(从管理账户执行)
aws securityhub enable-organization-admin-account \
--admin-account-id 111122223333
# 从委派管理员账户启用自动注册
aws securityhub update-organization-configuration \
--auto-enable \
--auto-enable-standards DEFAULT
# 创建跨区域发现结果聚合器
aws securityhub create-finding-aggregator \
--region-linking-mode ALL_REGIONS
# 列出成员账户
aws securityhub list-members \
--query 'Members[*].[AccountId,MemberStatus]' --output table
查询 Security Hub 以了解已启用标准的合规态势,并识别失败的控制项。
# 获取 CIS 基准的总体合规评分
aws securityhub get-standards-control-associations \
--security-control-id "IAM.1" \
--query 'StandardsControlAssociationSummaries[*].[StandardsArn,AssociationStatus]' \
--output table
# 列出所有失败的控制项
aws securityhub get-findings \
--filters '{
"ComplianceStatus": [{"Value": "FAILED", "Comparison": "EQUALS"}],
"RecordState": [{"Value": "ACTIVE", "Comparison": "EQUALS"}],
"WorkflowStatus": [{"Value": "NEW", "Comparison": "EQUALS"}]
}' \
--sort-criteria '{"Field": "SeverityNormalized", "SortOrder": "desc"}' \
--max-items 50 \
--query 'Findings[*].[Title,Severity.Label,Compliance.Status,Resources[0].Id]' \
--output table
# 按严重程度获取发现结果计数
aws securityhub get-insight-results \
--insight-arn "arn:aws:securityhub:us-east-1:111122223333:insight/111122223333/default/2"
构建自定义洞察以跟踪组织特定的安全优先事项。
# 创建针对公开可访问资源的洞察
aws securityhub create-insight \
--name "公开可访问的资源" \
--filters '{
"ResourceType": [
{"Value": "AwsS3Bucket", "Comparison": "EQUALS"},
{"Value": "AwsEc2SecurityGroup", "Comparison": "EQUALS"},
{"Value": "AwsRdsDbInstance", "Comparison": "EQUALS"}
],
"ComplianceStatus": [{"Value": "FAILED", "Comparison": "EQUALS"}],
"SeverityLabel": [{"Value": "CRITICAL", "Comparison": "EQUALS"}, {"Value": "HIGH", "Comparison": "EQUALS"}]
}' \
--group-by-attribute "ResourceType"
# 创建针对未加密资源的洞察
aws securityhub create-insight \
--name "跨账户未加密资源" \
--filters '{
"Title": [{"Value": "encryption", "Comparison": "CONTAINS"}],
"ComplianceStatus": [{"Value": "FAILED", "Comparison": "EQUALS"}]
}' \
--group-by-attribute "AwsAccountId"
设置 EventBridge 规则,为特定发现结果类型触发基于 Lambda 的自动修复。
# 为 Security Hub 发现结果创建 EventBridge 规则
aws events put-rule \
--name "security-hub-critical-findings" \
--event-pattern '{
"source": ["aws.securityhub"],
"detail-type": ["Security Hub Findings - Imported"],
"detail": {
"findings": {
"Severity": {"Label": ["CRITICAL"]},
"Compliance": {"Status": ["FAILED"]},
"Workflow": {"Status": ["NEW"]}
}
}
}'
# S3 公开访问自动修复示例 Lambda(Python)
cat > /tmp/remediate_s3.py << 'PYEOF'
import boto3
import json
def lambda_handler(event, context):
s3 = boto3.client('s3')
securityhub = boto3.client('securityhub')
for finding in event['detail']['findings']:
if 'S3' in finding.get('Title', '') and 'public' in finding.get('Title', '').lower():
bucket_arn = finding['Resources'][0]['Id']
bucket_name = bucket_arn.split(':::')[-1]
s3.put_public_access_block(
Bucket=bucket_name,
PublicAccessBlockConfiguration={
'BlockPublicAcls': True,
'IgnorePublicAcls': True,
'BlockPublicPolicy': True,
'RestrictPublicBuckets': True
}
)
securityhub.batch_update_findings(
FindingIdentifiers=[{
'Id': finding['Id'],
'ProductArn': finding['ProductArn']
}],
Workflow={'Status': 'RESOLVED'},
Note={
'Text': '自动修复:已启用阻止公开访问',
'UpdatedBy': 'security-hub-auto-remediation'
}
)
return {'statusCode': 200}
PYEOF
导出 Security Hub 发现结果,用于报告和与外部 SIEM 或 GRC 平台集成。
# 通过自定义脚本将所有发现结果导出到 S3
aws securityhub get-findings \
--filters '{
"RecordState": [{"Value": "ACTIVE", "Comparison": "EQUALS"}]
}' \
--max-items 1000 \
--output json > security-hub-findings-export.json
# 将严重发现结果发送到 SNS
aws sns publish \
--topic-arn arn:aws:sns:us-east-1:111122223333:security-alerts \
--subject "Security Hub 每日摘要" \
--message file://daily-summary.json
# 通过 EventBridge 集成第三方 SIEM
aws events put-targets \
--rule security-hub-critical-findings \
--targets '[{
"Id": "splunk-hec",
"Arn": "arn:aws:events:us-east-1:111122223333:api-destination/splunk-hec",
"HttpParameters": {
"HeaderParameters": {"Authorization": "Splunk HEC_TOKEN"}
}
}]'
| 术语 | 定义 |
|---|---|
| Security Hub | AWS 服务,聚合来自 AWS 服务和第三方工具的安全发现结果,评估对标准的合规性,并提供统一的安全仪表盘 |
| 安全标准(Security Standard) | Security Hub 针对您的 AWS 配置进行评估的预定义安全控制集(CIS、PCI DSS、NIST 800-53) |
| 安全控制(Security Control) | 标准中的单个检查项,评估特定 AWS 资源配置,例如 S3 存储桶是否阻止公开访问 |
| 发现结果(Finding) | Security Hub 或集成服务检测到的安全问题,采用 AWS Security Finding Format(ASFF)格式 |
| 洞察(Insight) | 按特定属性分组的自定义或托管发现结果集合,为安全分析提供聚合视图 |
| ASFF | AWS Security Finding Format,所有 Security Hub 集成使用的标准化 JSON 模式,确保发现结果表示的一致性 |
场景背景:安全团队需要在 AWS Organization 的所有账户中启用具有 CIS 和 FSBP 标准的 Security Hub,实现集中化发现结果聚合和自动告警。
方法:
update-organization-configuration 为所有现有和新成员账户配置自动启用常见陷阱:Security Hub 要求在每个账户和区域启用 AWS Config。未能启用 Config 将导致控制项显示为"无数据"而非 PASSED 或 FAILED。Config 已禁用的成员账户将静默产生不完整的合规评分。
AWS Security Hub 合规报告
=====================================
组织: acme-corp(50 个账户)
区域: us-east-1(来自所有区域的聚合)
报告日期: 2026-02-23
已启用标准: CIS 1.4, FSBP v1.0, PCI DSS 3.2.1
合规评分:
CIS AWS Foundations 1.4: 78%(182 个控制项中 142 个通过)
AWS FSBP v1.0.0: 85%(233 个控制项中 198 个通过)
PCI DSS 3.2.1: 72%(124 个控制项中 89 个通过)
严重发现结果: 23
高级发现结果: 87
中级发现结果: 245
低级发现结果: 412
失败控制项 TOP 排行:
[IAM.6] Root 账户未启用 MFA 12 个账户
[S3.2] S3 未启用阻止公开访问 8 个账户
[EC2.19] 安全组允许无限制访问 15 个账户
[RDS.3] RDS 未启用静态加密 6 个账户
自动修复操作(过去 30 天):
已启用 S3 阻止公开访问: 14 次
已限制安全组规则: 8 次
已重新启用 CloudTrail 日志: 3 次
自动修复发现结果总计: 25 次
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub killvxk/cybersecurity-skills-zh --plugin cybersecurity-skills-zh735 skills in this plugin
/acquiring-disk-image-with-dd-and-dcfldd使用 dd 和 dcfldd 创建取证级逐位磁盘镜像,通过哈希验证保持证据完整性。/analyzing-active-directory-acl-abuse使用 ldap3 检测 Active Directory 中危险的 ACL 配置错误,识别 GenericAll、WriteDACL 和 WriteOwner 等滥用路径/analyzing-android-malware-with-apktool使用 apktool 进行反编译、jadx 恢复 Java 源码、androguard 进行权限分析,对 Android APK 恶意软件样本执行静态分析,包括清单检查和可疑 API 调用检测。Other plugins' skills for the same job