implementing-aws-security-hub-compliance
实施 AWS Security Hub 跨 AWS 账户聚合安全发现结果,启用 CIS AWS Foundations 和 PCI DSS 等合规标准,通过 EventBridge 和 Lambda 配置自动修复,并为组织风险管理创建自定义安全洞察。
Best use case
implementing-aws-security-hub-compliance is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
实施 AWS Security Hub 跨 AWS 账户聚合安全发现结果,启用 CIS AWS Foundations 和 PCI DSS 等合规标准,通过 EventBridge 和 Lambda 配置自动修复,并为组织风险管理创建自定义安全洞察。
Teams using implementing-aws-security-hub-compliance should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/implementing-aws-security-hub-compliance/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How implementing-aws-security-hub-compliance Compares
| Feature / Agent | implementing-aws-security-hub-compliance | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
实施 AWS Security Hub 跨 AWS 账户聚合安全发现结果,启用 CIS AWS Foundations 和 PCI DSS 等合规标准,通过 EventBridge 和 Lambda 配置自动修复,并为组织风险管理创建自定义安全洞察。
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# 实施 AWS Security Hub 合规
## 适用场景
- 在多个 AWS 账户之间建立集中式安全态势管理时
- 合规要求需要针对 CIS、PCI DSS 或 NIST 800-53 标准进行持续监控时
- 聚合来自 GuardDuty、Inspector、Macie、Firewall Manager 和第三方工具的发现结果时
- 构建由安全发现结果触发的自动修复工作流时
- 管理层需要跨组织安全合规仪表盘时
**不适用于**:实时威胁检测(使用 GuardDuty)、漏洞扫描(使用 Inspector)或数据分类(使用 Macie)。Security Hub 聚合来自这些服务的发现结果,但不能取代它们。
## 前置条件
- 具有 Security Hub 委派管理员的 AWS Organizations
- 具备 `securityhub:*`、`config:*`、`events:*` 和 `lambda:*` 的 IAM 权限
- 在所有目标账户和区域启用 AWS Config(Security Hub 必需)
- 用于多账户部署的 CloudFormation StackSets 或 Terraform
- 已配置 SNS 主题用于向安全团队路由告警
## 工作流程
### 步骤 1:启用 Security Hub 并配置合规标准
在管理账户中启用 Security Hub,并选择要评估的合规标准。
```bash
# 在当前账户/区域启用 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
```
### 步骤 2:配置多账户聚合
设置委派管理员,并聚合来自所有组织账户的发现结果。
```bash
# 指定委派管理员(从管理账户执行)
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
```
### 步骤 3:审查合规评分和失败控制项
查询 Security Hub 以了解已启用标准的合规态势,并识别失败的控制项。
```bash
# 获取 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"
```
### 步骤 4:创建自定义安全洞察
构建自定义洞察以跟踪组织特定的安全优先事项。
```bash
# 创建针对公开可访问资源的洞察
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"
```
### 步骤 5:通过 EventBridge 配置自动修复
设置 EventBridge 规则,为特定发现结果类型触发基于 Lambda 的自动修复。
```bash
# 为 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
```
### 步骤 6:导出发现结果并生成合规报告
导出 Security Hub 发现结果,用于报告和与外部 SIEM 或 GRC 平台集成。
```bash
# 通过自定义脚本将所有发现结果导出到 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 Security Hub**:跨 AWS 账户安全发现结果聚合和合规评估的中央平台
- **AWS Config**:Security Hub 评估资源合规性所必需的配置记录服务
- **Amazon EventBridge**:将 Security Hub 发现结果路由到 Lambda、SNS 或外部修复系统的事件总线
- **AWS Lambda**:由 Security Hub 发现结果触发的自动修复函数的无服务器计算平台
- **Prowler**:可通过 ASFF 集成将发现结果发送到 Security Hub 的开源工具
## 常见场景
### 场景:在 50 账户组织中推广 Security Hub
**场景背景**:安全团队需要在 AWS Organization 的所有账户中启用具有 CIS 和 FSBP 标准的 Security Hub,实现集中化发现结果聚合和自动告警。
**方法**:
1. 在管理账户中启用 Security Hub,并将安全账户指定为委派管理员
2. 通过 `update-organization-configuration` 为所有现有和新成员账户配置自动启用
3. 创建跨区域发现结果聚合器,将所有区域的发现结果整合到管理员账户
4. 在所有账户中启用 CIS AWS Foundations 1.4 和 AWS FSBP 标准
5. 创建 EventBridge 规则,将严重(CRITICAL)发现结果路由到 PagerDuty,将所有发现结果发送到 Splunk
6. 为组织最高风险构建自定义洞察:公开资源、缺失加密、未使用凭据
7. 使用 Lambda 和 SES 为相关方安排每周合规报告
**常见陷阱**: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 次
```Related Skills
triaging-security-incident
使用 NIST SP 800-61r3 和 SANS PICERL 框架对安全事件进行初始分类,确定严重性、范围和所需响应行动。 按类型对事件分类,根据业务影响分配优先级,并路由到相应的响应团队。适用于事件分类、 安全告警分类、严重性评估、事件优先级排序或初始事件分析等请求场景。
triaging-security-incident-with-ir-playbook
使用结构化 IR Playbook 对安全事件进行分类和优先排序,确定严重性、分配响应团队并启动适当的响应程序。
triaging-security-alerts-in-splunk
在 Splunk Enterprise Security 中对安全告警进行分类,通过 SPL 查询和事件审查(Incident Review) 仪表板对重要事件进行严重性分类、调查、关联相关遥测并做出升级或关闭决策。 适用于 SOC 分析师需要处理关联搜索产生的告警队列、确定调查优先级, 或需要为交接给二/三级分析师记录分类决策时。
testing-websocket-api-security
测试 WebSocket API 实现中的安全漏洞,包括 WebSocket 升级时缺少身份认证、跨站 WebSocket 劫持(Cross-Site WebSocket Hijacking,CSWSH)、通过 WebSocket 消息进行的注入攻击、输入校验不足、通过消息泛洪实施拒绝服务,以及通过 WebSocket 帧造成的信息泄露。测试人员使用 Burp Suite 拦截 WebSocket 握手和消息,构造恶意 payload,并测试 WebSocket 通道上的授权绕过。适用于 WebSocket 安全测试、WS 渗透测试、CSWSH 攻击或实时 API 安全评估相关请求。
testing-jwt-token-security
在安全测试活动中,评估 JSON Web Token(JWT)实现中的密码学弱点、算法混淆攻击和授权绕过漏洞。
testing-api-security-with-owasp-top-10
使用自动化和手工测试技术,针对 OWASP API 安全 Top 10 风险对 REST 和 GraphQL API 端点进行系统性评估。
performing-wireless-security-assessment-with-kismet
使用 Kismet 通过被动射频监控进行无线网络安全评估,检测流氓接入点(Rogue AP)、隐藏 SSID、弱加密和未授权客户端。
performing-ssl-tls-security-assessment
使用 sslyze Python 库评估 SSL/TLS 服务器配置,评估加密套件、证书链、协议版本、HSTS 头部,以及 Heartbleed 和 ROBOT 等已知漏洞。
performing-soap-web-service-security-testing
通过分析 WSDL 定义,测试 XML 注入(XML Injection)、XXE、WS-Security 绕过和 SOAPAction 欺骗,对 SOAP Web 服务执行安全测试。
performing-serverless-function-security-review
对 AWS Lambda、Azure Functions 和 GCP Cloud Functions 中的无服务器函数(Serverless Function)执行安全审查,识别过度宽松的执行角色(Execution Role)、不安全的环境变量、注入漏洞和缺失的运行时保护措施。
performing-scada-hmi-security-assessment
对 SCADA 人机界面(HMI, Human-Machine Interface)系统进行安全评估,识别基于 Web 的 HMI、瘦客户端配置、认证机制以及 HMI 与 PLC 之间通信信道中的漏洞,符合 IEC 62443 和 NIST SP 800-82 指南要求。
performing-s7comm-protocol-security-analysis
对西门子SIMATIC S7 PLC使用的S7comm和S7CommPlus协议进行安全分析,识别漏洞,包括重放攻击、完整性绕过、未授权的CPU停止命令以及针对S7-300、S7-400、S7-1200和S7-1500控制器弱点的程序下载操控。