Performs GCP security assessments using Forseti Security, Security Command Center, and gcloud CLI. Audits IAM policies, firewall rules, storage permissions, and checks CIS GCP Foundations Benchmark compliance.
npx claudepluginhub killvxk/cybersecurity-skills-zhThis skill uses the workspace's default tool permissions.
- 对 GCP 组织和项目进行定期安全评估时
Audits GCP organizations and projects for security using Forseti, Security Command Center, gcloud CLI. Reviews IAM policies, firewall rules, storage permissions, and CIS GCP Foundations Benchmark compliance.
Performs GCP security assessments using Forseti, Security Command Center, and gcloud CLI to audit IAM policies, firewall rules, storage permissions, and CIS GCP Foundations Benchmark compliance. For periodic reviews, project onboarding, and baseline establishment.
Interprets gcp-inspector gcloud output for GCP compliance against SCF controls in IAM, Cloud Storage, audit logs, KMS, and Compute.
Share bugs, ideas, or general feedback.
不适用于:替代 GCP Security Command Center Premium 进行实时威胁检测、应用层漏洞扫描(应使用 Web Security Scanner),或 GKE 专项安全评估(应使用 GKE Security Posture)。
roles/securitycenter.admin、roles/iam.securityReviewer)pip install scoutsuite)启用 SCC 并设置 Cloud Asset Inventory(云资产清单),以实现全面的资源可见性。
# 启用 Security Command Center API
gcloud services enable securitycenter.googleapis.com \
--project=PROJECT_ID
# 启用 Cloud Asset API
gcloud services enable cloudasset.googleapis.com \
--project=PROJECT_ID
# 列出组织中的所有资产
gcloud asset search-all-resources \
--scope=organizations/ORG_ID \
--asset-types="compute.googleapis.com/Instance,storage.googleapis.com/Bucket,iam.googleapis.com/ServiceAccount" \
--format="table(name, assetType, location, project)"
# 将资产清单导出到 BigQuery 进行分析
gcloud asset export \
--organization=ORG_ID \
--output-bigquery-force \
--output-bigquery-dataset=projects/PROJECT_ID/datasets/asset_inventory \
--output-bigquery-table=resources \
--content-type=resource
审查整个组织的 IAM 策略,查找过度宽松的绑定、原始角色(Primitive Role)和服务账号滥用情况。
# 列出组织级别的所有 IAM 策略绑定
gcloud organizations get-iam-policy ORG_ID \
--format=json > org-iam-policy.json
# 查找所有跨项目拥有 Owner 或 Editor 角色的用户
gcloud asset search-all-iam-policies \
--scope=organizations/ORG_ID \
--query="policy:roles/owner OR policy:roles/editor" \
--format="table(resource, policy.bindings.role, policy.bindings.members)"
# 识别具有管理员角色的服务账号
gcloud asset search-all-iam-policies \
--scope=organizations/ORG_ID \
--query="policy.bindings.members:serviceAccount AND policy:roles/owner" \
--format=json
# 检查 allUsers 或 allAuthenticatedUsers 绑定(公开访问)
gcloud asset search-all-iam-policies \
--scope=organizations/ORG_ID \
--query="policy:allUsers OR policy:allAuthenticatedUsers" \
--format="table(resource, policy.bindings.role, policy.bindings.members)"
# 列出超过 90 天的服务账号密钥
gcloud iam service-accounts keys list \
--iam-account=SA_EMAIL \
--managed-by=user \
--format="table(name,validAfterTime,validBeforeTime)"
审计 VPC 防火墙规则,检查过度宽松的入站规则、缺失日志记录和网络暴露情况。
# 列出允许来自 0.0.0.0/0 入站流量的所有防火墙规则
gcloud compute firewall-rules list \
--filter="direction=INGRESS AND sourceRanges=0.0.0.0/0" \
--format="table(name, network, allowed, sourceRanges, targetTags)"
# 查找允许所有协议/端口的防火墙规则
gcloud compute firewall-rules list \
--filter="direction=INGRESS AND allowed[].IPProtocol=all" \
--format="table(name, network, sourceRanges, targetTags)"
# 检查向互联网开放 SSH(22)和 RDP(3389)的规则
gcloud compute firewall-rules list \
--filter="direction=INGRESS AND sourceRanges=0.0.0.0/0 AND (allowed[].ports=22 OR allowed[].ports=3389)" \
--format="table(name, network, allowed, sourceRanges)"
# 审计 VPC 流日志配置
gcloud compute networks subnets list \
--format="table(name, region, enableFlowLogs, logConfig.aggregationInterval)"
检查公开可访问的存储桶和缺失的加密配置。
# 列出项目中的所有存储桶
gsutil ls -p PROJECT_ID
# 检查存储桶 IAM 中的公开访问情况
for bucket in $(gsutil ls -p PROJECT_ID); do
echo "=== $bucket ==="
gsutil iam get "$bucket" | grep -E "allUsers|allAuthenticatedUsers" && \
echo " 警告:检测到公开访问" || \
echo " 正常:无公开访问"
done
# 检查存储桶加密配置
for bucket in $(gsutil ls -p PROJECT_ID); do
echo "=== $bucket ==="
gsutil kms encryption "$bucket" 2>/dev/null || echo " 使用 Google 管理的加密"
done
# 检查统一存储桶级访问强制执行
for bucket in $(gsutil ls -p PROJECT_ID); do
gsutil uniformbucketlevelaccess get "$bucket"
done
执行 ScoutSuite 对 GCP 环境进行自动化多项安全检查。
# 针对 GCP 运行 ScoutSuite
python3 -m ScoutSuite gcp \
--user-account \
--all-projects \
--report-dir ./scoutsuite-gcp-report
# 使用服务账号凭据运行
python3 -m ScoutSuite gcp \
--service-account /path/to/service-account-key.json \
--all-projects \
--report-dir ./scoutsuite-gcp-report
# 打开 HTML 报告
open ./scoutsuite-gcp-report/gcp-report.html
检索并分析 SCC 发现,包括漏洞、配置错误和威胁。
# 列出活跃的 SCC 发现
gcloud scc findings list ORG_ID \
--filter="state=\"ACTIVE\" AND severity=\"CRITICAL\"" \
--format="table(finding.category, finding.severity, finding.resourceName, finding.eventTime)"
# 按类别列出发现
gcloud scc findings list ORG_ID \
--filter="state=\"ACTIVE\" AND category=\"PUBLIC_BUCKET_ACL\"" \
--format=json
# 按类别统计发现数量
gcloud scc findings group ORG_ID \
--group-by="category" \
--filter="state=\"ACTIVE\""
# 列出 SCC 合规违规项
gcloud scc findings list ORG_ID \
--filter="state=\"ACTIVE\" AND sourceProperties.compliance_standard=\"CIS\"" \
--format="table(finding.category, finding.severity, finding.resourceName)"
| 术语 | 定义 |
|---|---|
| Security Command Center | GCP 原生安全和风险管理平台,提供资产清单、漏洞检测和威胁监控功能 |
| Forseti Security | 开源 GCP 安全工具集(现已弃用,由 SCC 取代),提供清单、扫描、执行和通知功能 |
| Cloud Asset Inventory | GCP 服务,提供包含元数据、IAM 策略和组织策略配置的完整云资源清单 |
| CIS GCP Foundations Benchmark | 互联网安全中心(Center for Internet Security)针对 Google Cloud Platform 配置发布的安全最佳实践指南 |
| 统一存储桶级访问(Uniform Bucket-Level Access) | GCP 存储设置,禁用旧版 ACL,通过 IAM 策略统一控制访问权限 |
| 组织策略(Organization Policy) | GCP 基于约束的治理机制,在整个组织层级中限制资源配置 |
场景背景:公司收购后,安全团队需要评估被收购公司拥有 30+ 个项目的 GCP 组织的安全态势。
方法:
gcloud asset search-all-iam-policies 查找所有 Owner/Editor 绑定和公开访问授权0.0.0.0/0 的过度宽松入站防火墙规则gsutil iam get 检查所有存储桶的公开访问情况常见陷阱:GCP IAM 绑定从组织继承到文件夹再到项目。组织级别的宽松绑定会影响所有下游项目。务必在层级的每个级别审计 IAM,而不仅仅是项目级别。
GCP 安全评估报告
=================================
组织: acme-acquired-org(ORG_ID: 123456789)
评估项目数: 34
评估日期: 2026-02-23
标准: CIS GCP Foundations 2.0
IAM 发现:
组织级别具有 Owner 角色的用户数: 3
具有 Editor 角色的服务账号数: 12
具有 allUsers 绑定的资源数: 5
超过 90 天的服务账号密钥数: 18
网络发现:
允许 0.0.0.0/0 的防火墙规则数: 14
向互联网开放 SSH 的规则数: 7
向互联网开放 RDP 的规则数: 2
未启用 VPC 流日志的子网数: 22
存储发现:
公开可访问的存储桶数: 5
未使用 CMEK 加密的存储桶数: 28
未启用统一访问的存储桶数: 15
严重发现: 12
高危发现: 34
中危发现: 78
低危发现: 145
优先修复事项:
1. 从 5 个存储桶移除 allUsers 绑定(严重)
2. 将 0.0.0.0/0 防火墙规则限制为特定 CIDR(高危)
3. 轮换 18 个超过 90 天的服务账号密钥(高危)
4. 在 22 个子网上启用 VPC 流日志(中危)