Skip to content

Security basics

"must be owner of table objects" in the Supabase SQL Editor

Supabase "must be owner of table objects": your SQL tried to change a table Storage owns. RLS is already on, so delete that line and keep your policies.

Vlad Tkachenko12 min read
A door with its lock already shut and a list pinned beside it, and an amber padlock held up in front of it with nowhere to go.

In short

  • Supabase "must be owner of table objects" (code 42501) means a line of your SQL tried to change storage.objects, a table that belongs to Supabase Storage and not to the postgres role your SQL Editor runs as. That line changed nothing.
  • The line is nearly always alter table storage.objects enable row level security, and Row Level Security is already on for that table. Delete it and run the rest. Your create policy lines are still allowed.
  • Leave the table with its owner. Supabase reserves the roles that own it, and the secret key that would skip your policies is a master key to every file once it is in your app.
  • "must be owner of table users" is the same rule on auth.users. Keep your own columns in a profiles table of your own.

You asked Lovable, Bolt, Cursor or Claude Code for profile pictures, and it handed you a block of SQL to paste into the SQL Editor in your Supabase dashboard. You paste it, press Run, and the editor stops on the first line:

ERROR:  42501: must be owner of table objects

The line it stopped on reads:

alter table storage.objects enable row level security;

Supabase "must be owner of table objects" means that line tried to change storage.objects, the table where Supabase Storage keeps one row for every file in your project. The table belongs to Storage, and only its owner may change it. The line changed nothing, and it had nothing to do anyway: Row Level Security, Supabase's rules about who may touch which rows, is already on for that table. Delete the line and run the rest.

The answers you find next will tell you to make yourself the owner of the table, to run the script as one of Supabase's admin roles, or to switch your app to the secret key so the upload stops asking. The first two fail with errors of their own. The third works, and it lets anyone who opens your app delete every file you store.

What does "must be owner of table objects" mean?

It means the role running your SQL is not the owner of the table, and the statement is one only the owner may run. Postgres's page on ALTER TABLE says it in one line: "You must own the table to use ALTER TABLE."

Think of storage.objects as a flat in a building Supabase manages. The door and its lock came with the flat, and the lock is already shut. You decide who gets let in by writing the list pinned beside the door, and that list is your policies. The door itself is the building's, and alter table is a request to change the door.

PartExampleWhat it tells you
Code42501Postgres's code for insufficient_privilege. Two other errors carry it as well, and a section further down tells them apart
Messagemust be owner of table objectsThe statement needs the owner of the table, whatever else the role running it may do
Last wordobjectsThe name of the table without its schema. objects is storage.objects, and users is auth.users
From a migrationERROR: must be owner of table objects (SQLSTATE 42501)The same error from the Supabase CLI, followed by At statement: 0 and the line it stopped on

The wording comes from Postgres's privilege checks, which raise every "must be owner of" message with that one code. The CLI form is from an issue on the Supabase CLI, where a preview branch stopped on the same line while its migrations ran.

Supabase's guide to Postgres roles says "Queries you run in the Dashboard execute as postgres", which is your project's main role. A table you create in the SQL Editor belongs to it, which is why the same line runs without complaint on a table of your own.

Who owns storage.objects?

Storage does, through a role of its own called supabase_storage_admin. Storage creates its tables itself, and the migration that creates them hands storage.objects to that role and switches Row Level Security on, in the same file. Auth does the same with its own tables: Supabase's Postgres setup gives auth.users to supabase_auth_admin.

You can ask your own project:

select schemaname, tablename, tableowner
from pg_tables
where schemaname in ('storage', 'auth')
  and tablename in ('objects', 'users');

pg_tables is Postgres's list of tables, with the owner of each. When tableowner names one of Supabase's own roles, the table is theirs, and no alter table on it will run from the SQL Editor.

Older answers and tutorials still open with that line because it used to run. Supabase's changelog post Restricting Access on Auth, Storage, and Realtime Schemas on April 21, 2025 lists what stopped on that date in those three schemas, among them creating tables and functions, dropping them, and creating indexes on existing tables. Supabase's maintainer answered the storage case in a thread on GitHub: "Due to recent permission changes on postgres platform, altering tables in storage schema is no longer possible."

How do I fix "must be owner of table objects"?

Delete the alter table storage.objects line and run the script again. Row Level Security is already on, so the line had nothing left to do. The migration that creates the table switches it on with ALTER TABLE storage.objects ENABLE ROW LEVEL SECURITY;, and the maintainer's answer in that thread says: "Since row level security is now enabled by default on storage.objects table, you can safely delete or comment out" the statement.

To see it in your own project:

select relrowsecurity
from pg_class
where oid = 'storage.objects'::regclass;

pg_class holds a row for every table, and relrowsecurity is the switch. true means it is on. In the flat, the lock was shut before you moved in, and the line was trying to fit it a second time.

The policies below that line may not have been created when the script stopped, so look before you assume they were:

select policyname, cmd, roles
from pg_policies
where schemaname = 'storage' and tablename = 'objects';

Each row is one entry on the list beside the door: its name, the action it covers (INSERT, SELECT, UPDATE, DELETE or ALL) and who it is for. If the upload rule is not there, run the script again without the alter table line. What that rule should say, and why upsert needs two more, is in the post on "new row violates row-level security policy for table objects", the error an upload gets while the rule is missing.

If the line is in a migration file, delete it from the file. The CLI prints At statement: 0 and the statement, so you can see which one it was. The maintainer's answer adds a step for when your project's remote migration history already holds the statement: supabase migration repair --status applied, followed by that migration's version.

Why create policy is still allowed. Postgres normally keeps policies for the owner as well. Its page on CREATE POLICY says "You must be the owner of a table to create or change policies for it." Supabase runs an extension called supautils on its Postgres, and one of its settings, policy_grants, names the tables where the postgres role may create policies anyway. storage.objects, storage.buckets and auth.users are on that list. The changelog lists the same among what still works: creating RLS policies and database triggers on those tables.

You write the list beside the door. The door and its lock belong to Storage, and the lock was shut before you arrived.

Why not make yourself the owner?

Because Supabase keeps the roles that own those tables out of reach, and every route to them is refused. These are the commands you will be offered:

  • alter table storage.objects owner to postgres; Handing a table to a new owner is an alter table too, so it needs the current owner and stops at the same message.
  • grant supabase_storage_admin to postgres; The supautils setting reserved_memberships lists supabase_storage_admin and supabase_auth_admin among the roles nobody may be made a member of, so the grant is refused.
  • set role supabase_storage_admin; Postgres lets a session switch only to a role it is a member of, which is the membership the grant above was meant to give.
  • Running it as supabase_admin. The roles guide describes that role as "An internal role Supabase uses for administrative tasks, such as running upgrades and automations", and it is on the same reserved list.

Supabase's changelog gives the reason for the restriction as preventing unintended side effects from third-party tools and from changes users make in those schemas. Storage and Auth are separate servers that read and write these tables on every upload and every sign-in.

Should I use the secret key instead?

Not in your app. It does get the upload through. Supabase's Storage access control guide says "Service keys entirely bypass RLS policies, granting you unrestricted access to all Storage APIs." That makes it the building's master key: it opens every flat and never reads the list beside the door.

Put the secret key (sb_secret_…, or service_role in older projects) in your app and it travels in the code your site sends to every visitor. Anyone who copies it from there can list, download, replace or delete every file in every bucket, without signing in. The same key skips Row Level Security on your tables as well. The guide ends that paragraph with "Remember you should not share the service key publicly", and a key in a web page is shared with everyone who loads it.

The secret key belongs in server code only you run, such as an Edge Function, for a file your server has to write itself. An upload that a signed-in person makes from your app needs a policy. Which keys belong in your frontend goes through the two kinds, and if the secret key is already in a version you published, rotate it first.

You can check from outside whether a secret key is already in your live app. Our free scan reads the code your site sends to every visitor, tells a publishable key from a secret one, and asks your project which of your buckets will list their files to a stranger. It takes about 20 seconds and needs no account: scan your app.

The publishable key gets what the list allows. The secret key goes round the list, for whoever holds it.

Is this the same as "permission denied for table"?

No. All three of these carry code 42501, and a different thing said no in each:

MessageWhat said noWhere to look
must be owner of table objectsthe statement needs the owner of the tablethis page
permission denied for table ordersthe role has no grant on the tablethe post on the missing grant
new row violates row-level security policy for table "orders"a policy turned the row downthe post on that error

The first is about changing a table. The other two are about using one, and you fix those in your own grants and policies.

"must be owner of table users"

That is the same rule on auth.users, the table where Supabase Auth keeps everyone who has signed up, and its owner is supabase_auth_admin. The line behind it is usually alter table auth.users add column ..., to keep a name or a plan beside each user, or a create index on one of its columns, which the changelog also lists among what stopped.

The fix Supabase documents is a table of your own beside it. Its guide to user data says "For security, the Auth schema is not exposed in the auto-generated API", and "If you want to access users data via the API, you can create your own user tables in the public schema." In the shape of its example:

create table public.profiles (
  id uuid not null references auth.users on delete cascade,
  first_name text,
  last_name text,
  primary key (id)
);

alter table public.profiles enable row level security;

This time the alter table runs, because the SQL Editor's postgres role made public.profiles and owns it. It is your own flat, so you fit the lock yourself. The guide asks you to reference auth.users "to ensure data integrity", with on delete cascade, so a profile goes when its user does.

The changelog keeps foreign keys to these tables allowed, and triggers on them, and the guide fills profiles from a trigger on auth.users when someone signs up. If sign-up starts failing once that trigger is in, the post on "Database error saving new user" is where to look. A new table in public needs policies of its own as well, and the post on switching RLS on for every table has them.

Before you change who may touch your files

Keep a copy of your database and your files from before you change the rules, and hear about it when a bucket starts answering strangers.

Reeve Care keeps a copy of your Supabase database:

  • an encrypted copy on a schedule, on Reeve's own storage in the EU, outside your Supabase account
  • your uploaded files as well, once you connect a Storage credential, so files a delete rule reached by mistake can come back from a copy taken before they went
  • each copy verified before it counts, by counting the rows in every table
  • a one-click restore, with a safety copy of the current state taken first
  • everything Monitor does

See what Care keeps

Reeve Monitor keeps checking from outside:

  • the full security check every hour, including whether a bucket lists its files to a visitor with no login and whether a secret key has turned up in your app's code
  • whether your app answers, every 60 seconds, and up to 10 more pages you choose
  • an alert by email, Telegram, Slack or webhook when the app goes down or a page breaks
  • a monthly report on your app, written for you

See what Monitor checks

The free scan shows what a visitor with no login can reach today: which keys are in your app's code, and which buckets list their files. About 20 seconds, and no account.

Scan your app free in 20 seconds

What to do now

What to do

  • Read the last word of the message. objects is storage.objects, users is auth.users, and both belong to Supabase.
  • Delete alter table storage.objects enable row level security from the script or the migration. Row Level Security is already on, and relrowsecurity shows it.
  • Run the rest, then list the policies on storage.objects to see which ones exist.
  • Leave the owner as it is. The roles that own these tables are reserved, and no grant reaches them.
  • Keep the secret key out of your app. It skips every policy on every file.
  • For auth.users, keep your own columns in public.profiles and switch Row Level Security on there.

Start with the list of policies, because it tells you whether the upload rule exists at all. If you are about to change who may delete files, keep a copy first.

FAQ

What does "must be owner of table objects" mean in Supabase?

It means a statement in your SQL tried to change storage.objects, the table where Supabase Storage keeps a row for every file, and only the owner of a table may run that statement. The SQL Editor runs as the postgres role, and the owner is supabase_storage_admin, Storage's own role. The code is 42501, and the statement changed nothing.

Is Row Level Security already enabled on storage.objects?

Yes. Storage's own migration switches it on in the file that creates the table, and Supabase's maintainer says the alter table line can be deleted for that reason. To see it in your project, run select relrowsecurity from pg_class where oid = 'storage.objects'::regclass; in the SQL Editor. It answers true.

Can I still create storage policies in the SQL Editor?

Yes. Postgres normally lets only the owner of a table create policies on it, and Supabase adds a setting that names the tables where the postgres role may create them anyway. storage.objects, storage.buckets and auth.users are on that list, and Supabase's changelog names creating RLS policies and triggers among what you can still do.

How do I fix "must be owner of table users"?

Leave auth.users as it is and keep what you wanted to add in a table of your own. Supabase's guide to user data creates public.profiles with an id that references auth.users and is deleted with it, and fills it from a trigger when someone signs up. You own that table, so you can add columns to it and switch Row Level Security on.

Should I use the service_role key to get round it?

Not in your app. Supabase's Storage guide says service keys entirely bypass RLS policies. That gets the upload through, and it lets anyone who copies the key out of your app list, replace or delete every file in every bucket. Keep it in server code only you run, and write the policy instead.

Written by

Vlad Tkachenko

Founder, Reeve

I spend my time looking at apps built with Lovable, Bolt, v0, Cursor and Replit, and at the short list of mistakes that keep turning up in them.

More about the author

Read next

All articles

Back up your Supabase database before your next change

Reeve keeps an encrypted copy on a schedule and restores it for you if something breaks.

See Supabase backups

Automated external check, not a full audit. Absence of findings is not a guarantee of safety.