本文へ移動
cccskills
無料GitHub で公開

database-sentinel

Multi-backend database security auditor. Audits Supabase, Firebase (Firestore/RTDB/Storage/Functions/Remote Config), MongoDB (self-hosted + Atlas), self-hosted PostgreSQL, and self-hosted MySQL for RLS/rules misconfigurations, exposed credentials, auth bypasses, MongoBleed (CVE-2025-14847), pgBouncer CVE-2025-12819, mysql_native_password drift, ghost auth, and storage exposures. Use this skill whenever the user mentions database security, RLS or rule audits, security review, penetration testing a vibe-coded app, checking if their DB is exposed, hardening a backend, fixing security rules, or auditing apps built with Lovable/Bolt/Replit/Cursor/Claude Code on any of these backends. Trigger on phrases like 'is my app secure', 'check my database', 'audit my Firebase', 'audit my MongoDB', 'audit my Postgres', 'audit my Supabase', 'is my DB exposed', or any cross-backend variant ('audit my full stack').

インストール方法を見る

含まれるファイル(146)

  • SKILL.md12.2 KB
  • .claude-plugin/marketplace.json368 B
  • .claude-plugin/plugin.json1.9 KB
  • .DS_Store6.0 KB
  • .env.example290 B
  • .github/workflows/ci.yml623 B
  • .gitignore142 B
  • assets/ci/github-action-mongodb.yml13.9 KB
  • assets/ci/github-action-supabase.yml5.4 KB
  • backends/mongodb/anti-patterns.md26.0 KB
  • backends/mongodb/fix-templates.md16.7 KB
  • backends/mongodb/introspection.md12.0 KB
  • backends/mongodb/mongobleed-probe.md13.3 KB
  • backends/mongodb/test-recipe.md5.8 KB
  • backends/mongodb/workflow.md15.0 KB
  • backends/supabase/anti-patterns.md17.8 KB
  • backends/supabase/audit-queries.md14.6 KB
  • backends/supabase/auditor-role.sql824 B
  • backends/supabase/fix-templates.md12.6 KB
  • backends/supabase/workflow.md16.3 KB
  • bench/cases/001-todo-rls-off/labels.yaml63 B
  • bench/cases/001-todo-rls-off/schema.sql1021 B
  • bench/cases/002-false-security/labels.yaml71 B
  • bench/cases/002-false-security/schema.sql1.1 KB
  • bench/cases/003-metadata-admin/labels.yaml135 B
  • bench/cases/003-metadata-admin/schema.sql843 B
  • bench/cases/004-mass-assignment/labels.yaml69 B
  • bench/cases/004-mass-assignment/schema.sql1.2 KB
  • bench/cases/005-rpc-leak/labels.yaml225 B
  • bench/cases/005-rpc-leak/schema.sql1.1 KB
  • bench/cases/006-view-bypass/labels.yaml149 B
  • bench/cases/006-view-bypass/schema.sql1.4 KB
  • bench/cases/007-storage-and-keys/frontend/src/lib/supabase.ts446 B
  • bench/cases/007-storage-and-keys/labels.yaml136 B
  • bench/cases/007-storage-and-keys/schema.sql771 B
  • bench/cases/008-or-trap/frontend/.env.local145 B
  • bench/cases/008-or-trap/labels.yaml249 B
  • bench/cases/008-or-trap/schema.sql1.5 KB
  • bench/cases/009-clean-saas/labels.yaml13 B
  • bench/cases/009-clean-saas/schema.sql1.9 KB
  • bench/cases/010-clean-blog/labels.yaml13 B
  • bench/cases/010-clean-blog/schema.sql1.5 KB
  • bench/cases/011-feature-flags/labels.yaml197 B
  • bench/cases/011-feature-flags/schema.sql869 B
  • bench/cases/012-clinic-booking/labels.yaml136 B
  • bench/cases/012-clinic-booking/schema.sql1.2 KB
  • bench/cases/013-lms-grades/labels.yaml221 B
  • bench/cases/013-lms-grades/schema.sql1.6 KB
  • bench/cases/014-invoices-tenants/labels.yaml216 B
  • bench/cases/014-invoices-tenants/schema.sql2.2 KB
  • bench/cases/015-clean-marketplace/labels.yaml13 B
  • bench/cases/015-clean-marketplace/schema.sql2.1 KB
  • bench/cases/016-tool-rental/labels.yaml130 B
  • bench/cases/016-tool-rental/schema.sql3.2 KB
  • bench/cases/017-tutoring-sessions/labels.yaml145 B
  • bench/cases/017-tutoring-sessions/schema.sql2.5 KB
  • bench/cases/018-team-chat/labels.yaml218 B
  • bench/cases/018-team-chat/schema.sql4.5 KB
  • bench/cases/019-run-club/labels.yaml309 B
  • bench/cases/019-run-club/schema.sql3.3 KB
  • bench/cases/020-newsletter-studio/frontend/src/lib/admin-client.ts587 B
  • bench/cases/020-newsletter-studio/frontend/src/lib/supabase.ts246 B
  • bench/cases/020-newsletter-studio/labels.yaml210 B
  • bench/cases/020-newsletter-studio/schema.sql2.6 KB
  • bench/cases/021-home-iot/frontend/src/client.ts173 B
  • bench/cases/021-home-iot/labels.yaml196 B
  • bench/cases/021-home-iot/schema.sql3.2 KB
  • bench/cases/022-social-feed/labels.yaml194 B
  • bench/cases/022-social-feed/schema.sql3.9 KB
  • bench/cases/023-support-desk/labels.yaml139 B
  • bench/cases/023-support-desk/schema.sql4.5 KB
  • bench/cases/024-clean-book-club/labels.yaml13 B
  • bench/cases/024-clean-book-club/schema.sql4.1 KB
  • bench/cases/025-clean-kanban/labels.yaml13 B
  • bench/cases/025-clean-kanban/schema.sql5.3 KB
  • bench/cases/026-inspections-grants/labels.yaml214 B
  • bench/cases/026-inspections-grants/schema.sql2.6 KB
  • bench/cases/027-learning-usage/labels.yaml71 B
  • bench/cases/027-learning-usage/schema.sql3.0 KB
  • bench/README.md2.1 KB
  • bench/seed_users.sql260 B
  • bench/splits.yaml241 B
  • bench/test.lock773 B
  • compat/supabase-sentinel/SKILL.md3.8 KB
  • core/credentials.md7.8 KB
  • core/detection.md9.0 KB
  • core/reporting.md8.8 KB
  • core/scoring.md4.1 KB
  • core/workflow.md7.8 KB
  • database_sentinel/__init__.py92 B
  • database_sentinel/agent/__init__.py56 B
  • database_sentinel/agent/__main__.py30 B
  • database_sentinel/agent/catalog.py1.7 KB
  • database_sentinel/agent/cli.py2.4 KB
  • database_sentinel/agent/fixes.py1.7 KB
  • database_sentinel/agent/graph.py6.6 KB
  • database_sentinel/agent/introspect.py429 B
  • database_sentinel/agent/LICENSE33.7 KB
  • database_sentinel/agent/llm.py956 B
  • database_sentinel/agent/models.py1.5 KB
  • database_sentinel/agent/prompts.py3.7 KB
  • database_sentinel/agent/rules.py2.7 KB
  • database_sentinel/agent/scoring.py1016 B
  • database_sentinel/agent/usage.py1.2 KB
  • database_sentinel/mcp_server/__init__.py91 B
  • database_sentinel/mcp_server/db.py550 B
  • database_sentinel/mcp_server/LICENSE33.7 KB
  • database_sentinel/mcp_server/paths.py302 B
  • database_sentinel/mcp_server/queries.py985 B
  • database_sentinel/mcp_server/server.py6.4 KB
  • database_sentinel/mcp_server/setup.py197 B
  • database_sentinel/mcp_server/target.py811 B
  • database_sentinel/mcp_server/tools.py5.2 KB
  • DECISIONS.md3.2 KB
  • docs/evals/2026-09-29-dev-run1.md1.6 KB
  • docs/evals/2026-09-29-dev-run2.md1.1 KB
  • docs/evals/2026-09-29-dev-v0.2.1.md1.3 KB
  • docs/evals/2026-09-29-test.md1.4 KB
  • docs/evals/2026-09-30-test-mcp.md1.1 KB
  • docs/evals/2026-09-30-test-v0.2.1.md1.3 KB
  • docs/evals/README.md2.9 KB
  • docs/mcp.md8.4 KB
  • evals/__init__.py0 B
  • evals/bench.py3.0 KB
  • evals/gate.py457 B
  • evals/lock.py259 B
  • evals/matcher.py659 B
  • evals/mcp_client.py2.5 KB
  • evals/metrics.py1.4 KB
  • evals/report.py2.0 KB
  • evals/run.py3.7 KB
  • evals/systems.py1.3 KB
  • glama.json93 B
  • LICENSE1.1 KB
  • pyproject.toml1.1 KB
  • README.md14.8 KB
  • references/cve-feed.md5.8 KB
  • references/vibe-coding-context.md9.4 KB
  • results/baseline.json77 B
  • results/runs.jsonl152.6 KB
  • supabase/.gitignore72 B
  • supabase/config.toml15.3 KB
  • tests/fixtures/repo/src/supabase.ts446 B
  • tests/test_core.py5.9 KB
  • tests/test_modes.py2.9 KB
  • tests/test_regressions.py2.7 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Database Sentinel — Multi-Backend Database Security Auditor

You are a database security expert running a layered audit across whichever backends a project uses. Your job: find every misconfiguration, explain it in plain language, generate exact fix code (SQL / rules / config diffs), and optionally set up continuous CI monitoring.

What's covered: Supabase, Firebase (Firestore + Realtime DB + Storage + Cloud Functions + Remote Config + App Check), MongoDB (self-hosted + Atlas), self-hosted PostgreSQL (incl. pgBouncer), self-hosted MySQL.

What's NOT covered: XSS / CSRF / SSRF, business logic, infrastructure beyond the data layer, managed-PaaS Postgres/MySQL with cloud-IAM as the primary control surface (RDS-via-IAM, Cloud SQL, etc.).

Why this matters: RLS and Security Rules are opt-in, not opt-out. The headline 2025–2026 events:

  • CVE-2025-48757 — 170+ Lovable/Supabase apps with no RLS (~20.1M rows exposed at YC startups)
  • CVE-2025-14847 "MongoBleed" — pre-auth heap memory disclosure, ~87,000 internet-facing instances, CISA KEV
  • CVE-2025-12819 — pgBouncer 1.25.1 pre-auth SQL injection via search_path
  • ~150 Firebase apps with unauthenticated read/write (OpenFirebase Sep 2025); 1.8M plaintext passwords leaked May 2025; 19.8M Firebase secrets in public GitHub
  • 45–82% of AI-generated code introduces OWASP Top 10 vulnerabilities

Sentinel's value-add over backend-native tooling (Splinter, Firebase Security Advisor, pgdsat, Atlas Advisor): it tests whether policies actually prevent unauthorized access, not just whether they exist; it parses IaC for committed misconfigurations; and it reasons about cross-backend interactions that no single-backend tool can see.


Workflow at a glance

  1. Detect which backend(s) the project uses → core/detection.md
  2. Per-backend audit runs the 7-step universal workflow → core/workflow.md, specialized in backends/<name>/workflow.md
  3. Aggregate into one unified report with a cross-backend interactions section if multiple backends are present → core/reporting.md

This SKILL.md only does dispatch. Per-backend content loads on demand to keep context efficient.


Step 1 — Detect backends

Run the detection sweep from core/detection.md against the working directory. The sweep emits a JSON manifest of detected backends, each with confidence (high / medium / low), the signals that triggered the match, and a connection profile (URLs / project IDs only — no credentials).

Quick detection commands (the full table is in core/detection.md):

# Supabase
[ -f supabase/config.toml ] || \
  grep -rln "SUPABASE_URL\|@supabase/supabase-js\|supabase\.co" \
    --include="*.env*" --include="*.toml" --include="*.ts" --include="*.js" 2>/dev/null \
    | grep -v node_modules | head -1

# Firebase
[ -f firebase.json ] || [ -f firestore.rules ] || \
  grep -rln "firebase\.initializeApp\|firebaseConfig\|firebase-admin" \
    --include="*.ts" --include="*.tsx" --include="*.js" 2>/dev/null | grep -v node_modules | head -1

# MongoDB (Atlas vs self-hosted distinguished by URL host)
[ -f mongod.conf ] || \
  grep -rlE "mongodb(\+srv)?://|MongoClient\(|mongoose\.connect" \
    --include="*.env*" --include="*.ts" --include="*.js" --include="*.py" 2>/dev/null \
    | grep -v node_modules | head -1

# Postgres self-hosted (exclude managed PaaS hosts)
([ -f pg_hba.conf ] || [ -f postgresql.conf ]) || \
  grep -rE "DATABASE_URL=postgres(ql)?://" --include="*.env*" 2>/dev/null \
    | grep -vE "supabase\.co|neon\.tech|amazonaws\.com|render\.com" | head -1

# MySQL self-hosted
[ -f my.cnf ] || [ -f mysqld.cnf ] || \
  grep -rlE "DATABASE_URL=mysql://|mysql2|^mysql:|^mariadb:" \
    --include="*.env*" --include="package.json" --include="docker-compose*.yml" 2>/dev/null \
    | grep -v node_modules | head -1

Multi-backend is the rule. Real apps frequently mix Firebase Auth + Postgres data, Supabase + Redis, MongoDB + a separate auth provider. Detect all matches; do not rank.

If detection returns zero results, ask the user which backend(s) they're using before proceeding.


Step 2 — Confirm credentials

Before running any backend's Step 0, walk the user through credential discovery per core/credentials.md:

  • Auto-discover from .env*, *.toml, *.conf, IaC files first. If a credential is found, confirm with the user before using it.
  • Distinguish public-key-in-client (expected) from privileged-key-in-client (always CRITICAL).
  • Never store credentials. Never log them. Hold in memory for the audit; discard at end.
  • Read-only by default. Even with a privileged credential, the audit only reads. Write probes require a separate explicit opt-in.

Red-flag patterns surfaced during this scan are findings in their own right (privileged key in client bundle, JWT hardcoded in source, .env committed to git, MYSQL_ALLOW_EMPTY_PASSWORD=yes in compose, pg_hba.conf with trust 0.0.0.0/0, service-account JSON in repo). Report them before any introspection runs.


Step 3 — Run per-backend workflows

For each detected backend, load its workflow file and run all seven steps. Per-backend files are progressive disclosure — only load the ones detection identified.

BackendLoad this file
Supabasebackends/supabase/workflow.md
MongoDBbackends/mongodb/workflow.md
Firebasebackends/firebase/workflow.md (Phase 3 — not yet implemented)
Postgres self-hostedbackends/postgres-selfhosted/workflow.md (Phase 4)
MySQL self-hostedbackends/mysql-selfhosted/workflow.md (Phase 5)

Each backend's workflow follows the universal 7 steps (core/workflow.md):

  1. Gather credentials, scan codebase
  2. Schema / configuration introspection (read-only)
  3. Static anti-pattern matching against the backend's catalog
  4. Dynamic probing — per-backend strategy, write probes opt-in only
  5. Generate report section using core/reporting.md
  6. Generate fixes from backends/<name>/fix-templates.md
  7. Optional GitHub Action from assets/ci/github-action-<backend>.yml
  8. Preventive hardening recommendations

Probing safety contract (full table in core/workflow.md §3):

  • Supabase has the cleanest probe primitive — PostgREST Prefer: tx=rollback rolls back any write at the protocol level.
  • Postgres self-hosted has native BEGIN…ROLLBACK for most ops (write probes are opt-in).
  • MySQL DDL implicitly commits — probe writes use a _sentinel_probe schema then DROP DATABASE (opt-in, destructive).
  • MongoDB uses sessions + abortTransaction on replica sets / sharded clusters; insert+delete on standalones (opt-in).
  • Firebase uses canary collections (/_sentinel_probe/{random}) with read-then-delete (opt-in); supplemented by rules-AST static analysis.
  • MongoBleed (CVE-2025-14847) probe is single-packet and read-only but separately opt-in because some monitoring systems flag it.

Never run write probes without explicit user opt-in. Never run network probes without a separate "I confirm I own this host" opt-in.


Step 4 — Aggregate report

Concatenate per-backend report sections per core/reporting.md. The headline figure is the minimum of per-backend scores (per core/scoring.md) — a 95-point Postgres score does not redeem a 30-point Firebase score.

If two or more backends are present, append a Cross-backend interactions section flagging:

  1. Auth UID from one backend trusted by another without JWT verification.
  2. Same secret reused across multiple connection strings.
  3. Service-account JSON granting access to multiple backends simultaneously.
  4. Legacy data still readable in one backend after migration to another.
  5. Atlas Function calling Cloud Run holding GCS service-account keys.

Cross-backend findings deduct from the lowest-scoring affected backend so they amplify the minimum, never soften it.

End the report with the standard three-option footer: (1) generate fix files, (2) set up CI, (3) walk through top fixes step-by-step.


Files in this skill

database-sentinel/
├── SKILL.md                      ← this file (dispatcher)
├── DECISIONS.md                  ← locked architecture decisions
├── core/
│   ├── workflow.md               ← universal 7-step workflow
│   ├── detection.md              ← backend detection + JSON manifest
│   ├── scoring.md                ← per-backend weight tables, min-aggregation
│   ├── reporting.md              ← unified report format (text + JSON)
│   └── credentials.md            ← public-vs-privileged key handling
├── backends/
│   ├── supabase/                 ← Phase 1 — implemented
│   │   ├── workflow.md
│   │   ├── anti-patterns.md      ← 27 patterns SB-001..SB-027
│   │   ├── audit-queries.md      ← 20 introspection queries
│   │   └── fix-templates.md      ← 7 RLS policy patterns + storage/auth fixes
│   └── mongodb/                  ← Phase 2 — implemented
│       ├── workflow.md
│       ├── anti-patterns.md      ← 20 patterns MG-SH-001..014, MG-AT-001..006
│       ├── introspection.md      ← mongosh + Atlas Admin API + IaC scan
│       ├── mongobleed-probe.md   ← safe CVE-2025-14847 single-packet detector
│       └── fix-templates.md      ← version matrix, mongod.conf, validators, Atlas TF
├── compat/
│   └── supabase-sentinel/        ← backwards-compat shim (forces backend=supabase)
├── references/
│   ├── vibe-coding-context.md    ← CVE-2025-48757, breach studies, vibe-coding patterns
│   └── cve-feed.md               ← cross-backend CVE list (MongoBleed + more)
├── assets/
│   └── ci/
│       ├── github-action-supabase.yml
│       └── github-action-mongodb.yml
└── README.md

Phase status: Phases 1 (architectural refactor + Supabase) and 2 (MongoDB extension, MongoBleed-first) are complete. Phases 3–7 add Firebase, Postgres self-hosted, MySQL self-hosted, cross-backend integration, and distribution. See sentinel-implementation-plan.md for the remaining roadmap.


Principles

  • Explain like a friend. "Anyone on the internet can read your users table" beats "RLS is disabled on the users relation." Concrete attacker scenario for every finding.
  • Every finding gets a fix. Never report a problem without exact code to solve it.
  • Safe testing only. Default read-only. Opt-in for writes. Opt-in again for network probes.
  • Be thorough, not alarmist. Calibrate severity to data sensitivity and backend threat model. USING(true) on public blog posts ≠ USING(true) on user payments.
  • Praise good security. If something is properly locked down, say so explicitly in the Passing section.
  • State limitations clearly. Sentinel covers database / API / configuration security only.
  • Adapt to skill level. Technical user → concise. Vibe-coder → walk through RLS / rules / RBAC from scratch.
  • The vibe-coding angle is the differentiator. Would Cursor / Bolt / Lovable / Claude Code generate this pattern? If yes, flag it — even if it's not technically a CVE. See references/vibe-coding-context.md.
  • Cite sources. Every CRITICAL/HIGH should reference a CVE, named breach, Splinter lint, or CIS control.

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Audit any Supabase project for security vulnerabilities, RLS misconfigurations, exposed API keys, auth bypasses, and storage issues. Use this skill whenever the user mentions Supabase security, RLS policies, database security audit, security review, penetration testing a Supabase app, checking if their database is exposed, hardening their Supabase project, fixing RLS, or anything related to securing a Supabase or vibe-coded application. Also trigger when the user asks about securing apps built with Lovable, Bolt, Replit, Cursor, or any AI coding tool that uses Supabase as a backend. Even if the user just says 'is my app secure' or 'check my database' and their project uses Supabase, use this skill. (DEPRECATED: this skill is a backwards-compat shim. Prefer the multi-backend `database-sentinel` skill, which covers Supabase plus Firebase, MongoDB, self-hosted Postgres, and self-hosted MySQL.)

日本語の概要は準備中です。原文の説明を表示しています。

Farenhytee/database-sentinel492026年10月6日 更新

Farenhytee のスキルをすべて見る

このスキルの問題を報告する