关于 supabase-audit-auth-config
此技能分析 Supabase 项目的认证配置,适用于上线前检查及认证安全审计。它通过公开 API 检查邮箱和手机号认证、OAuth 提供方、注册状态、邮箱确认及密码要求,并提供风险检查项与修复建议。
主要功能
- 01检查邮箱和手机号认证设置
- 02识别启用的 OAuth 提供方
- 03检查注册开放状态与邮箱确认
- 04分析密码要求和认证风险
- 05逐步记录发现并保存配置证据
适用场景
- 01上线前审查认证设置
- 02确认注册是否开放及提供方配置
- 03检查邮箱确认与密码策略
- 04记录认证配置问题以便修复
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ yoanbernabeu/ supabase-pentest-skills --skill supabase-audit-auth-config安装后在 Claude Code 中输入/supabase-audit-auth-config确认已加载。
详细介绍
身份验证配置审计
🔴 严重:必须渐进式更新文件
必须边执行边写入上下文文件,而不是只在最后写入。
- 每分析完一项设置,立即写入
.sb-pentest-context.json- 每次测试前后都要记录到
.sb-pentest-audit.log- 不要等到技能执行完毕才更新文件
- 如果技能崩溃或中断,之前的所有发现都必须已经保存
这不是可选项。未能渐进式写入属于严重错误。
此技能用于分析 Supabase 项目的身份验证配置。
适用场景
- 检查身份验证安全设置
- 在部署到生产环境之前
- 审计与身份验证相关的漏洞时
- 作为全面安全审查的一部分
前提条件
- 已获取 Supabase URL 和 anon key
- 已完成检测
身份验证端点
Supabase Auth(GoTrue)提供以下端点:
https://[project].supabase.co/auth/v1/
| 端点 | 用途 |
|---|---|
/auth/v1/settings | 公开设置(有限) |
/auth/v1/signup | 用户注册 |
/auth/v1/token | 身份验证 |
/auth/v1/user | 当前用户信息 |
/auth/v1/recover | 密码恢复 |
可检测的内容
通过公开 API,我们可以检测:
| 设置 | 检测方法 |
|---|---|
| 是否启用电子邮件身份验证 | 尝试注册 |
| 是否启用手机号身份验证 | 检查设置 |
| OAuth 提供商 | 检查设置 |
| 是否禁用注册 | 尝试注册 |
| 电子邮件确认 | 注册响应 |
| 密码要求 | 错误消息 |
用法
基本身份验证审计
Audit authentication configuration
检查特定功能
Check if signup is open and what providers are enabled
输出格式
═══════════════════════════════════════════════════════════
AUTHENTICATION CONFIGURATION AUDIT
═══════════════════════════════════════════════════════════
Project: abc123def.supabase.co
Auth Endpoint: https://abc123def.supabase.co/auth/v1/
─────────────────────────────────────────────────────────
Authentication Methods
─────────────────────────────────────────────────────────
Email/Password: ✅ Enabled
├── Signup: ✅ Open (anyone can register)
├── Email Confirmation: ❌ NOT REQUIRED ← P1 Issue
├── Password Min Length: 6 characters ← P2 Consider longer
└── Secure Password Check: Unknown
Phone/SMS: ✅ Enabled
└── Provider: Twilio
Magic Link: ✅ Enabled
└── OTP Expiry: 300 seconds (5 min)
OAuth Providers Detected: 3
├── Google: ✅ Enabled
├── GitHub: ✅ Enabled
└── Discord: ✅ Enabled
Anonymous Auth: ✅ Enabled ← Review if intended
─────────────────────────────────────────────────────────
Security Settings
─────────────────────────────────────────────────────────
Rate Limiting:
├── Signup: 3/hour per IP (good)
├── Token: 30/hour per IP (good)
└── Recovery: 3/hour per IP (good)
Session Configuration:
├── JWT Expiry: 3600 seconds (1 hour)
├── Refresh Token Rotation: Unknown
└── Inactivity Timeout: Unknown
Security Headers:
├── CORS: Configured
├── Allowed Origins: * (wildcard) ← P2 Consider restricting
└── Credentials: Allowed
─────────────────────────────────────────────────────────
Findings
─────────────────────────────────────────────────────────
🟠 P1: Email Confirmation Disabled
Issue: Users can signup and immediately access the app
without verifying their email address.
Risks:
├── Fake accounts with invalid emails
├── Typosquatting ([email protected])
├── No verified communication channel
└── Potential for abuse
Recommendation:
Supabase Dashboard → Authentication → Email Templates
→ Enable "Confirm email"
─────────────────────────────────────────────────────────
🟡 P2: Short Minimum Password Length
Issue: Minimum password length is 6 characters.
Recommendation: Increase to 8-12 characters minimum.
Supabase Dashboard → Authentication → Settings
→ Minimum password length
─────────────────────────────────────────────────────────
🟡 P2: Wildcard CORS Origin
Issue: CORS allows requests from any origin (*).
Recommendation: Restrict to your domains only.
Supabase Dashboard → Authentication → URL Configuration
→ Site URL and Redirect URLs
─────────────────────────────────────────────────────────
ℹ️ INFO: Anonymous Auth Enabled
Note: Anonymous authentication is enabled.
This is fine if intentional (guest access).
Review if you expect all users to be authenticated.
─────────────────────────────────────────────────────────
Summary
─────────────────────────────────────────────────────────
Auth Methods: 5 enabled
OAuth Providers: 3
Findings:
├── P1 (High): 1 - Email confirmation disabled
├── P2 (Medium): 2 - Password length, CORS
└── Info: 1 - Anonymous auth enabled
Recommended Actions:
1. Enable email confirmation
2. Increase minimum password length
3. Restrict CORS to specific domains
4. Review if anonymous auth is needed
═══════════════════════════════════════════════════════════
安全检查清单
电子邮件身份验证
| 设置 | 建议 | 配置不当的风险 |
|---|---|---|
| 电子邮件确认 | ✅ 必须 | 虚假账号 |
| 密码长度 | ≥8 个字符 | 弱密码 |
| 密码复杂度 | 启用 | 容易被猜到 |
| 速率限制 | 启用 | 暴力破解 |
OAuth 配置
| 设置 | 建议 | 配置不当的风险 |
|---|---|---|
| 仅使用已验证的提供商 | 是 | 账号被接管 |
| 使用正确的重定向 URL | 指定 URL | OAuth 重定向攻击 |
| 状态参数 | 启用 | CSRF 攻击 |
会话安全
| 设置 | 建议 | 配置不当的风险 |
|---|---|---|
| JWT 有效期较短 | 不超过 1 小时 | 令牌被盗 |
| 刷新令牌轮换 | 启用 | 令牌重用 |
| 安全 Cookie 标志 | HttpOnly、Secure、SameSite | XSS、CSRF |
上下文输出
{
"auth_config": {
"timestamp": "2025-01-31T12:30:00Z",
"methods": {
"email": {
"enabled": true,
"signup_open": true,
"email_confirmation": false,
"min_password_length": 6
},
"phone": {
"enabled": true,
"provider": "twilio"
},
"magic_link": {
"enabled": true,
"otp_expiry": 300
},
"oauth": {
"enabled": true,
"providers": ["google", "github", "discord"]
},
"anonymous": {
"enabled": true
}
},
"findings": [
{
"severity": "P1",
"issue": "Email confirmation disabled",
"recommendation": "Enable email confirmation in dashboard"
}
]
}
}
常见身份验证漏洞
1. 未启用电子邮件确认
// User can signup with any email
const { data, error } = await supabase.auth.signUp({
email: '[email protected]', // No verification needed
password: 'password123'
})
// User is immediately authenticated
2. 密码策略薄弱
// Weak password accepted
await supabase.auth.signUp({
email: '[email protected]',
password: '123456' // Accepted with min length 6
})
3. 不需要时仍开放注册
如果你的应用只应允许由管理员创建用户:
-- Disable public signup via dashboard
-- Or use invite-only flow
修复示例
启用电子邮件确认
- Supabase Dashboard → Authentication → Email Templates
- 启用“Confirm email”
- 自定义确认邮件模板
- 在应用中处理未确认的用户
强化密码要求
- Dashboard → Authentication → Settings
- 将最小长度设为 8 个字符以上
- 考虑启用密码强度检查
限制 CORS
- Dashboard → Authentication → URL Configuration
- 设置指定的 Site URL
- 仅将你的域名添加到 Redirect URLs
- 移除通配符条目
强制要求:渐进式更新上下文文件
⚠️ 此技能必须在执行过程中渐进式更新跟踪文件,而不是只在最后更新。
关键规则:边执行边写入
不要在最后批量写入。应按以下步骤执行:
- 检查每种身份验证方式之前 → 将操作记录到
.sb-pentest-audit.log - 分析每项配置之后 → 立即更新
.sb-pentest-context.json - 发现每项问题之后 → 立即记录严重程度
这样可以确保即使技能被中断、崩溃或超时,到那时为止的所有发现都已保留。
必须执行的操作(逐步进行)
-
使用结果更新
.sb-pentest-context.json:{ "auth_config": { "timestamp": "...", "methods": { ... }, "findings": [ ... ] } } -
记录到
.sb-pentest-audit.log:[TIMESTAMP] [supabase-audit-auth-config] [START] Auditing auth configuration [TIMESTAMP] [supabase-audit-auth-config] [FINDING] P1: Email confirmation disabled [TIMESTAMP] [supabase-audit-auth-config] [CONTEXT_UPDATED] .sb-pentest-context.json updated -
如果文件不存在,请在写入前创建它们。
不更新上下文文件是不可接受的。
必须:收集证据
📁 证据目录: .sb-pentest-evidence/05-auth-audit/
需要创建的证据文件
| 文件 | 内容 |
|---|---|
auth-settings.json | 完整的身份验证配置 |
证据格式
{
"evidence_id": "AUTH-CFG-001",
"timestamp": "2025-01-31T10:50:00Z",
"category": "auth-audit",
"type": "auth_configuration",
"endpoint": "https://abc123def.supabase.co/auth/v1/",
"configuration": {
"email_auth": {
"enabled": true,
"signup_open": true,
"email_confirmation_required": false,
"min_password_length": 6
},
"phone_auth": {
"enabled": true,
"provider": "twilio"
},
"oauth_providers": ["google", "github", "discord"],
"anonymous_auth": true
},
"security_settings": {
"rate_limiting": {
"signup": "3/hour",
"token": "30/hour",
"recovery": "3/hour"
},
"jwt_expiry": 3600,
"cors_origins": "*"
},
"findings": [
{
"severity": "P1",
"issue": "Email confirmation disabled",
"impact": "Users can signup without verifying email",
"recommendation": "Enable email confirmation"
},
{
"severity": "P2",
"issue": "Weak password policy",
"impact": "Minimum 6 characters allows weak passwords",
"recommendation": "Increase to 8+ characters"
}
]
}
添加到 curl-commands.sh
# === AUTH CONFIGURATION TESTS ===
# Test signup availability
curl -X POST "$SUPABASE_URL/auth/v1/signup" \
-H "apikey: $ANON_KEY" \
-H "Content-Type: application/json" \
-d '{"email": "[email protected]", "password": "test123456"}'
# Test password policy (weak password)
curl -X POST "$SUPABASE_URL/auth/v1/signup" \
-H "apikey: $ANON_KEY" \
-H "Content-Type: application/json" \
-d '{"email": "[email protected]", "password": "123456"}'
相关技能
supabase-audit-auth-signup— 测试注册流程supabase-audit-auth-users— 测试用户枚举supabase-audit-rls— 身份验证用户需要受到 RLS 保护
评论
支持 Markdown