Implements Google Workspace admin security hardening: anti-phishing MFA enforcement, DLP policies, email auth (SPF/DKIM/DMARC), OAuth app controls, external sharing limits. For G Suite configs and cloud office security.
How this skill is triggered — by the user, by Claude, or both
Slash command
/cybersecurity-skills-zh:implementing-google-workspace-admin-securityThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
- 为企业使用部署或加固 Google Workspace 环境
不适用于 Microsoft 365 环境;Google Workspace 有独特的管理控制台设置和 API 配置,与 Azure AD/Entra ID 控制有所不同。
保护 Google Workspace 租户中最高权限的账户:
# Google Workspace Admin SDK - 配置管理员账户安全
# 使用 gam(Google Apps Manager)CLI 工具
# 列出所有超级管理员账户进行审计
gam print admins role "Super Admin" > super_admins.csv
echo "审查并最小化超级管理员数量(推荐:最多 2-3 个)"
# 为超级管理员强制执行高级保护计划
# APP 提供最强大的账户保护:
# - 登录时需要 FIDO2 安全密钥
# - 阻止第三方应用访问 Gmail 和 Drive
# - 增强账户恢复验证
gam update user superadmin@corp.com \
advanced_protection true
# 创建专用的紧急访问管理员账户
gam create user breakglass-admin@corp.com \
firstname "Break" lastname "Glass Admin" \
password "$(openssl rand -base64 32)" \
changepassword true \
org "/Emergency Accounts"
# 为紧急访问账户分配超级管理员角色
gam create admin breakglass-admin@corp.com "Super Admin"
# 配置管理员活动告警
# Alert Center API - 为管理员操作创建告警
cat > admin_alert_policy.json << 'EOF'
{
"alertPolicies": [
{
"name": "超级管理员登录告警",
"conditions": {
"eventType": "login",
"filterCriteria": "actor.adminRole=SUPER_ADMIN"
},
"notifications": {
"email": ["security-team@corp.com"],
"webhook": "https://siem.corp.com/webhook/google-admin"
}
},
{
"name": "管理员角色变更告警",
"conditions": {
"eventType": "admin_role_change"
},
"notifications": {
"email": ["security-team@corp.com"]
}
}
]
}
EOF
配置消除可钓鱼认证因素的 MFA 策略:
# 为所有组织单元强制执行两步验证
# 使用 Admin SDK Directory API
# 为整个组织启用 2SV 强制执行
gam update org "/" settings \
2sv_enforcement true \
2sv_enrollment_grace_period 14 \
2sv_new_user_enrollment_period 1
# 配置允许的 2SV 方法 - 仅限抗钓鱼方法
# 高安全性 OU:仅限安全密钥
gam update org "/Executive" settings \
2sv_allowed_methods "SECURITY_KEY_ONLY"
# 普通员工:安全密钥或手机提示(不允许短信/语音)
gam update org "/" settings \
2sv_allowed_methods "SECURITY_KEY,PHONE_PROMPT" \
2sv_disallowed_methods "SMS,VOICE_CALL,BACKUP_CODES"
# 批量检查 2SV 注册状态
gam print users \
fields primaryEmail,isEnrolledIn2Sv,isEnforcedIn2Sv \
query "isEnrolledIn2Sv=false" > users_without_2sv.csv
# 统计未注册 2SV 的用户
echo "未注册 2SV 的用户:"
wc -l < users_without_2sv.csv
# 配置上下文感知访问策略
# 对敏感应用要求 2SV + 托管设备
cat > context_aware_policy.json << 'EOF'
{
"accessLevels": [
{
"name": "需要托管设备",
"conditions": {
"devicePolicy": {
"requireScreenLock": true,
"requireAdminApproval": true,
"allowedEncryptionStatuses": ["ENCRYPTED"],
"requireCorpOwned": false
},
"requiredAccessLevels": ["VERIFIED_2SV"]
}
}
],
"applicationPolicies": [
{
"applications": ["Google Drive", "Gmail", "Admin Console"],
"accessLevel": "需要托管设备"
}
]
}
EOF
设置 SPF、DKIM、DMARC 和高级钓鱼保护:
# 步骤 3a:配置 SPF 记录
# 添加到 corp.com 的 DNS TXT 记录
echo 'SPF 的 DNS TXT 记录:'
echo 'corp.com TXT "v=spf1 include:_spf.google.com ~all"'
echo ''
echo '测试后,将 ~all 改为 -all(硬失败)以强制执行'
# 步骤 3b:生成并配置 DKIM 签名
# 通过管理控制台或 API 生成 2048 位 DKIM 密钥
gam create dkim domain corp.com selector google bitlength 2048
echo '添加 DKIM DNS TXT 记录:'
echo 'google._domainkey.corp.com TXT "v=DKIM1; k=rsa; p=<管理控制台中的公钥>"'
# 验证 DKIM 是否正常工作
gam info dkim domain corp.com
# 步骤 3c:配置 DMARC 策略
echo 'DMARC 的 DNS TXT 记录(从监控开始):'
echo '_dmarc.corp.com TXT "v=DMARC1; p=none; rua=mailto:dmarc-reports@corp.com; ruf=mailto:dmarc-forensics@corp.com; pct=100; adkim=s; aspf=s"'
echo ''
echo '监控 30 天后,升级为隔离再到拒绝:'
echo '_dmarc.corp.com TXT "v=DMARC1; p=reject; rua=mailto:dmarc-reports@corp.com; pct=100; adkim=s; aspf=s"'
# 步骤 3d:启用高级钓鱼和恶意软件防护
# 在管理控制台 > 安全 > 电子邮件安全中配置
gam update settings email_safety \
protect_against_domain_spoofing true \
protect_against_employee_spoofing true \
protect_against_inbound_spoofing true \
protect_unauthenticated_email true \
identify_spoofed_groups true \
auto_move_suspicious_to_spam true
# 配置附件安全
gam update settings email_safety \
protect_encrypted_attachments true \
protect_anomalous_attachment_types true \
protect_scripts_from_untrusted true \
whitelist_sender_domains "" \
apply_future_recommended_settings true
配置 DLP 规则以防止敏感数据泄露:
# 为 Gmail 和 Drive 创建 DLP 规则
# 使用 Google Workspace DLP API
cat > dlp_rules.json << 'EOF'
{
"dlpRules": [
{
"name": "PII 检测 - 社会安全号",
"description": "检测外发邮件和 Drive 共享中的社会安全号",
"trigger": {
"contentMatchers": [
{
"infoType": "US_SOCIAL_SECURITY_NUMBER",
"likelihood": "LIKELY",
"minMatchCount": 1
}
],
"scope": ["GMAIL_OUTBOUND", "DRIVE_EXTERNAL_SHARE"]
},
"action": {
"blockAction": "QUARANTINE",
"notifyAdmin": true,
"notifyUser": true,
"userMessage": "此邮件包含社会安全号,已被隔离等待审查。",
"auditLog": true
}
},
{
"name": "信用卡号检测",
"description": "阻止外发通信中的信用卡号",
"trigger": {
"contentMatchers": [
{
"infoType": "CREDIT_CARD_NUMBER",
"likelihood": "LIKELY",
"minMatchCount": 1
}
],
"scope": ["GMAIL_OUTBOUND", "DRIVE_EXTERNAL_SHARE", "CHAT"]
},
"action": {
"blockAction": "BLOCK",
"notifyAdmin": true,
"notifyUser": true,
"auditLog": true
}
},
{
"name": "机密文档检测",
"description": "检测标记为机密或仅限内部的文档",
"trigger": {
"contentMatchers": [
{
"customRegex": "(?i)(CONFIDENTIAL|INTERNAL ONLY|DO NOT DISTRIBUTE|RESTRICTED)",
"minMatchCount": 2
}
],
"metadataMatchers": [
{
"driveLabels": ["Confidential", "Restricted"]
}
],
"scope": ["DRIVE_EXTERNAL_SHARE"]
},
"action": {
"blockAction": "WARN",
"requireJustification": true,
"auditLog": true
}
}
]
}
EOF
echo "通过管理控制台 > 安全 > 数据保护应用 DLP 规则"
echo "或使用 Google Workspace DLP API 进行程序化部署"
限制哪些第三方应用可以访问组织数据:
# 配置 OAuth 应用访问控制
# 管理控制台 > 安全 > API 控制 > 应用访问控制
# 默认阻止所有第三方应用,然后将已批准的应用加入白名单
gam update org "/" settings \
third_party_app_access "BLOCKED" \
allow_users_to_install_apps false
# 将已批准的应用加入白名单
cat > approved_apps.json << 'EOF'
{
"allowedApps": [
{
"appId": "slack-app-id",
"name": "Slack",
"scopes": ["gmail.readonly", "calendar.readonly"],
"approvedBy": "security-team",
"reviewDate": "2026-01-15"
},
{
"appId": "zoom-app-id",
"name": "Zoom",
"scopes": ["calendar.events"],
"approvedBy": "security-team",
"reviewDate": "2026-01-15"
},
{
"appId": "salesforce-app-id",
"name": "Salesforce",
"scopes": ["gmail.send", "contacts.readonly"],
"approvedBy": "security-team",
"reviewDate": "2026-01-15"
}
]
}
EOF
# 审计用户授予的当前 OAuth 令牌
gam all users print tokens > oauth_tokens_audit.csv
echo "审查 oauth_tokens_audit.csv 以发现未授权的第三方访问"
# 撤销未批准应用的令牌
gam all users deprovision tokens \
clientid "unapproved-app-client-id"
# 配置 API 范围限制
# 限制第三方应用可以请求的 API 范围
gam update org "/" settings \
api_access_restricted true \
allowed_api_scopes "gmail.readonly,calendar.readonly,drive.readonly"
锁定数据共享控制:
# 配置 Google Drive 共享限制
gam update org "/" settings \
drive_sharing_outside_domain "WHITELISTED_DOMAINS" \
drive_sharing_whitelisted_domains "partner1.com,partner2.com" \
drive_allow_file_requests false \
drive_shared_drive_creation "ADMIN_ONLY" \
drive_default_link_sharing "RESTRICTED"
# 配置共享告警
gam create alert \
name "外部共享告警" \
type "drive_external_share" \
condition "shared_outside_domain=true AND file_type IN ('spreadsheet','document','presentation')" \
action "notify_admin security-team@corp.com"
# 审计当前外部共享
gam all users print filelist \
fields id,name,owners,permissions \
query "visibility='anyoneWithLink' or visibility='anyoneCanFind'" \
> external_shares_audit.csv
echo "需要审查的外部共享:"
wc -l < external_shares_audit.csv
# 配置 Google Groups 安全
gam update org "/" settings \
groups_external_members false \
groups_external_posting false \
groups_creation "ADMIN_ONLY" \
groups_allow_external_invitations false
| 术语 | 定义 |
|---|---|
| 高级保护计划(APP) | Google 最强大的账户安全,要求使用 FIDO2 安全密钥、阻止第三方应用访问,以及增强的账户恢复身份验证 |
| 上下文感知访问 | 在授予访问 Google Workspace 应用程序之前评估设备状态、位置和用户身份的安全策略框架 |
| DMARC | 基于域的消息认证、报告和合规协议,通过验证 SPF 和 DKIM 对齐来防止电子邮件域欺骗 |
| DLP 规则 | 扫描 Gmail、Drive 和 Chat 中内容以查找敏感数据模式,并触发阻止、隔离或警告操作的数据丢失防护策略 |
| OAuth 应用白名单 | 管理员控制,限制哪些第三方应用可以通过 Google OAuth API 范围访问组织数据 |
| 两步验证(2SV) | Google 的多因素认证实现,支持安全密钥、手机提示、TOTP 和备份码作为第二因素 |
背景:收购后安全审计发现,被收购公司的 Google Workspace 没有 MFA 强制执行,外部共享开放,没有 DLP 策略,多个未授权的 OAuth 应用正在访问用户数据。
处理方式:
注意事项:
GOOGLE WORKSPACE 安全评估报告
=============================================
租户: corp.com
许可证: Enterprise Plus
用户总数: 3,847
组织单元: 12
认证安全
2SV 已强制执行: 是(所有 OU)
2SV 注册: 3,712 / 3,847 (96.5%)
仅限安全密钥: 执行 OU(47 位用户)
高级保护: 3 个超级管理员账户
超级管理员数量: 3(在推荐范围内)
电子邮件认证
SPF: 已配置(硬失败:-all)
DKIM: 已配置(2048 位,选择器:google)
DMARC: 已强制执行(p=reject,100%)
反钓鱼: 所有保护已启用
反欺骗: 已启用(域 + 员工姓名)
数据保护
DLP 规则活跃: 7
PII 检测: SSN、信用卡、护照
内容标签: 机密、受限
自定义模式: 3 条组织特定规则
DLP 违规(30 天):89(67 已阻止,22 已警告)
应用控制
第三方应用策略: 已阻止(白名单模式)
已批准应用: 12
未授权令牌: 0(全部已撤销)
API 范围限制: 已启用
共享控制
外部共享: 受限(仅限白名单域)
公共链接共享: 已禁用
外部组成员: 已禁用
共享驱动器创建: 仅限管理员
npx claudepluginhub killvxk/cybersecurity-skills-zhImplements Google Workspace security hardening: admin console configuration, MFA enforcement, DLP, email auth (SPF/DKIM/DMARC), OAuth controls, and external sharing restrictions.
Implements Google Workspace security hardening: admin console configuration, MFA enforcement, DLP, email auth (SPF/DKIM/DMARC), OAuth controls, and external sharing restrictions.
Implements Google Workspace admin security hardening: phishing-resistant MFA, DLP policies, SPF/DKIM/DMARC email auth, OAuth app controls, external sharing restrictions. For enterprise hardening and CIS compliance.