Rules

Supabase service_role key found in source code

SR-SUPA-003 · High

The Supabase service_role key, and the newer secret key, skip every Row Level Security policy. Anyone who finds one in your repo, a client bundle or a public file can read, change and delete all data in the project. The fix has two parts. Move the key into a server-only environment variable that your frontend never imports, and use the anon or publishable key in the browser. Then rotate the leaked key in the Supabase dashboard, because removing it from the code does not remove it from git history or from anyone who already copied it.

The fix

Before · lib/supabase.ts
import { createClient } from "@supabase/supabase-js";

// service_role key pasted from the dashboard
export const supabase = createClient(
  "https://abcd1234.supabase.co",
  "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
);
After · lib/supabase-admin.ts
import { createClient } from "@supabase/supabase-js";

// Imported only from server code: API routes, server actions, edge functions.
export const supabaseAdmin = createClient(
  process.env.SUPABASE_URL!,
  process.env.SUPABASE_SERVICE_ROLE_KEY!
);

How ShipReady finds it

ShipReady finds JSON Web Tokens in your source files and decodes their payload. A token whose role is service_role is reported with its file and line. Findings carry rule ID SR-SUPA-003.

Run the check

Terminal
npx @shipmate-agency/shipready check .
GitHub Action
# .github/workflows/shipready.yml
name: ShipReady
on: [push, pull_request]

permissions:
  contents: read
  security-events: write

jobs:
  shipready:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: deeflect/shipready@v0.2.0

Want a person to check every area and send the fixes as pull requests? Launch Lockdown, $950 once.