mcpField
S
supabase-report

supabase-report

github.com/yoanbernabeu安全71501 次安装39 周前更新
代码仓库

关于 supabase-report

用于将 Supabase 安全审计发现整理为 Markdown 报告的技能,面向需要记录风险并制定修复计划的团队。它依赖审计上下文文件,并支持定制报告章节和输出格式。

主要功能

  1. 01生成管理层摘要与安全评分
  2. 02按严重级别整理审计发现
  3. 03提供组件分析与修复计划
  4. 04支持自定义章节和输出格式
  5. 05渐进更新审计日志与上下文文件

适用场景

  1. 01汇总已完成的 Supabase 安全审计
  2. 02向相关方呈现风险和修复优先级
  3. 03生成用于合规和审计留档的报告

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/yoanbernabeu/supabase-pentest-skills --skill supabase-report

安装后在 Claude Code 中输入/supabase-report确认已加载。

详细介绍

安全报告生成器

🔴 严重:必须渐进式更新文件

必须在处理过程中写入上下文文件,不能只在最后写入。

  • 处理每个部分时,立即写入 .sb-pentest-audit.log
  • 逐步更新 .sb-pentest-context.json 中的报告元数据
  • 不要等到整个报告生成后才更新文件
  • 如果技能崩溃或中断,部分进度必须已经保存

这不是可选项。未能逐步写入属于严重错误。

此技能会根据所有已收集的发现生成一份全面的 Markdown 安全审计报告。

何时使用此技能

  • 完成安全审计阶段后
  • 为利益相关方记录发现
  • 制定可执行的修复计划
  • 用于合规和审计追踪

前提条件

  • 已完成审计阶段(上下文文件已填充)
  • 已在 .sb-pentest-context.json 中收集发现

报告结构

生成的报告包括:

  1. 执行摘要 — 面向管理层的高层概述
  2. 安全评分 — 量化风险评估
  3. 严重发现(P0) — 需要立即采取行动
  4. 高危发现(P1) — 尽快处理
  5. 中危发现(P2) — 制定处理计划
  6. 详细分析 — 按组件进行拆解
  7. 修复计划 — 按优先级排列的待办事项
  8. 附录 — 技术细节、方法

用法

生成报告
Generate security report from audit findings
自定义报告名称
Generate report as security-audit-2025-01.md
指定部分
Generate executive summary only

输出格式

此技能会生成 supabase-audit-report.md:

# Supabase Security Audit Report

**Target:** https://myapp.example.com
**Project:** abc123def.supabase.co
**Date:** January 31, 2025
**Auditor:** Internal Security Team

---

## Executive Summary

### Overview

This security audit identified **12 vulnerabilities** across the Supabase implementation, including **3 critical (P0)** issues requiring immediate attention.

### Key Findings

| Severity | Count | Status |
|----------|-------|--------|
| 🔴 P0 (Critical) | 3 | Immediate action required |
| 🟠 P1 (High) | 4 | Address within 7 days |
| 🟡 P2 (Medium) | 5 | Address within 30 days |

### Security Score

**Score: 35/100 (Grade: D)**

The application has significant security gaps that expose user data and allow privilege escalation. Critical issues must be addressed before the application can be considered secure.

### Most Critical Issues

1. **Service Role Key Exposed** — Full database access possible
2. **Database Backups Public** — All data downloadable
3. **Admin Function No Auth** — Any user can access admin features

### Recommended Actions

1. ⚡ **Immediate (Today):**
   - Rotate service role key
   - Make backup bucket private
   - Add admin role verification

2. 🔜 **This Week:**
   - Enable RLS on all tables
   - Enable email confirmation
   - Fix IDOR in Edge Functions

3. 📅 **This Month:**
   - Strengthen password policy
   - Restrict CORS origins
   - Add rate limiting to functions

---

## Critical Findings (P0)

### P0-001: Service Role Key Exposed in Client Code

**Severity:** 🔴 Critical
**Component:** Key Management
**CVSS:** 9.8 (Critical)

#### Description

The Supabase service_role key was found in client-side JavaScript code. This key bypasses all Row Level Security policies and provides full database access.

#### Location

文件:/static/js/admin.chunk.js 行:89 代码:const SUPABASE_KEY = 'eyJhbGciOiJIUzI1NiI...'


#### Impact

- Full read/write access to all database tables
- Bypass of all RLS policies
- Access to auth.users table (all user data)
- Ability to delete or modify any data

#### Proof of Concept

```bash
curl 'https://abc123def.supabase.co/rest/v1/users' \
  -H 'apikey: [service_role_key]' \
  -H 'Authorization: Bearer [service_role_key]'

# Returns ALL users with full data
修复

立即处理:

  1. 在 Supabase Dashboard 中轮换服务角色密钥
    • Settings → API → Regenerate service_role key
  2. 从客户端代码中移除此密钥
  3. 重新部署应用

长期处理:

// Move privileged operations to Edge Functions
// supabase/functions/admin-action/index.ts

import { createClient } from '@supabase/supabase-js'

Deno.serve(async (req) => {
  // Service key only on server
  const supabase = createClient(
    Deno.env.get('SUPABASE_URL')!,
    Deno.env.get('SUPABASE_SERVICE_ROLE_KEY')!
  )

  // Verify caller is admin before proceeding
  // ...
})

文档:


P0-002:数据库备份可公开访问

严重性: 🔴 严重 组件: Storage CVSS: 9.1(严重)

描述

名为“backups”的存储桶被配置为公开,导致数据库转储、用户导出数据和环境密钥暴露。

暴露的文件
文件大小内容
db-backup-2025-01-30.sql125MB完整数据库转储
users-export.csv2.3MB包含个人身份信息的所有用户数据
secrets.env1KBAPI 密钥和密码
影响
  • 完整的数据泄露(所有数据库内容)
  • 第三方服务的凭据暴露
  • 用户个人身份信息暴露(电子邮件、姓名等)
修复

立即处理:

-- Make bucket private
UPDATE storage.buckets
SET public = false
WHERE name = 'backups';

-- Delete or move files
-- Consider incident response procedures

轮换凭据:

  • Stripe API 密钥
  • 数据库密码
  • JWT 密钥
  • secrets.env 中的任何其他密钥

P0-003:Admin Edge Function 权限提升

严重性: 🔴 严重 组件: Edge Functions CVSS: 8.8(高危)

描述

任何已通过身份验证的用户都可以访问 /functions/v1/admin-panel Edge Function,且无需验证角色。

[... 其他 P0 发现 ...]


高危发现(P1)

P1-001:已禁用电子邮件确认

严重性: 🟠 高危 组件: Authentication

[... P1 发现 ...]


中危发现(P2)

P2-001:密码策略薄弱

严重性: 🟡 中危 组件: Authentication

[... P2 发现 ...]


按组件进行详细分析

API 安全
表RLS访问级别状态
users❌完全读取🔴 P0
orders✅无✅
posts✅仅已发布内容✅
存储安全
存储桶公开敏感文件状态
avatars是否✅
backups是是(45 个文件)🔴 P0
身份验证
设置当前值建议值状态
邮箱确认已禁用已启用🟠 P1
密码最小长度68+🟡 P2

整改计划

阶段 1:严重(立即)
ID操作负责人截止时间
P0-001轮换服务密钥DevOps今天
P0-002将备份设为私有DevOps今天
P0-003添加管理员角色检查Backend今天
阶段 2:高优先级(本周)
ID操作负责人截止时间
P1-001启用邮箱确认Backend3 天
P1-002修复 get-user-data 中的 IDOR 漏洞Backend3 天
阶段 3:中优先级(本月)
ID操作负责人截止时间
P2-001加强密码策略Backend14 天
P2-002限制 CORS 来源DevOps14 天

附录

A. 方法

本次审计使用 Supabase Pentest Skills 工具包完成,其中包括:

  • 对客户端代码进行被动侦察
  • 使用 anon 和 service 密钥测试 API 端点
  • 枚举存储桶并测试访问权限
  • 分析身份验证流程
  • 测试实时频道订阅
B. 使用的工具
  • supabase-pentest-skills v1.0.0
  • 用于 API 测试的 curl
  • 用于分析客户端代码的浏览器 DevTools
C. 审计范围
  • 目标 URL:https://myapp.example.com
  • Supabase 项目:abc123def
  • 测试的组件:API、Storage、Auth、Realtime、Edge Functions
  • 排除项:无
D. 审计日志

完整审计日志见 .sb-pentest-audit.log


报告由 supabase-pentest-skills 生成 审计完成时间: 2025 年 1 月 31 日 15:00 UTC


## Score Calculation

The security score is calculated based on:

| Factor | Weight | Calculation |
|--------|--------|-------------|
| P0 findings | -25 per issue | Critical vulnerabilities |
| P1 findings | -10 per issue | High severity issues |
| P2 findings | -5 per issue | Medium severity issues |
| RLS coverage | +10 if 100% | All tables have RLS |
| Auth hardening | +10 | Email confirm, strong passwords |
| Base score | 100 | Starting point |

### Grade Scale

| Score | Grade | Description |
|-------|-------|-------------|
| 90-100 | A | Excellent security posture |
| 80-89 | B | Good, minor improvements needed |
| 70-79 | C | Acceptable, address issues |
| 60-69 | D | Poor, significant issues |
| 0-59 | F | Critical, immediate action needed |

## Context Input

The report generator reads from `.sb-pentest-context.json`:

```json
{
  "target_url": "https://myapp.example.com",
  "supabase": {
    "project_url": "https://abc123def.supabase.co",
    "project_ref": "abc123def"
  },
  "findings": [
    {
      "id": "P0-001",
      "severity": "P0",
      "component": "keys",
      "title": "Service Role Key Exposed",
      "description": "...",
      "location": "...",
      "remediation": "..."
    }
  ],
  "audit_completed": "2025-01-31T15:00:00Z"
}

自定义报告

包含/排除部分
Generate report without appendix
Generate report with executive summary only
不同格式
Generate report in JSON format
Generate report summary as HTML

必须遵循:上下文文件依赖项

⚠️ 此技能要求跟踪文件已正确填充。

前提条件

生成报告前,请确保:

  1. .sb-pentest-context.json 已存在,且包含审计技能发现的问题
  2. .sb-pentest-audit.log 已存在,且记录了带时间戳的操作
  3. 所有相关审计技能均已更新这些文件
缺少上下文文件时

如果上下文文件缺失或为空:

  1. 不要生成空报告
  2. 告知用户必须先运行审计技能
  3. 建议运行 supabase-pentest 以完成完整审计
报告生成输出

生成报告后,此技能必须:

  1. 记录到 .sb-pentest-audit.log:

    [TIMESTAMP] [supabase-report] [START] Generating security report
    [TIMESTAMP] [supabase-report] [SUCCESS] Report generated: supabase-audit-report.md
    [TIMESTAMP] [supabase-report] [CONTEXT_UPDATED] Report generation logged
    
  2. 使用报告元数据更新 .sb-pentest-context.json:

    {
      "report": {
        "generated_at": "...",
        "filename": "supabase-audit-report.md",
        "findings_count": { "p0": 3, "p1": 4, "p2": 5 }
      }
    }
    

不更新上下文文件是不可接受的。

相关技能

  • supabase-report-compare — 与之前的报告进行比较
  • supabase-pentest — 先运行完整审计
  • supabase-help — 列出所有可用技能

评论

支持 Markdown