lowCWE-1127

Database Migrations Not in Repository

Database schema changes are applied manually through the Supabase Dashboard instead of tracked migration files, making security audits and rollbacks impossible.

How It Works

When developers modify the database schema directly through the Supabase Dashboard SQL editor instead of using migration files, changes are untracked and unreviewable. There is no history of what was changed, when, or by whom. RLS policies, function definitions, and table structures can be silently modified without code review. This makes it impossible to audit security configurations, reproduce the database in a new environment, or roll back dangerous changes. It also prevents CI from validating that RLS is properly configured.

Vulnerable Code
# Project structure missing migrations
my-app/
  src/
  package.json
  # No supabase/ directory!
  # Schema changes done manually in Dashboard
Secure Code
# Proper Supabase project structure
my-app/
  src/
  package.json
  supabase/
    migrations/
      20240101000000_create_profiles.sql
      20240102000000_add_rls_policies.sql
      20240103000000_create_storage_policies.sql
    seed.sql
    config.toml

Real-World Example

A fintech startup had no migration files and made all schema changes through the Dashboard. When a developer accidentally dropped an RLS policy in production, there was no record of the original policy, no way to roll back, and the table was exposed for 3 hours before anyone noticed.

How to Prevent It

  • Use supabase db diff to generate migration files from Dashboard changes
  • Store all migrations in the repository under supabase/migrations/
  • Require code review for all migration files before applying them
  • Set up CI to run supabase db lint on every pull request

Affected Technologies

SupabaseNode.jsNext.jsReact

Data Hogo detects this vulnerability automatically.

Scan Your Repo Free

Related Vulnerabilities