惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

www.infosecurity-magazine.com
www.infosecurity-magazine.com
Security Archives - TechRepublic
Security Archives - TechRepublic
TaoSecurity Blog
TaoSecurity Blog
Cloudbric
Cloudbric
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
N
News and Events Feed by Topic
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
S
Securelist
The Cloudflare Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
D
DataBreaches.Net
S
Schneier on Security
L
LangChain Blog
Jina AI
Jina AI
M
MIT News - Artificial intelligence
Recent Announcements
Recent Announcements
T
Tenable Blog
B
Blog RSS Feed
V
Visual Studio Blog
Simon Willison's Weblog
Simon Willison's Weblog
G
Google Developers Blog
T
The Exploit Database - CXSecurity.com
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
WordPress大学
WordPress大学
W
WeLiveSecurity
I
InfoQ
The Hacker News
The Hacker News
雷峰网
雷峰网
月光博客
月光博客
P
Privacy & Cybersecurity Law Blog
O
OpenAI News
Hacker News: Ask HN
Hacker News: Ask HN
T
Threat Research - Cisco Blogs
GbyAI
GbyAI
The Last Watchdog
The Last Watchdog
P
Privacy International News Feed
Cyberwarzone
Cyberwarzone
S
SegmentFault 最新的问题
L
Lohrmann on Cybersecurity
人人都是产品经理
人人都是产品经理
V
V2EX
V
Vulnerabilities – Threatpost
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
C
Cybersecurity and Infrastructure Security Agency CISA
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
T
Troy Hunt's Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
阮一峰的网络日志
阮一峰的网络日志
SecWiki News
SecWiki News
Microsoft Azure Blog
Microsoft Azure Blog

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Why Your Supabase Data Is Exposed (And You Don’t Know It)
Jordan Sterc · 2026-04-26 · via DEV Community

Why Your Supabase Data Is Exposed (And You Don’t Know It)

The four RLS mistakes that silently leak production data — and how to verify your policies actually work.


In January 2025, security researchers found over 170 apps built with Lovable had exposed databases. Every user’s data — emails, messages, private records — was publicly readable by anyone with the project URL and the anonymous key. The anonymous key is embedded in every Supabase client-side app. It’s meant to be public.

The cause wasn’t a Supabase bug. It was missing Row Level Security.

If you’re building on Supabase, RLS is not optional. Any table without it is publicly readable and writable by anyone who can reach your API. This post covers the four RLS mistakes that silently expose data — including the one that’s counterintuitive — and how to verify your policies actually do what you think they do.


What RLS Actually Does

Row Level Security is a Postgres feature that lets you write SQL rules controlling which rows a user can see, insert, update, or delete. Supabase enforces these rules at the database level — below your application code, below your API routes, below your middleware.

Without RLS, the flow is:

Client (anon key) → Supabase API → PostgreSQL → All rows returned

Enter fullscreen mode Exit fullscreen mode

With RLS:

Client (anon key) → Supabase API → PostgreSQL → Only rows matching the policy

Enter fullscreen mode Exit fullscreen mode

The critical thing: RLS operates regardless of how the query arrives. If someone finds a way around your Next.js auth middleware and hits the Supabase API directly, RLS still enforces your rules. Application-level guards are a layer on top. RLS is the floor.


Mistake 1: RLS Disabled (The Data Leak)

Tables created through the SQL Editor or raw migrations have RLS disabled by default. The Supabase Dashboard shows a warning for tables missing RLS, but if you’re running migrations programmatically or using an ORM, you may never see it.

-- This table is publicly accessible to anyone with your anon key
CREATE TABLE user_profiles (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  user_id UUID REFERENCES auth.users,
  email TEXT,
  subscription_status TEXT,
  private_notes TEXT
);
-- RLS is disabled. Anyone can SELECT * from this table.

Enter fullscreen mode Exit fullscreen mode

The fix — enable RLS immediately after creating the table:

CREATE TABLE user_profiles (
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
  user_id UUID REFERENCES auth.users,
  email TEXT,
  subscription_status TEXT,
  private_notes TEXT
);

-- Enable RLS
ALTER TABLE user_profiles ENABLE ROW LEVEL SECURITY;

-- Add a policy — users can only see their own profile
CREATE POLICY "Users can view own profile"
  ON user_profiles
  FOR SELECT
  TO authenticated
  USING (auth.uid() = user_id);

Enter fullscreen mode Exit fullscreen mode

Check which tables in your project have RLS disabled:

SELECT schemaname, tablename, rowsecurity
FROM pg_tables
WHERE schemaname = 'public'
  AND rowsecurity = false;

Enter fullscreen mode Exit fullscreen mode

Any table in that result set is publicly accessible.


Mistake 2: RLS Enabled With No Policies (The Silent Lockout)

This is the counterintuitive one. You enable RLS on a table but don’t add any policies. What happens?

Every query returns zero rows. No error. No warning.

This isn’t a bug — it’s by design. RLS with no policies defaults to deny all. The database is completely locked down. But because queries succeed (they just return nothing), this is easy to miss in development. You enable RLS, run a select, get an empty array, assume your policies are working.

const { data } = await supabase
  .from('user_profiles')
  .select('*');

console.log(data); // [] — but your table has 500 rows
// No error. You have no idea why.

Enter fullscreen mode Exit fullscreen mode

The fix — always add at least one policy when enabling RLS:

-- Enable RLS
ALTER TABLE user_profiles ENABLE ROW LEVEL SECURITY;

-- Users can read their own profile
CREATE POLICY "Users can view own profile"
  ON user_profiles
  FOR SELECT
  TO authenticated
  USING (auth.uid() = user_id);

-- Users can update their own profile
CREATE POLICY "Users can update own profile"
  ON user_profiles
  FOR UPDATE
  TO authenticated
  USING (auth.uid() = user_id)
  WITH CHECK (auth.uid() = user_id);

Enter fullscreen mode Exit fullscreen mode

Note: FOR ALL creates one policy covering SELECT, INSERT, UPDATE, DELETE. Useful for simple cases, but you lose the ability to have different conditions for reads vs writes. Use separate policies when your read and write rules differ.


Mistake 3: service_role Key in Client Code

Your Supabase project has two keys:

  • anon key — public, safe for client-side use, RLS enforced
  • service_role key — private, bypasses RLS entirely, grants unrestricted database access

The service_role key is for server-side operations that legitimately need to bypass RLS — admin actions, background jobs, migrations. It should never appear in client-side code, environment variables accessible to the browser, or committed to git.

// Wrong — anyone who inspects your app can steal this key
// and read your entire database
const supabase = createClient(
  process.env.NEXT_PUBLIC_SUPABASE_URL,
  process.env.NEXT_PUBLIC_SUPABASE_SERVICE_ROLE_KEY // ← never public
);

// Right — anon key on the client
const supabase = createClient(
  process.env.NEXT_PUBLIC_SUPABASE_URL,
  process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY // ← safe
);

Enter fullscreen mode Exit fullscreen mode

If you need to run a privileged operation from the client — marking a payment complete, promoting a user role — put it in a Supabase Edge Function that validates the caller’s permissions before using the service_role key server-side:

// supabase/functions/promote-user/index.ts
import { createClient } from 'npm:@supabase/supabase-js';

Deno.serve(async (req) => {
  // Verify the caller is authenticated
  const authHeader = req.headers.get('Authorization');
  const userClient = createClient(
    Deno.env.get('SUPABASE_URL')!,
    Deno.env.get('SUPABASE_ANON_KEY')!,
    { global: { headers: { Authorization: authHeader! } } }
  );

  const { data: { user } } = await userClient.auth.getUser();
  if (!user) return new Response('Unauthorized', { status: 401 });

  // Verify the caller is an admin (using RLS-enforced query)
  const { data: admin } = await userClient
    .from('admins')
    .select('id')
    .eq('user_id', user.id)
    .single();

  if (!admin) return new Response('Forbidden', { status: 403 });

  // Now use service_role to perform the privileged action
  const adminClient = createClient(
    Deno.env.get('SUPABASE_URL')!,
    Deno.env.get('SUPABASE_SERVICE_ROLE_KEY')! // Safe — server-side only
  );

  // ... perform admin action
});

Enter fullscreen mode Exit fullscreen mode


Mistake 4: RLS Without Indexes (The Performance Trap)

This one doesn’t leak data — it kills query performance. RLS policies run on every row scanned by a query. If your policy references a column with no index, Postgres does a sequential scan of the entire table on every request.

-- This policy runs auth.uid() = user_id on every row
CREATE POLICY "Users see own data"
  ON posts
  FOR SELECT
  TO authenticated
  USING (auth.uid() = user_id);

Enter fullscreen mode Exit fullscreen mode

Without an index on user_id, a table with 100,000 rows scans all 100,000 rows to find the ones that match. With an index, Postgres jumps directly to the matching rows.

-- Add this after creating the table and enabling RLS
CREATE INDEX idx_posts_user_id ON posts(user_id);

Enter fullscreen mode Exit fullscreen mode

The performance difference on large tables can be 100x or more.

Second performance issue: calling auth.uid() without wrapping it in a subquery causes Postgres to re-evaluate it on every row:

-- Slower — auth.uid() called on every row
USING (auth.uid() = user_id)

-- Faster — auth.uid() evaluated once and cached
USING ((SELECT auth.uid()) = user_id)

Enter fullscreen mode Exit fullscreen mode

The SELECT wrapper causes the query planner to evaluate auth.uid() once and reuse the result, rather than calling the function on every row.


How to Verify Your Policies Actually Work

The SQL Editor in Supabase runs queries as the postgres role, which bypasses RLS. Testing your policies in the SQL Editor tells you nothing about what your users can actually access.

Test from the client SDK:

// Test as authenticated user
const { data: { session } } = await supabase.auth.signInWithPassword({
  email: 'testuser@example.com',
  password: 'testpassword'
});

const { data, error } = await supabase
  .from('user_profiles')
  .select('*');

// Should only return the test user's own profile
console.log(data);

Enter fullscreen mode Exit fullscreen mode

Or use the Supabase CLI to simulate different roles:

-- In the SQL Editor, test as anon role
SET LOCAL ROLE anon;
SELECT * FROM user_profiles; -- Should return 0 rows

-- Test as authenticated role with a specific user
SET LOCAL ROLE authenticated;
SET LOCAL request.jwt.claims TO '{"sub": "your-user-uuid"}';
SELECT * FROM user_profiles; -- Should return only that user's rows

Enter fullscreen mode Exit fullscreen mode


The Production Security Checklist

Before you ship:

  • [ ] RLS enabled on every table in the public schema
  • [ ] Every RLS-enabled table has at least one policy
  • [ ] service_role key is not in any client-side code or public environment variable
  • [ ] Indexes added on every column referenced in RLS policies
  • [ ] auth.uid() wrapped in (SELECT auth.uid()) in policies
  • [ ] Views have security_invoker = true if they should respect RLS
  • [ ] Policies tested from the client SDK, not the SQL Editor
  • [ ] Storage buckets have RLS policies configured (separate from table policies)

Run this query to find all public tables missing RLS:

SELECT schemaname, tablename
FROM pg_tables
WHERE schemaname = 'public'
  AND rowsecurity = false
ORDER BY tablename;

Enter fullscreen mode Exit fullscreen mode

If that query returns anything, your data is publicly accessible. Fix it before you ship.


If you’re building on Supabase and hitting an RLS edge case — multi-tenant isolation, role-based access control, storage bucket policies, realtime subscription filtering — drop a comment. I’ll answer.


Disclosure: This post was produced by AXIOM, an agentic developer advocacy workflow powered by Anthropic’s Claude, operated by Jordan Sterchele. Human-reviewed before publication.