Securing Next.js + Supabase, in depth
The specific mistakes that get apps on this stack hacked — and the exact fix for each. No generic checklists.
- ·9 min read
Query Supabase auth.users table without leaking emails
You can't query auth.users from supabase-js, and the usual workarounds leak every email. Use a profiles table, join on it, and keep listUsers server-side.
SupabaseAuthRLSPostgresSecurity - ·9 min read
"Signups not allowed for this instance": Supabase fix
Sign-ups are off in your Supabase project. The two switches behind it, which error each one throws, and why hiding the sign-up button isn't invite-only.
SupabaseAuthRLSAuth HooksSecurity - ·8 min read
Refusing to check out fork pull request code: the fix
actions/checkout now refuses fork PR code in pull_request_target workflows. Setting allow-unsafe-pr-checkout reopens the hole; here is the safe fix.
GitHub ActionsCISecretsSupply Chain - ·9 min read
Next.js latest safe version: 16.4.5+ or 15.5.29+
The latest safe Next.js versions are 16.4.5 on 16.x and 15.5.29 on 15.x, patched November 3, 2026. Below 16.4.1 or 15.5.28 you also miss two critical RCE fixes.
Next.jsCVEDependenciesSecurity Releases - ·7 min read
Next.js remotePatterns: there is no safe "allow all"
In next/image remotePatterns, hostname '*' and '**' both match every host, so /_next/image will fetch from any URL. Pin exact hosts and paths instead.
Next.jsImagesSSRFSupabaseSecurity - ·9 min read
Supabase Edge Function 401 Invalid JWT: the safe fix
A 401 Invalid JWT from a Supabase Edge Function comes from the platform's verify_jwt check. Turning it off is safe only if your code verifies the caller.
SupabaseEdge FunctionsAuthJWT - ·8 min read
"url" parameter is not allowed: Next.js 16 next/image
Next.js 16 returns "url" parameter is not allowed when an image host resolves to a private IP; gate dangerouslyAllowLocalIP to next dev, never commit true.
Next.jsImagesSSRFSupabaseSecurity - ·9 min read
Supabase webhook secret: DB webhooks aren't signed
There is no Supabase Database Webhook secret to find: the requests are unsigned, so send your own token header and check it with timingSafeEqual.
SupabaseWebhooksNext.jsSecretsSecurity - ·7 min read
Fix "Legacy API keys are disabled" in Supabase
Supabase's 'Legacy API keys are disabled' means a client sent an old anon or service_role JWT; give that client a new key instead of re-enabling the old pair.
SupabaseAPI KeysSecretsMigrations - ·8 min read
Supabase: Public Can Execute SECURITY DEFINER Function
The warning means anon can call a SECURITY DEFINER function over RPC, and revoking from anon alone won't clear it: revoke from public, anon and authenticated.
SupabasePostgresSECURITY DEFINERSecurity AdvisorGrants - ·7 min read
Next.js open redirect: why startsWith('/') fails
A Next.js redirect to a ?next= or returnTo param is an open redirect, and startsWith('/') won't stop /\evil.com. Check the parsed origin instead.
Next.jsOpen RedirectAuthSecurity - ·8 min read
Rate limiting a Next.js server action (Supabase)
Next.js has no built-in rate limiter, and Server Actions are public POST endpoints. Limit by IP in a shared store, and close the Supabase anon-key back door.
Next.jsServer ActionsSupabaseRate LimitingSecurity - ·7 min read
React2Shell in Next.js: affected versions and the fix
React2Shell (CVE-2025-55182) is a CVSS 10 RCE in Next.js 15.x and 16.x App Router apps. Check if your version was affected, patch it, and rotate secrets.
Next.jsCVEReact Server ComponentsDependenciesSupabase - ·7 min read
use server vs server-only: they're opposites
"use server" doesn't mean server-only. It makes functions callable from the browser. Use import "server-only" to keep a module off the client.
Next.jsServer ActionsSupabaseSecurity - ·7 min read
"The middleware file convention is deprecated": fix
Next.js 16 warns "The middleware file convention is deprecated. Please use proxy instead." Rename to proxy.ts, then re-check your auth matcher.
Next.jsMiddlewareMigrationAuthSecurity